-
Notifications
You must be signed in to change notification settings - Fork 100
feat: export as images #6987
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
base: main
Are you sure you want to change the base?
feat: export as images #6987
Conversation
Co-authored-by: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com>
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.
Pull request overview
This PR introduces an export-as-image feature that allows users to download or copy brackets, group tables, cross tables, and match lists as images to the clipboard.
Changes:
- Added dropdown UI components for selecting export options (copy to clipboard or download)
- Implemented image export functionality using html2canvas to capture content and compose branded images with headers and footers
- Added Font Awesome icons for share, copy, and download actions
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| stylesheets/commons/Dropdown.scss | Styling for dropdown widget components with light/dark theme support |
| stylesheets/Main.scss | Imported Dropdown styles and removed basic body styling |
| lua/wikis/commons/Widget/Basic/Dropdown/Item.lua | Lua widget for individual dropdown menu items with optional icons and links |
| lua/wikis/commons/Widget/Basic/Dropdown/Container.lua | Lua widget for dropdown container with toggle button |
| lua/wikis/commons/Icon/Data.lua | Added icon definitions for share, copy, and download |
| lua/spec/dropdown_spec.lua | Test suite for dropdown widget functionality |
| javascript/commons/ExportImage.js | Core export functionality including canvas composition, image caching, and clipboard operations |
| javascript/commons/Dropdown.js | JavaScript for dropdown menu toggle behavior |
| javascript/Main.js | Registered new Dropdown and ExportImage modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
javascript/commons/ExportImage.js
Outdated
| ); | ||
| context.fill(); | ||
|
|
||
| const mainTitle = mw.config.get( 'wgTitle' ); |
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.
Maybe retrieve the DISPLAYTITLE here instead of the MW Pagename?
Not sure if that is exposed in the config, or whether you'd need to get that from the h1.firstHeading.
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.
It's not in the config rn, but it could be added if we want this.
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.
tend to agree with Salt
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.
agree that displaytitle seems more fitting
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.
There's an argument to be made that only the pagename is a reliable way to get back to the page, with displayname you are always relying on the search.
But I think we'd probably value a nice display more than that.
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.
mw.config.get('wgDisplayTitle'); this now returns the display title, either the one set by a user, or if none is set the default one built from the url
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.
(mind pages need to be purged for it to be available)
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.
using wgDisplayTitle with fallback to wgTitle now
javascript/commons/ExportImage.js
Outdated
| ); | ||
| context.fill(); | ||
|
|
||
| const mainTitle = mw.config.get( 'wgTitle' ); |
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.
It's not in the config rn, but it could be added if we want this.
| generateFilename( title ) { | ||
| const pageTitle = mw.config.get( 'wgTitle' ); | ||
| return `Liquipedia ${ pageTitle } ${ title }`; | ||
| } |
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.
Maybe add something more to the file name like the current date and time in case someone wants to export more than one thing from the same page, say multiple groups etc
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.
Good point, added
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.
also do we have any thoughts on illegal characters in filenames? mediawiki titles can have / chars, which on most systems are not allowed in file names. Might need some research
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.
could just gsub those to underscores
/ (forward slash)
< (less than)
> (greater than)
: (colon - sometimes works, but is actually NTFS Alternate Data Streams)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
come to mind from the top of my head
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.
oh and windoofs has length restrictions too
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.
If we used the display name for the file name too, would that work? Do those have illegal characters
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.
yeah displayname allows those chars too
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.
either way displaytitles are optional, so we need to be able to support page names, but hjpa correctly pointed out that displaytitles have few rules
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.
Added illegal character sanitation and fallback to wgTitle if wgDisplayTitle is not available
* Add Metafy link * add metafy suffix and fix to alphab order in suffixes * Update Icons.scss --------- Co-authored-by: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Co-authored-by: Eetu Rantanen <75437856+Eetwalt@users.noreply.github.com>
* create shopmerch module * add to all * add default for url * always show icon * add default icon * change defaults * chore: update visual snapshots * constant char pattern * fix * use I18n, lose option to customize text and icon * use mw existings methods when possible * remove redundant props Co-authored-by: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> * simplify by only allowing slug input and show errors on bad inputs * fix asserts and consider escaped chars by constructing the final url before check * plain Co-authored-by: SyntacticSalt <mail@mbergen.de> --------- Co-authored-by: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Co-authored-by: SyntacticSalt <mail@mbergen.de>
Summary
This introduces a new feature of exporting these elements as images by either downloading or copying to clipboard:
How did you test this change?
Locally compiled css & js. Can use dev tools too.
Dropdown examples
Export examples: