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:

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

  1. Add the PhotoSwipe project files via the ZIP-file, following the project page and README instructions
  2. 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:

  1. ✅ Add Git-instructions in the README
  2. ✅ Add ZIP-instructions in the README, make it clear that only four files are needed
  3. 🔲 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
  4. ✅ We could link to the Documentation from the project page, and maybe also link to the official web site for examples?:
  5. 🔲 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

Command icon 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

ressa created an issue. See original summary.

ressa’s picture

Title: Clarify manual library installation of libraries from ZIP-file » Clarify manual installation of PhotoSwipe files from ZIP-file
Issue summary: View changes
ressa’s picture

Issue summary: View changes
ressa’s picture

Assigned: ressa » Unassigned
Issue summary: View changes
Status: Active » Needs review

Adding suggestion for a simplified project page text, simply linking to instructions in the README, so we only have to update one place.

ressa’s picture

Issue summary: View changes
fkelly12054@gmail.com’s picture

How 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.

ressa’s picture

Thanks 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 :)

anybody’s picture

@fkelly12054@gmail.com yes please open a separate issue for that. Maintainers need to discuss that. I'm open to that idea.
Thanks!

anybody’s picture

Status: Needs review » Needs work

@ressa can you prepare a MR please? I'm missing the button to do that on the changes - any ideas why?

ressa’s picture

Status: Needs work » Needs review

Ah 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 ...

ressa’s picture

Issue summary: View changes

Adding suggestion to add Documentation link, and maybe also link to the PhotoSwipe page for a page with more examples?

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Nice work in my eyes, let's do it!

anybody’s picture

@ressa: Would you finish #3557981: Document installing library files with Git as follow-up?

ressa’s picture

Title: Clarify manual installation of PhotoSwipe files from ZIP-file » Clarify manual installation of PhotoSwipe files from Git and ZIP-file
Status: Reviewed & tested by the community » Needs review

Great, 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.

ressa’s picture

Issue summary: View changes

Updating Issue Summary, remaining tasks are updating the project page, and adding Documentation link.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @ressa! Merging!

Do you think we should just "copy" the README.md or prepare a dedicated text?

ressa’s picture

Issue summary: View changes

Thanks @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.

anybody’s picture

Assigned: Unassigned » grevil
Status: Reviewed & tested by the community » Active

Thanks @ressa we'll check these final points in the next days to get this finished! Great work!

ressa’s picture

Thanks @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.js

Using 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

user:~$ unzip DOMPurify-main.zip
user:~$ tree -a DOMPurify-main
[...]
27 directories, 112 files

Git clone

user:~$ git clone https://github.com/cure53/DOMPurify
user:~$ tree -a DOMPurify
.
├── .babelrc
├── CODE_OF_CONDUCT.md
├── CODEOWNERS
├── config
│   ├── playwright.config.js
[...]
│   │   └── tsconfig.json
│   ├── package.json
│   └── verify.js
└── website
    └── index.html

44 directories, 140 files

Similarly for the external Photoswipe library, many unneeded extra files are publicly accessible, using the recommended Composer method:

$ composer require bower-asset/photoswipe:^5
./composer.json has been updated
Running composer update bower-asset/photoswipe
[...]

$ tree -a web/libraries/photoswipe/
web/libraries/photoswipe/
├── .babelrc
├── build
│   ├── config-builder.js
│   ├── rollup.config.js
│   └── rollup.config.watch.js
[...]
│   │       ├── spring-easer.js
│   │       ├── util.js
│   │       └── viewport-size.js
│   └── photoswipe.css
└── tsconfig.json

45 directories, 175 files

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:

$ composer require npm-asset/dompurify
./composer.json has been updated
Running composer update npm-asset/dompurify
[...]
Using version ^3.4 for npm-asset/dompurify

$ tree -L1 web/libraries/dompurify/
web/libraries/dompurify/
├── dist
├── LICENSE
├── LICENSE-MPL
├── package.json
├── README.md
└── src

$ ls web/libraries/dompurify/dist/purify.min.js
web/libraries/dompurify/dist/purify.min.js
grevil’s picture

Assigned: grevil » Unassigned
Status: Active » Fixed

Alright. All done, except the follow-up issue.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

ressa’s picture

Issue summary: View changes
Status: Fixed » Needs work

Thank 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?

  • anybody committed 9b0e9454 on 3605632-drushcommands-revised authored by ressa
    Resolve #3610060 "Clarify manual library"
    
grevil’s picture

Status: Needs work » Postponed (maintainer needs more info)

I feel like it is fine as is. @anybody? What do you think?

On the module page it says:

Manual
See "Manual Installation" in the README file.

With a link to the README. I feel like that is fine.

ressa’s picture

Thanks 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 :)