ijgnd / anki__pdf_viewer_with_pdfjs

3 stars 2 forks source link

comment1 #1

Closed lovac42 closed 5 years ago

lovac42 commented 5 years ago

I haven't looked at your code, but the next version of Qt will have native support for PDF... So kind of makes your addon obsolete already. You can still work on it, and it'll be some time before it comes packaged with Anki.

Another thing is that this line is not needed anymore after Anki 2.1.10?

# from lovac42's Anki Fanfare/main.py from https://github.com/lovac42/Fanfare
# Replace /user/collection.media folder with actual addon path
def _redirectWebExports(self, path, _old):

So using this method is cleaner: https://github.com/lovac42/JSLoader/blob/master/src/jsloader/jsloader.py#L57-L61

ijgnd commented 5 years ago

Thanks for helping me with this post.

Actually you kind of inspired me to this add-on with your screencast about your IR approach in mid June where you imported a pdf.

 

About the webexport: I want to load the pdfs from a subfolder in the user documents folder. I used your Anki Fanfare code because I thought that the new webexport method only works for subfolders of my add-on folder because of this line and this comment in the commit. But it's very possible that I missed something. If so a I would very much appreciate a short hint.

 

about the upcoming built-in pdf component: I didn't know that. Thanks for letting me know. That's good news because pdfium should load faster than pdfjs. Hopefully this doesn't get removed during Anki packaging ... Once this is released I'll just need to change a few lines and mostly discard code I took from my codemirror add-on for which I copied it from my tinymce add-on ...

 

Actually there are two areas in this add-on that I worry about. Maybe I could bother you with this?

  1. I import some custom models and am not fully confident about my approach.
  2. the security/privacy implications of exposing the whole pdf documents folder to the webview.

 

about 1.) To make the setup easier I offer to import a modified version of the default models with code like this

models = json.loads(mij)
for e in mta:
    mw.col.models.add(models[e])

The json file is just a dump from the database of a new profile where I renamed the keys. I try to verify that there isn't a note with the same note id or name. But I wonder if I missed something or if importing such a database dump is a bad idea in general.

 

about 2.) My understanding is that all files in the media folder (and folders set with setWebExports and the anki fanfare approach) are readable for every card that is loaded into a webview (i.e. that you review or preview)? I kind of dislike this but as far as I see there's no way of telling the mediaserver which card will be in the webview so that I can't conditionally export. Still it should be more secure than in 2.0 and I don't randomly import shared decks and even if I did I have much bigger security and privacy problems on my computer ... Do you have an idea about this?

And once more: thanks for your time.

ijgnd commented 5 years ago

about my two additional questions at the end: Ignore them.

Background: I actually asked another anki add-on author some days ago. I figured that he didn't have the time/interest for answering such uninvited questions which is no problem. But now he just send a message that he's working on an answer and that it just takes longer. I don't want to waste the time of two developers. I hope I didn't create additional work for you.

lovac42 commented 5 years ago

The new method is limited to the addon folder. I did not realize you were trying to access the user folder. At the time of writing Fanfare, some sections of the code requires local paths, but the reviewer for images required http paths. So modifying webexport was necessary. You can use the Fanfare approach or create a copy as a temp file within the addon folder. Though more secure, the later approach is messy.

On #2: Security is an illusion. I just use Anki as a personal app and look though all the templates before using shared decks. A good firewall will protect you from most of the issues.

ijgnd commented 5 years ago

Thanks for your confirmation and once more for all your time.