haroldtreen / epub-press-clients

📦 Clients for building books with EpubPress.
https://epub.press
GNU General Public License v3.0
592 stars 75 forks source link

macOS Safari extension #11

Open marbetschar opened 7 years ago

marbetschar commented 7 years ago

I've seen the Safari extension is already planned. Is there already any ETA available? Or is there any code which can already be used or testdriven? Would love to help out here, since Safari is my primary content browser.

haroldtreen commented 7 years ago

Safari extension would be super wonderful! Just haven't had time to get around to it.

It shouldn't be tooo hard though.

Some safari apis that would need to be figured out:

These are all the .js files that run in Chrome: https://github.com/haroldtreen/epub-press-clients/tree/master/packages/epub-press-chrome/scripts

All talking to the Browser apis is done through Browser.js so theoretically, you should be able to update the following methods to work in Safari and make it cross platform pretty easy.

...Basically anywhere that chrome is used 😅 .

You'd probably want something like

if (chrome) {
 // Do current implementation
else {
  // Do safari specific stuff.
}

Would be super cool if you were able to get it started. I haven't had the time to do it myself, but if there was a PR started I would be super keen to collaborate on that.

Thanks for offering!

marbetschar commented 7 years ago

I've started building the macOS Share Extension as discussed in https://github.com/haroldtreen/epub-press-clients/issues/10.

Unfortunately I'm stuck publishing the book - hoping you may help out with a basic walk through on which endpoints should be called in which order.

Can you please confirm the following is correct?

  1. POST https://epub.press/api/v1/books - tells the server to create the book, returns the bookId
  2. GET https://epub.press/api/v1/books/{bookId}/status - poll this till it returns the book is finished
  3. GET https://epub.press/api/v1/books/{bookId}/download - download the finished book

And also provide dummy parameters which should be send to the endpoints? Unfortunately I get a 404 at 1., so kind of rudimentary specs would really help.

Last but not least, here a little sneak peek - for simplicity I'm starting with only one article (the active tab):

share menu

share extension
haroldtreen commented 7 years ago

Wicked! Happy to give more explanation... probably best to commit it though rather than post here :).

But the TLDR is that you seem to have it right!

  1. I just checked the server and it was full. That might have been giving errors? Cleaned up now.
  2. GET https://epub.press/api/v1/books/{bookId}/status this returns some json which will include the progress. Once progress is 100, it is ready to download.
  3. GET https://epub.press/api/v1/books/{bookId}/download will likely return 404 if the publish isn't complete.

json for publish can just have:

{ 
   "title": "Some title",
   "urls": ["http://google.com"]
}

or sections:

{ 
   "title": "Some title",
   "sections": [
         { "html": "<html></html>", "title": "Empty" }
     ]
}

I'll write that up ASAP (just landed after 24 hours of flying and going to take a while to get up to speed).

Excited to see where this is headed :).

marbetschar commented 7 years ago

Thank you very much!! The Safari Share Extension for macOS works seamlessly! :) Have to tweak the app a bit more in terms of minor design issues and will then release the first version to the public.

Here's a shot of the current share extension:

bildschirmfoto 2017-04-08 um 03 45 09
haroldtreen commented 7 years ago

Wicked! I started writing the API spec out today, but seems you beat me to it :D.

Great to hear!

WinterLoki commented 7 years ago

I was wondering if the Safari version was still being worked on? Just found this extension but saw that it hasn't been updated in a few months.

haroldtreen commented 7 years ago

Hey @WinterLoki !

Not sure on the status of the safari work. I think @marbetschar found a solution to his problem and left it at that.

Most of the feature requests have been on the backend, so this has been super low priority for me. But as before, I'm happy to support anyone looking to implement something for safari.

marbetschar commented 7 years ago

@WinterLoki I'm working on an iBook helper App which allows you to create an ePub file from the Safari extension (as for now only from the current page as you can see in the above screenshot) - as well as export non-protected DRM books including all iBook annotations as a PDF file.

Unfortunately I'm struggling with the App Store review now, since I'm not able to find any ePub2PDF framework which seems to be compatible with the guidelines.

Does it help you, if I publish the App without any PDF export functionality for now? Just with the Safari extension?

NightMachinery commented 5 years ago

@marbetschar Definitely publish what has been done! :D

marbetschar commented 5 years ago

@NightMachinary you'll find the current work here: https://gitlab.com/marbetschar/iBookmarks

Please note I was able to submit the app to the App Store, since at time of creating there was no ePub2PDF library which I was able to embed in the app. If you want to export PDF from iBooks, you need to install Calibre in /Applications.

I don't use the app anymore, therefore I have no clue if the features still work as expected - feel free to clone & modify as you see fit.