Skip to content
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

Downloaded PGN files dynamically titled based on PGN data #96

Open
MatthewEppelsheimer opened this issue Sep 20, 2017 · 2 comments
Open

Comments

@MatthewEppelsheimer
Copy link

MatthewEppelsheimer commented Sep 20, 2017

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:

  1. Within the Navigation Board switch block of the refresh() method, pass widget as a parameter each time buildNavigationSkeleton() is called
  2. Within buildNavigationSkeleton(widget), get the event title with formatDefault(widget._game.header('Event')), and store that as a string
  3. 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.

@yo35
Copy link
Owner

yo35 commented Sep 24, 2017

Hi Matthew,

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?

@MatthewEppelsheimer
Copy link
Author

Thanks, Yoann. It's good to know that workaround exists, although the workflow is a bit cumbersome.

I'll consult with my client on whether I should commit time to create a PR. I'll reply again here when I know how we'll proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants