Skip to content

Commit

Permalink
Merge pull request #5400 from JabRef/fixJabfoxInstall
Browse files Browse the repository at this point in the history
Fix JabFox integration
  • Loading branch information
Siedlerchr authored Oct 8, 2019
2 parents facda00 + a6948ea commit 8dd3fab
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where it was no longer possible to connect to LibreOffice. [#5261](https://github.com/JabRef/jabref/issues/5261)
- The "All entries group" is no longer shown when no library is open.
- We fixed an exception which occurred when closing JabRef. [#5348](https://github.com/JabRef/jabref/issues/5348)
- We fixed a few problems that prevented JabFox to communicate with JabRef. [#4737](https://github.com/JabRef/jabref/issues/4737) [#4303](https://github.com/JabRef/jabref/issues/4303)
- We fixed an error where the groups containing an entry loose their highlight color when scrolling. [#5022](https://github.com/JabRef/jabref/issues/5022)
- We fixed an error where an exception was thrown when merging entries. [#5169](https://github.com/JabRef/jabref/issues/5169)
- After assigning an entry to a group, the item count is now properly colored to reflect the new membership of the entry. [#3112](https://github.com/JabRef/jabref/issues/3112)
Expand Down
21 changes: 14 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,11 @@ modernizer {
}

// Release tasks
task generateFinalJabRefPS1File(type: Copy) {
from('buildres') {
include 'JabRef.ps1'
}
into 'build'
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [jabRefJarFileName: jar.archiveName])
task deleteInstallerTemp(type: Delete) {
delete "$buildDir/installer"
}

jpackage.dependsOn deleteInstallerTemp
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
Expand Down Expand Up @@ -585,7 +582,9 @@ jlink {
'--app-version', "${project.version}",
'--win-upgrade-uuid', 'd636b4ee-6f10-451e-bf57-c89656780e36',
'--win-dir-chooser',
'--win-shortcut'
'--win-shortcut',
'--temp', "$buildDir/installer",
'--resource-dir', "${projectDir}/buildres"
]
}

Expand All @@ -610,6 +609,14 @@ jlink {
}
}
}
tasks.jpackageImage.doLast {
copy {
from("/buildres/") {
include "jabref.json", "JabRefHost.bat", "JabRefHost.ps1"
}
into "$buildDir/distribution/JabRef"
}
}

jmh {
warmupIterations = 5
Expand Down
35 changes: 35 additions & 0 deletions buildres/JabRef-post-image.wsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" ?>
<package>
<job id="postImage">
<script language="jscript">
<![CDATA[
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
// The script is invoked in the "image" folder and not in "config" for some reason
var jabRefRoot = fileSystem.GetFolder(".").ParentFolder.ParentFolder.ParentFolder.ParentFolder.Path;
var installerConfig = jabRefRoot + "/build/installer/config/";
// Copy additional installer resources
fileSystem.CopyFile(jabRefRoot + "/buildres/JabRefTopBanner.bmp", installerConfig);
var wxsFilePath = installerConfig + "JabRef.wxs";
wxsFile = fileSystem.OpenTextFile(wxsFilePath, 1);
var contents = wxsFile.ReadAll();
wxsFile.Close();
// Add registry values for JabFox
contents = contents.replace("</Product>", "<DirectoryRef Id=\"TARGETDIR\"><Component Id=\"RegistryJabFoxEntries\" Guid=\"b6bc55ad-905c-4258-89b1-8b37abbe559c\" Win64=\"yes\"><RegistryKey Root=\"HKMU\" Key=\"SOFTWARE\\Mozilla\\NativeMessagingHosts\\org.jabref.jabref\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Value=\"[APPLICATIONFOLDER]jabref.json\"/></RegistryKey></Component></DirectoryRef><Feature Id=\"JabFox\" Level=\"1\"><ComponentRef Id=\"RegistryJabFoxEntries\" /></Feature></Product>");
// Specify correct icon in Add/Remove Programs
contents = contents.replace("</Product>", "<Property Id=\"ARPPRODUCTICON\" Value=\"DesktopIcon.exe\" /></Product>");
// Specify banner
contents = contents.replace("</Product>", "<WixVariable Id=\"WixUIBannerBmp\" Value=\"JabRefTopBanner.bmp\" /></Product>");
//contents = contents.replace("</Product>", "<WixVariable Id=\"WixUIDialogBmp\" Value=\"\" /></Product>");
wxsFile = fileSystem.OpenTextFile(wxsFilePath, 2, true);
wxsFile.Write(contents);
wxsFile.Close();
]]>
</script>
</job>
</package>
2 changes: 1 addition & 1 deletion buildres/JabRef.bat → buildres/JabRefHost.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
pushd %~dp0
@powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File ".\JabRef.ps1"
@powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File ".\JabRefHost.ps1"
15 changes: 7 additions & 8 deletions buildres/JabRef.ps1 → buildres/JabRefHost.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ function Respond($response) {
}
}

$jabRefJarFileName = "@jabRefJarFileName@"
$jabRefJar = [System.IO.Path]::Combine($PSScriptRoot, $jabRefJarFileName)
$jabRefExe = [System.IO.Path]::Combine($PSScriptRoot, "JabRef.exe")

try {
$reader = New-Object System.IO.BinaryReader([System.Console]::OpenStandardInput())
Expand All @@ -21,16 +20,16 @@ try {
$message = $messageRaw | ConvertFrom-Json

if ($message.Status -eq "validate") {
if (-not (Test-Path $jabRefJar)) {
return Respond @{message="jarNotFound";path=$jabRefJar}
if (-not (Test-Path $jabRefExe)) {
return Respond @{message="jarNotFound";path=$jabRefExe}
} else {
return Respond @{message="jarFound"}
}
}
if (-not (Test-Path $jabRefJar)) {

if (-not (Test-Path $jabRefExe)) {
$wshell = New-Object -ComObject Wscript.Shell
$popup = "Unable to locate '$jabRefJarFileName' in '$([System.IO.Path]::GetDirectoryName($jabRefJar))'."
$popup = "Unable to locate '$jabRefExe'."
$wshell.Popup($popup,0,"JabRef", 0x0 + 0x30)
return
}
Expand All @@ -39,7 +38,7 @@ try {
#$wshell.Popup($message.Text,0,"JabRef", 0x0 + 0x30)

$messageText = $message.Text
$output = & java -jar $jabRefJar -importBibtex "$messageText" 2>&1
$output = & $jabRefExe -importBibtex "$messageText" 2>&1
#$output = & echoargs -importBibtex $messageText 2>&1
#$wshell.Popup($output,0,"JabRef", 0x0 + 0x30)
return Respond @{message="ok";output="$output"}
Expand Down
Binary file added buildres/JabRefTopBanner.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion buildres/jabref.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "org.jabref.jabref",
"description": "JabRef",
"path": "JabRef.bat",
"path": "JabRefHost.bat",
"type": "stdio",
"allowed_extensions": [
"@jabfox"
Expand Down

0 comments on commit 8dd3fab

Please sign in to comment.