Page MenuHomePhabricator

Provide custom filename for downloading QR code image
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):

Currently, the QR code is downloaded with the filename qrcode.svg. It would be good to make it possible to customize this.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

When downloading multiple QR codes from different wiki pages it becomes necessary to manually rename each as you download them. Although the Special:QrCode supports codes for all URLs a common use case is for simple wiki page URLs, and in that case the page name could be used for the QR code.

Benefits (why should this be implemented?):

Avoids users having to set manual filenames, or ending up with files named qrcode (1).svg, qrcode (2).svg, etc.

Event Timeline

I think the default filename should be {{PAGENAMEE}}.svg
Alternative:

  • {{FULLPAGENAMEE}}.svg
  • {{FULLPAGENAMEE}}-{{SITENAME}}.svg
  • {{FULLPAGENAMEE}}-{{SITENAME}}-{{CONTENTLANGUAGE}}.svg
  • {{FULLPAGENAMEE}}-{{REVISIONID}}.svg
  • {{FULLPAGENAMEE}}-{{REVISIONTIMESTAMP}}.svg

or other combinations

Change 1011351 had a related patch set uploaded (by Gopavasanth; author: Gopavasanth):

[mediawiki/extensions/UrlShortener@master] Added appropriate filename on download of QR code

https://gerrit.wikimedia.org/r/1011351

I think the default filename should be {{PAGENAMEE}}.svg

That sounds like a good idea. When the QR Code is retrieved via the tools menu link on a page, then it'd be easy to use the page name and pass it to Special:QrCode. It could be a new filename parameter (alongside the existing url parameter) that'd take a filename and normalize it (including enforcing but not duplicating the .svg extension).

When generating a QR Code from the Special:QrCode form, however, it accepts any URL (conforming to $wgUrlShortenerAllowedDomains etc.) so there may or may not be an associated page title. That makes it harder to figure out a title for the download, but perhaps it could still inspect the URL for title=, and then fall back to qrcode.svg?

@Gopavasanth Looks like @Samwilson has left you some comments on the patchset. Have you had a chance to review the suggested changes?