external-application-button icon indicating copy to clipboard operation
external-application-button copied to clipboard

A specialized version for djview4?

Open jsbien opened this issue 5 years ago • 33 comments

The Djvu format was very popular in digital libraries, but when the NPAPI plugin stopped to be supported viewing online documents in this format became terribly cumbersome (you cannot simply download the document because DjVu keeps the pages in separate files). Your excellent extension is in principle the right solution, but the configuration seems too difficult for a typical DjVu user. It would be also nice to eliminate the need to use the context menu and open the document without asking. Cf. https://sourceforge.net/p/djvu/feature-requests/100/

jsbien avatar Oct 22 '20 06:10 jsbien

Prepare the command that opens a local file with djview4 (including all the arguments needed) and I'll see what I can do.

andy-portmen avatar Oct 22 '20 07:10 andy-portmen

I can extend the "External Application Button" extension to include a sample for this application so that the users do not need to deal with writing the complex command.

It would be also nice to eliminate the need to use the context menu

It is possible. I'll investigate.

andy-portmen avatar Oct 22 '20 07:10 andy-portmen

By the way, any extension can use this extension for native connections to prevent writing the native messaging part too.

andy-portmen avatar Oct 22 '20 07:10 andy-portmen

Thank you very much for your interest!

The configuration instruction has been provided to me by Joachim Aleszkiewicz.

  1. Display Name: DjView
  2. Executable name: in Linux djview, in Windows c:\Program Files(x86)\DjVuLibre\djview.exe
  3. Arguments: [HREF]
  4. Link Contex selected
  5. Target Pattern: *://*/*.djvu

For testing I suggest to use https://djvu.szukajwslownikach.uw.edu.pl/. The directories IMPACT... contain small self-contained single page documents; other directories contain so called unbundled documents and it is index.djvu which should be opened.

jsbien avatar Oct 22 '20 08:10 jsbien

@jsbien, we now have all the features you need:

  1. The extension has a new placement option to allow left-click interruption for wildcard filters.
  2. The extension now pre-configures itself if there is a platform related JSON file located in the "configs" directory. This way, you can prepare the extension to work for any executable. When the extension works, simply export the options and place it in this directory (win.json, mac.json, and lin.json). Update the manifest file and icons, then pack the extension to create your customized native integration.

andy-portmen avatar Oct 25 '20 12:10 andy-portmen

Thanks! Unfortunately I don't see the new placement options. It is suffient to use the update button to update the extension?

jsbien avatar Oct 25 '20 13:10 jsbien

I haven't released the new version yet. You need to wait for a few days or install the developer version from GitHub.

andy-portmen avatar Oct 25 '20 13:10 andy-portmen

I would be glad to install from GitHub. However all the instructions I found depend on the presence of a *.xpi file. I don't see such a file in the repository.

jsbien avatar Oct 25 '20 13:10 jsbien

It is now approved on FF, so just update your extension.

andy-portmen avatar Oct 25 '20 14:10 andy-portmen

Great! I still see version 0.3.9 and "no update found". I understand some time is needed for propagating the update to user, so I wait patiently.

jsbien avatar Oct 25 '20 14:10 jsbien

It's already available and it works as expected. Thank you very much!

I have now to test the ditribution of the configuration. I'm not sure the instruction is sufficiently clear for me, but I will try.

jsbien avatar Oct 25 '20 14:10 jsbien

The configuration directory is "config" or "configs"? In the code I see fetch('configs/' + os + '.json') Where exactly this directory is located on Linux and on Windows?

jsbien avatar Oct 25 '20 16:10 jsbien

  1. download the entire project from https://github.com/andy-portmen/external-application-button/archive/master.zip
  2. extract to a local directory and open the firefox folder
  3. create a new directory called "configs"
  4. paste your exported config file here and rename it to win.json if you are on a Windows machine.
  5. open about:debugging#/runtime/this-firefox in a browser tab
  6. press "Load Temporary Add-on" and point it to the manifest file inside the "firefox" directory.

You must now have a custom EAB extension and the previous config should have been exported to this new installation.

For the extension to actually work, you need to add its custom id (....@temporary-addon) to the list of supported ids of my native client (config.js file) and reinstall the native client;

https://github.com/andy-portmen/native-client/releases/tag/0.9.1 https://github.com/andy-portmen/native-client/blob/master/config.js

andy-portmen avatar Oct 26 '20 09:10 andy-portmen

Thanks. I understand this is the instruction the install the extension from scratch directly from the repository. Is this aboslutely necessary for the pre-configuration?

At point 6 I got two warnings: Reading manifest: Warning processing background.persistent: Event pages are not currently supported. This will run as a persistent background page. Reading manifest: Warning processing offline_enabled: An unexpected property was found in the WebExtension manifest.

For the time being I gave up reinstalling the native client, perhaps I will try later.

What about closing this issue as solved and opening another one, e.g. "Making preconfiguration easier"?

What is the relation of native-client to EAB? I just noticed there is a Debian package for native-client. Can using it simplify the installation of EAB?

