Problem/Motivation
It seems like only these three four files are needed from the PhotoSwipe project:
/libraries/photoswipe/package.json/libraries/photoswipe/dist/photoswipe.css/libraries/photoswipe/dist/umd/photoswipe.umd.min.js/libraries/photoswipe/dist/umd/photoswipe-lightbox.umd.min.js
From https://git.drupalcode.org/project/photoswipe/-/blob/5.x/photoswipe.libr...
For security reasons, we could could make this clearer in the instructions, to not unnecessarily commit and upload files to a production server:
- #1895328: Security exploit in plupload external library examples folder
- #2791573: Check for sample/example/demo directory of libraries
Downloading the Photoswipe library with Git is fairly easy, and could be added.
The verification check is for package.json file ... wouldn't it be more precise to check for the three CSS and JavaScript files?
Steps to reproduce
- Add the PhotoSwipe project files via the ZIP-file, following the project page and README instructions
- See that there a lot of extra files which are not used
Find that adding the PhotoSwipe files using Git is easy.
Proposed resolution
Solve, or decide an approach for these five items:
- ✅ Add Git-instructions in the README
- ✅ Add ZIP-instructions in the README, make it clear that only four files are needed
- 🔲 Update the project page: Remove instructions and link to the README:
Photoswipe 5 library installation
photoswipe:^5 only!
Composer (recommended)
See "Composer Installation (recommended)" in the README file.
Manual
See "Git" or "Zip" in the README file.
CDN
- Go to '/admin/config/media/photoswipe' and enable the 'Load PhotoSwipe library from CDN' option
- Check the status report for errors
- ✅ We could link to the Documentation from the project page, and maybe also link to the official web site for examples?:
- 🔲 As a follow up issue, consider changing the verification method, and check if the three CSS and JavaScript files are present, instead of packages.json?
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork photoswipe-3610060
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ressaThe packages.json file is also required, since it is used as a verifier:
Comment #3
ressaComment #4
ressaAdding suggestion for a simplified project page text, simply linking to instructions in the README, so we only have to update one place.
Comment #5
ressaComment #6
fkelly12054@gmail.com commentedHow about just make dynamic caption be part of the standard Photoswipe installation with no need to mess around with complicated Composer setup? Install Photoswipe and dynamic caption just gets installed and works.
Comment #7
ressaThanks for weighing in @fkelly12054@gmail.com, but that's for another issue. This issue is only about getting the PhotoSwipe files placed correctly -- but feel free to create one :)
Comment #8
anybody@fkelly12054@gmail.com yes please open a separate issue for that. Maintainers need to discuss that. I'm open to that idea.
Thanks!
Comment #9
anybody@ressa can you prepare a MR please? I'm missing the button to do that on the changes - any ideas why?
Comment #11
ressaAh yes, I forgot the MR ... sorry @anybody. Maybe some things have changed, as part of the migration to Gitlab? Because I created an MR (https://git.drupalcode.org/project/photoswipe/-/merge_requests/155) and it took a while before the "MR !155 mergeable" link appeared, it usually shows up right away ...
Comment #12
ressaAdding suggestion to add Documentation link, and maybe also link to the PhotoSwipe page for a page with more examples?
Comment #13
anybodyNice work in my eyes, let's do it!
Comment #14
anybody@ressa: Would you finish #3557981: Document installing library files with Git as follow-up?
Comment #15
ressaGreat, thanks for reviewing @anybody!
I thought it was easier to move the Git part over here, rather than having to juggle two README MR's, so closing the other issue.
Comment #16
ressaUpdating Issue Summary, remaining tasks are updating the project page, and adding Documentation link.
Comment #17
anybodyThank you @ressa! Merging!
Do you think we should just "copy" the README.md or prepare a dedicated text?
Comment #19
ressaThanks @anybody!
About the project page, a while ago I added a suggestion about that in the Issue Summary, could that work?
(I just now added check marks and empty boxes, to make it clearer what is done, and not.)
So, there are also suggestions for additional links under "Resources" :)
And then there is a last item, about a possible follow-up issue, switching from a check on packages.json, to the three CSS files.
Comment #20
anybodyThanks @ressa we'll check these final points in the next days to get this finished! Great work!
Comment #21
ressaThanks @anybody, sounds good!
I am adding a few related issues about why it's better to only add the required files, since a vulnerability may slip in undetected, if you use Composer or Git to add a third-party library, as opposed to manually unzipping a ZIP-file, and cherry-picking only the needed file(s).
For example, all 175 Photoswipe library files are downloaded if you use the Composer methods, and are publicly accessible, like this one:
https://example.org/libraries/photoswipe/demo-docs-website/src/components/PswpCodePreview/gallery-templates/srcset-test.jsUsing ZIP can be just as unsafe, if you do not clean up afterwards, and remove all unnecessary files.
Another example is the recent issue about HTML support in Captions (#3574103: Allow limited HTML in captions through domPurify, move caption README in main module and fix tests), where only a single JavaScript file is needed from DOMPurify, but the ZIP-file includes 112 files, and the Git repo includes 144 files (many of them are hidden):
Zip file
Git clone
Similarly for the external Photoswipe library, many unneeded extra files are publicly accessible, using the recommended Composer method:
By the way, I see that there is an asset package for DOMPurify https://asset-packagist.org/package/npm-asset/dompurify
... and it seems to work:
Comment #22
grevil commentedAlright. All done, except the follow-up issue.
Comment #24
ressaThank you @grevil, the new links to Documentation and demonstration are nice little improvements.
I updated the wording in the README MR in the process, but forgot to update the suggested README in the Issue Summary ... So there is no longer a "Manual installation", sorry about that.
I have updated the proposal with "Git", "Zip", and anchor links ... so perhaps this could work better?
And what do you both think about the follow up issue suggestion (#5) about changing the verification method, and check if the three CSS and JavaScript files are present, instead of packages.json? I can create it, if you want?
Comment #26
grevil commentedI feel like it is fine as is. @anybody? What do you think?
On the module page it says:
With a link to the README. I feel like that is fine.
Comment #27
ressaThanks for looking at this @grevil.
But the only mention of "manual" is under "Photoswipe Dynamic Caption Submodule" ... isn't this confusing for the user, if they scan for "Manual Installation"?
Also, please note that I asked two questions :)