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

[Dataset page] Add filename/extension to download attribute #117

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tkohr
Copy link
Member

@tkohr tkohr commented Dec 18, 2024

PR adds filename/extension to download attribute for json and geojson files. Other file formats should have a name and don't need download attribute. Note that download attribute only takes effect on same-origin.

for json and geojson files. other file formats should have a name and don't need download attribute. note that download attribute only takes effect on same-origin
@tkohr tkohr force-pushed the download-attribute-filename branch from 8e996b5 to 73cd07d Compare December 18, 2024 09:13
Copy link
Contributor

@f-necas f-necas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the title retrieved from the data-api ? It could be used to set name of the file instead of data.

What append to let fileName = '' when it clicks on a csv format ?

@tkohr tkohr force-pushed the download-attribute-filename branch from 5311a0b to de1abc7 Compare December 19, 2024 08:51
@tkohr tkohr force-pushed the download-attribute-filename branch from de1abc7 to 9bf3549 Compare December 19, 2024 08:51
@tkohr
Copy link
Member Author

tkohr commented Dec 19, 2024

Is the title retrieved from the data-api ? It could be used to set name of the file instead of data.

Good point ! Completely forgot about that, added it now.

What append to let fileName = '' when it clicks on a csv format ?

Do you mean "why"? The download attribute does not seem to affect formats that cannot be opened by the browser. Filenames including extension behave already as expected in this case if I saw right, so I just keep it empty in this case.

Copy link
Contributor

@f-necas f-necas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, for me, if the format is, by example csv, it won't go through :

if (this.format === 'geojson') {
      completeFileName = `${fileName}.geojson`
    } else if (this.format === 'json') {
      completeFileName = `${fileName}.json`
    }

Then completeFileName will be empty.

@f-necas f-necas self-requested a review January 3, 2025 13:39
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

Successfully merging this pull request may close these issues.

2 participants