jsbien avatar Oct 26 '20 10:10 jsbien

I wrote (in Polish) an installation instruction and realized that for a typical user it is prohibitively complicated. A typical user for me is a linguist or a historian using our corpora (old Polish texts and dictionaries) search tool at https://szukajwslownikach.uw.edu.pl/ (practically orphaned because of the lack of funds) . They need not an enhancement of EAB, but an EAB fork with all the configuration options hard-wired in the code. Any chance for such a solution? Unfortunately I don't have the necessary skills to do it myself.

jsbien avatar Nov 03 '20 07:11 jsbien

At point 6 I got two warnings:

ignore warnings.

What is the relation of native-client to EAB? I just noticed there is a Debian package for native-client. Can using it simplify the installation of EAB?

The native client is the native component to talk with a native application for a few extensions including EAB.

andy-portmen avatar Nov 03 '20 13:11 andy-portmen

They need not an enhancement of EAB, but an EAB fork with all the configuration options hard-wired in the code.

With the recent update of EAB, you can create a custom extension with a custom icon and hardcoded configs. Then submit it to Chrome and FF and share the ID of the extension in different stores. I'll include the ids to my native client. This way even a non-technical user can install the extension, and it is ready to use.

andy-portmen avatar Nov 03 '20 13:11 andy-portmen

Sounds great, I will try. However I encountered a minor but irritating problem: why the original djview4 icon is not accepted? prebuilt-hi32-djview4 After Update application there is no change.

jsbien avatar Nov 04 '20 07:11 jsbien

why the original djview4 icon is not accepted?

I don't mind. You need to ask permission from the developer(s) though.

andy-portmen avatar Nov 04 '20 08:11 andy-portmen

I mean it is not accepted by your configuration panel, cf. #56.

jsbien avatar Nov 04 '20 09:11 jsbien

You need to replace all icons in /firefox/data/icons/

andy-portmen avatar Nov 07 '20 12:11 andy-portmen

OK

You wrote:

  1. download the entire project from https://github.com/andy-portmen/external-application-button/archive/master.zip
    
  2. extract to a local directory and open the firefox folder
    
  3. create a new directory called "configs"
    
  4. paste your exported config file here and rename it to win.json if you are on a Windows machine.
    
  5. open about:debugging#/runtime/this-firefox in a browser tab
    
  6. press "Load Temporary Add-on" and point it to the manifest file inside the "firefox" directory.
    

I understand 1. and 2. are equivalent to cloning the repository. 3. and 4. done, cf. https://github.com/jsbien/application-button-for-djview 5. and 6. done, got Extension ID 4964cdb2bcc9ae4aca083843424e33f1c1f1188d@temporary-addon

You wrote:

you need to add its custom id (....@temporary-addon) to the list of supported ids of my native client (config.js file) and reinstall the native client;

