You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently downloaded files are always titled "game.pgn". We'd like the ability to use the Event data from within the PGN title to change the download's filename.
I have this partially implemented locally. My approach within rpbchess-ui-chessgame.js is:
Within the Navigation Board switch block of the refresh() method, pass widget as a parameter each time buildNavigationSkeleton() is called
Within buildNavigationSkeleton(widget), get the event title with formatDefault(widget._game.header('Event')), and store that as a string
In the anchor at the bottom of return block of buildNavigationSkeleton(), change download="game.pgn" to use the stored event string, like download="' + filename + '"
I haven't tested or polished this yet. I wanted to check in with you before I go further. If this seems like a good direction to go, I can submit a PR if you'd like.
The text was updated successfully, but these errors were encountered:
Customizing the buildNavigationSkeleton(...) method is the right approach. The string that goes out of widget._game.header('Event') has to be properly sanitized to get rid of the special characters that may be incompatible with a file name.
However, have you noticed that, by uploading a PGN file to your website and using the syntax [pgn url="<url-of-the-uploaded-file>"][/pgn] (instead of having the PGN text inlined between the [pgn][/pgn] tags), then the download filename matches the upload filename, hence can be customized?
The new PGN download button works great!
Currently downloaded files are always titled "game.pgn". We'd like the ability to use the Event data from within the PGN title to change the download's filename.
I have this partially implemented locally. My approach within
rpbchess-ui-chessgame.js
is:switch
block of therefresh()
method, passwidget
as a parameter each timebuildNavigationSkeleton()
is calledbuildNavigationSkeleton(widget)
, get the event title withformatDefault(widget._game.header('Event'))
, and store that as a stringreturn
block ofbuildNavigationSkeleton()
, changedownload="game.pgn"
to use the stored event string, likedownload="' + filename + '"
I haven't tested or polished this yet. I wanted to check in with you before I go further. If this seems like a good direction to go, I can submit a PR if you'd like.
The text was updated successfully, but these errors were encountered: