markdown-viewer icon indicating copy to clipboard operation
markdown-viewer copied to clipboard

Transition to Jetpack SDK

Open Thiht opened this issue 10 years ago • 11 comments

Following #20 and #46, + the fact Mozilla is progressively deprecating XUL extensions, it becomes urgent to transition to another solution.

The two solutions are the Jetpack SDK and WebExtensions.

WebExtensions don't allow mime-type registering (yet?) so they're not an option for now.

As always, bhollis/jsonview is a good source of inspiration since it does the same thing as Markdown Viewer but for JSON :)

Important things to check along the development:

  • [x] Linux support
  • [ ] Windows support
  • [x] UTF-8 support
  • [ ] Electrolysis support
  • [ ] Basically no behavioral regression

Thiht avatar Feb 22 '16 14:02 Thiht

WIP on branch no-restart

Thiht avatar Feb 23 '16 10:02 Thiht

Any new information on that? Since SDK will also be deprecated at the end of this year WebExtensions are the only way to go forward.

Croydon avatar Feb 03 '17 05:02 Croydon

As far as I'm aware, and according to all the tests I've done, there's no way to make Markdown Viewer work with either Jetpack or WebExtensions.

Markdown Viewer needs to register the ".md" extension to Firefox (see this code) but it doesn't seem to be possible with either of the APIs, and I doubt it'll ever be possible in the future, given the direction taken by Mozilla to standardize extensions between browsers. The idea is good but not applicable since Gecko and Chromium platforms are fundamentally different.

Enjoy Markdown Viewer if it still works for you, or else consider it dead :(

Thiht avatar Feb 03 '17 10:02 Thiht

What if you just check the URL if it ends on .md ?

Croydon avatar Feb 03 '17 14:02 Croydon

It's not enough, it breaks on Linux because Firefox will download the file instead of displaying it.

Thiht avatar Feb 03 '17 14:02 Thiht

With some persistence... I am happy to report that I was able to solve this issue. I was able to trick Firefox by modifying a local MIME type in Linux:

https://wiki.archlinux.org/index.php/default_applications#New_MIME_types

Here is what mine looks like currently with it working:

<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="text/plain">
    <glob pattern="*.md"/>
    <glob pattern="*.mkd"/>
    <glob pattern="*.markdown"/>
  </mime-type>
</mime-info>

ghost avatar Feb 06 '17 14:02 ghost

@braderhart This might be a local workaround not a real solution how this can be rewritten as a webextension.

Croydon avatar Feb 06 '17 15:02 Croydon

@Croydon I agree we need a better solution from Mozilla with WebExtensions for sure, but to finally get a fix—even if isn't the "proper" approach—it still solves a long-standing bug quite well for the time-being, and doesn't really seem to cause any issues.

You may even be able to create a proper fix yourself using the info provided here:

https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html

ghost avatar Feb 06 '17 15:02 ghost

If the only issue is reading the download stream as indicated by the code linked to in a previous comment, you should be able to do that since webRequest.onResponseData landed.

https://bugzilla.mozilla.org/show_bug.cgi?id=1255894

mixedpuppy avatar Apr 25 '17 19:04 mixedpuppy

Sorry, it hasn't landed yet, but is close.

mixedpuppy avatar Apr 25 '17 19:04 mixedpuppy

Landed.

Croydon avatar Sep 18 '17 00:09 Croydon