Do you mean

 firefox: [
      '{4964cdb2bcc9ae4aca083843424e33f1c1f1188d@temporary-addon-addon}', // test
...

or

  firefox: [
      '{4964cdb2bcc9ae4aca083843424e33f1c1f1188d}', // test
...

or something else? I tried both and none of them seem to work (moreover your original extension stops working).

Single click just downloads the file, selecting djview from the menu opens an empty page: moz-extension://951fd152-83ff-4712-9940-57248b5cc742/data/helper/index.html I guess this may be related to the fact that: firefox/data contains a broken link helper -> ../../../_/helper However for your original extension a similar link works: moz-extension://398e90f0-e771-4a9d-bf23-8befea50aa68/data/helper/index.html Where this page come from?

What are your suggestions?

jsbien avatar Nov 08 '20 08:11 jsbien

Do you mean

The first one with @temporary-addon-addon

I tried both and none of them seem to work

Have you tried to reinstall the native client? Also, you can check the log during the installation to see where the extension places its files, then add the id manually to the list. This way you don't need to reinstall each time you load the developer version of the extension.

Single click just downloads the file, selecting djview from the menu opens an empty page:

Firefox does not follow symlinks, so first zip the "firefox" directory and ask the browser to use the ZIP file instead of the directory. It is much easier to switch to Chrome for your development tests.

However for your original extension a similar link works:

The official release does not have any symlinks.

andy-portmen avatar Nov 29 '20 13:11 andy-portmen

On Sun, Nov 29 2020 at 5:36 -08, andy portmen wrote:

Do you mean

The first one with @temporary-addon-addon

I tried both and none of them seem to work

Have you tried to reinstall the native client?

Don't remember now. Will try again after solving the link problem.

Also, you can check the log during the installation to see where the extension places its files, then add the id manually to the list. This way you don't need to reinstall each time you load the developer version of the extension.

This would be nice.

Single click just downloads the file, selecting djview from the menu opens an empty page:

Firefox does not follow symlinks, so first zip the "firefox" directory and ask the browser to use the ZIP file instead of the directory.

But the link is broken, using ZIP cannot fix it.

It is much easier to switch to Chrome for your development tests.

I tried to find an instruction how to add such a private extension to Chrome but was unable to find quickly anything useful.

jsbien avatar Nov 30 '20 05:11 jsbien

But the link is broken, using ZIP cannot fix it.

Download the latest XPI from Firefox add-ons website. There is a helper directory in the "/data/". replace the symlink with the actual directory.

was unable to find quickly anything useful.

Open chrome://extensions in a browser tab. Enable the developer mode checkbox, and drop the "chrome" directory into the tab.

andy-portmen avatar Nov 30 '20 11:11 andy-portmen

On Mon, Nov 30 2020 at 3:53 -08, andy portmen wrote:

But the link is broken, using ZIP cannot fix it.

Download the latest XPI from Firefox add-ons website. There is a helper directory in the "/data/". replace the symlink with the actual directory.

Done.

The modified extension still doesn't work on Firefox, moreover reinstalling the native client with the custom ID breaks the original one (it shouldn't I think).

Open chrome://extensions in a browser tab. Enable the developer mode checkbox, and drop the "chrome" directory into the tab.

Thanks. I get

Navigation is configured, but "webNavigation" permission is not granted

Some additional questions:

In principle the modified extension should peacefully coexist with the original one? If so, it is easy to change the name of the modified extension to avoid confusion?

When the original extension is configured for DjVu, is it sufficient to disable it when testing the modified one or it should be removed?

FYI, I tried to install both the original and modified extensions on another computer and run into some problems with the native client. I will come back to this later if I don't solve it myself.

jsbien avatar Nov 30 '20 13:11 jsbien

The extension used for today's testing is in my fork of the repository (https://github.com/jsbien/application-button-for-djview). Firefox tries to download the file. The console contains messages like this: Invalid header array: [{name:"Host", value:"djvu.szukajwslownikach.uw.edu.pl"}, {name:"User-Agent", value:"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"}, {name:"Accept", value:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"}, {name:"Accept-Language", value:(void 0)}, {name:"Accept-Encoding", value:"gzip, deflate, br"}, {name:"Connection", value:"keep-alive"}, {name:"Cookie", value:"_ga=GA1.3.1139016456.1606330737; _gid=GA1.3.69600035.1606667185"}, {name:"Upgrade-Insecure-Requests", value:"1"}] WebRequest.jsm:122 applyChanges resource://gre/modules/WebRequest.jsm:122 applyChanges resource://gre/modules/WebRequest.jsm:1056 InterpretGeneratorResume self-hosted:1158 AsyncFunctionNext self-hosted:693

jsbien avatar Dec 02 '20 11:12 jsbien

Chrome works! I just forgot to add the id to config.js. Now the question is: what is the best way to distribute it. Is this the right way to follow: https://stackoverflow.com/questions/23873623/obtaining-chrome-extension-id-for-development ?

jsbien avatar Dec 02 '20 12:12 jsbien

Firefox tries to download the file. The console contains messages like this:

So did it download the file or not? FF sometimes displays warnings that can be ignored.

andy-portmen avatar Dec 03 '20 05:12 andy-portmen

As djview didn't start, I just cancelled download (if I remeber well). Today's attempt to reproduce it gives "Cannot find the native client" despite the ID being added and the client reinstalled. The console contains, among others, the errors

Value must either: .allowed_extensions.28 must () => { let array = Array.from(choices, forceString); let n = array.length - 1; array[n] = `or ${array[n]}`; return `must either [${array.join(", ")}]`; }, or contain the required "data" property NativeManifests.jsm:115 _tryPath resource://gre/modules/NativeManifests.jsm:115

ExtensionError: No such native application com.add0n.node ExtensionUtils.jsm:56:5 ExtensionError resource://gre/modules/ExtensionUtils.jsm:56 startupPromise resource://gre/modules/NativeMessaging.jsm:83

The install said Native Host is installed in /home/jsbien/.config/com.add0n.node This happens both for "webNavigation", ":///*" in the permission section and in the optional_permissions one.

jsbien avatar Dec 03 '20 06:12 jsbien

Today I decided to try to reproduce the problem but this time I watch the console while pressing "Check Connection" on the "One Extra Step" page. The message is This extension does not have permission to use native manifest /home/jsbien/.mozilla/native-messaging-hosts/com.add0n.node.json The file is -rw-r--r-- 1 jsbien jsbien 1345 Dec 29 11:54 com.add0n.node.json

jsbien avatar Dec 29 '20 11:12 jsbien

The problem was solved by modifying manifest.json, actually following the suggestion from #59. Now the question is how to assign a stable ID to be included in your distribution of local server. Using the workflow for "Distribute pre-release version" will do or I have to use "Submitting an add-on"? Or perhaps you have some other suggestion?

jsbien avatar Dec 29 '20 17:12 jsbien

You can clone my "native client" and clear the list of ids. Then add your extension's id. The one that you will get from WebStore. Alternatively, pass the URL of the WebStore, and I'll review the project and add the ID to the list of existing add-ons.

andy-portmen avatar Jan 04 '21 14:01 andy-portmen