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

Set max length of each argument separately in filename template #814

Closed
scruel opened this issue Nov 14, 2021 · 10 comments
Closed

Set max length of each argument separately in filename template #814

scruel opened this issue Nov 14, 2021 · 10 comments

Comments

@scruel
Copy link
Contributor

@scruel scruel commented Nov 14, 2021

Is your feature request related to a problem? Please describe.
For now, if the filename is exceeded the maximum length of filename on Windows, the file will sometimes lose ".html" extension in filename when saving it, the global filename length property is not enough, because it may lose the important information which I want to keep in filename.
For example, if I set {page-title} - {digest-sha-256}.html, if the length of page title exceeded the limitation, the digest info will be truncated, the ".html" part will also not be included in the filename.

Describe the solution you'd like
An option which can specify the maximum length of each argument if it should be limited(e.g. page-title).

If the maximum length of page-title is 100, the syntax may:
{page-title-\<max-length\>}

@gildas-lormeau
Copy link
Owner

@gildas-lormeau gildas-lormeau commented Nov 14, 2021

For example, if I set {page-title} - {digest-sha-256}.html, if the length of page title exceeded the limitation, the digest info will be truncated, the ".html" part will also not be included in the filename.

Are you sure? I just did the test and the extension , i.e. .html, is not removed from the filename.

Edit: I did the test in the extension. I'll do another test with the CLI. The CLI should behave the same, otherwise I need to fix this.

@scruel
Copy link
Contributor Author

@scruel scruel commented Nov 15, 2021

For example, if I set {page-title} - {digest-sha-256}.html, if the length of page title exceeded the limitation, the digest info will be truncated, the ".html" part will also not be included in the filename.

Are you sure? I just did the test and the extension , i.e. .html, is not removed from the filename.

Edit: I did the test in the extension. I'll do another test with the CLI. The CLI should behave the same, otherwise I need to fix this.

Yep, I am sure, but it hadn't happened when working with cli, but browser plugin(1.19.21), sometimes the ".html" part will lose.
When it comes again, I will let you know how to reproduce.

@gildas-lormeau
Copy link
Owner

@gildas-lormeau gildas-lormeau commented Nov 15, 2021

For the record, I confirm I cannot reproduce the issue when using the CLI. The command below produces a filename with .html preserved.

single-file https://www.example.com  --filename-max-length=32 --filename-template="{page-title} - {digest-sha-256}.html"

@scruel
Copy link
Contributor Author

@scruel scruel commented Nov 15, 2021

For the record, I confirm I cannot reproduce the issue when using the CLI. The command below produces a filename with .html preserved.

single-file https://www.example.com  --filename-max-length=32 --filename-template="{page-title} - {digest-sha-256}.html"

Ok, and I think you may design the UI like this:
image
It would not need to change the code logic of parsing the template variables but provide a way to set the properties of variables.

@gildas-lormeau
Copy link
Owner

@gildas-lormeau gildas-lormeau commented Nov 15, 2021

Well, it would be a substantial amount of work :p. I think I would maybe prefer to implement a new syntax in the template language, e.g. {page-title|max-length(200)}. It would also allow to introduce other functions like {page-title|lower-case()} and combine them, e.g. {page-title|max-length(200)|lower-case()}.

@gildas-lormeau
Copy link
Owner

@gildas-lormeau gildas-lormeau commented Nov 15, 2021

Hmmm, this feature already exists actually. It's even already documented in the help page! I totally forgot about it... Use [ and ], e.g. {page-title}[200]

@scruel
Copy link
Contributor Author

@scruel scruel commented Nov 16, 2021

Hmmm, this feature already exists actually. It's even already documented in the help page! I totally forgot about it... Use [ and ], e.g. {page-title}[200]

I haven't noticed about the section ‘Template variables’ in the help page, it should be work as excepted, thanks!

@scruel
Copy link
Contributor Author

@scruel scruel commented Jan 10, 2022

@gildas-lormeau I think this issue need to reopen, because its behavior is not work as we excepted.
I set the filename template as {page-title}[120] - {url-href-digest-sha-1}.html
For saving the web page: http://www.jasongj.com/java/multi_thread/
The filename just lost the {url-href-digest-sha-1} part when saving it.

The filename for saving is:
Java多线程 sleep wait synchronized 锁 await signal 信号量 Semaphore _ 技术世界 _ java,Java,sleep wait,synchro - .html

@gildas-lormeau
Copy link
Owner

@gildas-lormeau gildas-lormeau commented Jan 10, 2022

@scruel The issue you're seeing is not related to this bug. The problem is that the SHA-1 cannot be computed on http pages, it only works with https pages unfortunately.

@scruel
Copy link
Contributor Author

@scruel scruel commented Jan 11, 2022

@scruel The issue you're seeing is not related to this bug. The problem is that the SHA-1 cannot be computed on http pages, it only works with https pages unfortunately.

Got it, so could it be fixed? Should I post a new issue for this?

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

Successfully merging a pull request may close this issue.

None yet
2 participants