New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
previewer: pdfjs plugin addition #2402
previewer: pdfjs plugin addition #2402
Conversation
@lnielsen-cern Please check also this: zenodo/zenodo#15 |
|
||
|
||
def can_preview(f): | ||
'''Returns True for PDFs, False for others''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use double quotes `"""instead of single quotes
'''```.
@bouzlibop if we are keeping previous implementation we need to create separate bundles. Please check also WDYT about commit message: |
@jirikuncar, the new commit message title sounds good. I checked the |
@bouzlibop I have made some little fixes for |
@@ -1,5 +1,5 @@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1: D208 Docstring is over-indented
118:1: F999 redefinition of unused 'compile_text' from line 111
output="previewer/pdfjs.js", | ||
weight=20, | ||
bower={ | ||
"pdfjs-build": "git://github.com/bouzlibop/pdfjs-build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lnielsen-cern Here I put the url to my repository with customized pdfjs-build.
I tested it and it's working. Probably it should be one of zenodo repositories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the upstream package and just install custom js/css files from Invenio (Zenodo) repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The official bower package for pdfjs
is pdfjs-dist
, but this one can be probably only used to build own version of the viewer and it doesn't contain the official version of the viewer (the one I am using here).
The two example ways of how to obtain this official viewer are:
- Use the official repo https://github.com/mozilla/pdf.js as endpoint for
bower install
and then build the viewer locally (node make generic
) - Use the 3rd party repo (eg. git://github.com/RiptideCloud/pdfjs-build.git), which comes with the prebuild version of the viewer
And then, there still remains the problem with some paths hardcoded in the scripts (like PDFJS.imageResourcesPath
for example), which we need to customize in order to make the viewer work in invenio.
The simplest solution which comes to my mind (as I mentioned in the first comment) is to fork the 3rd party repo and make the changes we need.
But I'm not sure if this is the best way to solve this.
During integration on Zenodo I've made some changes that should likely be added to the pull request, so I'm just changing it to WIP |
@lnielsen-cern could you please specify what are those changes that needs to be add here ? |
Yes, it is in these commits: However, also we should like copy the viewer html and css into Invenio and use the standard bower build of pdfjs. |
@lnielsen-cern I got through the commits you pointed out and applied the changes to this PR. Now I will try to look into switching to bower build. |
@lnielsen-cern what do you mean by "use the standard bower build of pdfjs" ? Should we use the official repo https://github.com/mozilla/pdf.js as endpoint for bower install and then build the viewer locally ( |
Official is probably not the right word. "Existing" bower package is better. As far as I remember you said that the official build could not be used out of the box. |
I think that this one - mozilla/pdfjs-dist - can be used only for building some custom viewer. In our case we can use this one: RiptideCloud/pdfjs-build or (as I mentioned in the previous comment) - we can use official mozilla/pdfjs repo as endpoint for bower and then locally perform In either case, what about this changes https://github.com/bouzlibop/pdfjs-build/compare/RiptideCloud:master...master#diff-564dfd8dd910689dffde37ab83a2a010L58 in |
I would like to avoid running extra commands besides
The |
@lnielsen-cern I've just added the full screen mode and I've changed the structure a little bit - now I'm using the RiptideCloud/pdfjs-build package. I still have to test a few things here, but meanwhile if you find a time please have a birds-eye view over the changes 😄 |
I guess this https://github.com/bouzlibop/invenio/blob/zenodo-194-pdfpreviewer/invenio/modules/previewer/static/js/previewer/pdfjs_previewer/pdfjs.js#L5625-L5668 can be moved out because the button is defined here https://github.com/inveniosoftware/invenio/pull/2402/files#diff-d555729c3cdb5523bfba4e8c872f6c7bR79 |
I would rename |
@bouzlibop Can you take https://github.com/lnielsen-cern/invenio/tree/pu-previewer-pdfjs and repush this PR. I've rebased the code, cleaned up some few things and checked that all code from Zenodo was integrated. Once it's done, you can remove the WIP from the title, so that can get it integrated. |
@lnielsen-cern, many thanks for the clean up. Today I tested this PR (after taking the lnielsen-cern/invenio/tree/pu-previewer-pdfjs) and in order to make things work I did some changes in this commit 49d6b69. Specifically files:
Could you have a look at this final version? PS: I tested this PR in both |
LGTM. Just missing the test to pass (seems to be a sphinx doc build issue). |
@jirikuncar, I think it's ready to be merged. |
@bouzlibop Can you just try to run ``python setup.py build_sphinx -b html" locally to see why the documentation build fails. |
|
you need to run |
Thanks @jirikuncar, now there are no errors during |
* Adds cleancss assets filter with support for rebasing relative URLs against COLLECT_STATIC_ROOT. Signed-off-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch>
* Adds pdfjs viewer component from Mozilla pdf.js as a single commit. This commit is needed since the viewer part of pdf.js cannot be installed via bower. * NOTE: All source code in commit is copyrighted by Mozilla Foundation and licensed under Apache License Version 2.0. Reviewed-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch> Signed-off-by: Adrian Pawel Baran <adrian.pawel.baran@cern.ch>
* Integrates pdf.js support in Invenio including customization of default pdf.js viewer. * Fixes problem with pdftk bundle naming collision. * Fixes problem with jQuery loading in records module. Reviewed-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch> Signed-off-by: Adrian Pawel Baran <adrian.pawel.baran@cern.ch>
* Fixes issue with ZIP files with no content. * Fixes minor styling issues. * Changes icons from Bootstrap to Font Awesome. Signed-off-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch>
* Adds new alias for `webassets.filter.ExternalTool`. Signed-off-by: Adrian Pawel Baran <adrian.pawel.baran@cern.ch>
Signed-off-by: Adrian Pawel Baran adrian.pawel.baran@cern.ch