-
Notifications
You must be signed in to change notification settings - Fork 129
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
Add configuration option for archive_source
#337
Conversation
This allows for specifying a custom archive URL as an alternative approach to Custom Pages.
Thank you for submitting this PR! I can see from your example code that the motivation for this change seems to be to host your own internal pages - cool idea, I agree that it could be useful. We need to think about #335 here though. A new version of the client spec is apparently about to be released (see tldr-pages/tldr#10148) which will specify where clients (including tealdeer) will look for language specific archives. So I think we should wait until that is all cleared up and then take note in our documentation accordingly. I will hence mark this as draft for now :) |
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.
Hey @mipedja,
we have been letting this PR sit for a while now, but I think now is a good time to merge this!
I made some small suggestions, if you want we can discuss them. If you (understandably so) don't want to pick up this PR right now, I will add the final updates myself in a couple of days or so :)
As far as the new client spec discussion goes: The main reason for waiting (language specific archives) has been included in the specification. Since we want to support this, we should change our config option here to not point to some.site/tldr/pages.zip
but instead just to some.site/tldr/
, and then require that the zip files are present as pages.zip
/ pages.en.zip
and so on. You don't have to add much documentation for this now, as the exact wording has to be changed anyways once we switch to downloading language specific archives :)
docs/src/config_updates.md
Outdated
URL for the location of tldr pages archive. Default is the main `thdr.sh` | ||
archive location. |
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.
The new client specification has changed the recommended source for pages again, instead of using tldr.sh
, the Github releases are preferred now. I would thus change this to
URL for the location of tldr pages archive. Default is the main `thdr.sh` | |
archive location. | |
URL for the location of tldr pages archive. By default the pages are fetched from the latest `tldr-pages/tldr` GitHub release. |
docs/src/config_updates.md
Outdated
auto_update = true | ||
auto_update_interval_hours = 24 |
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.
I think we should omit these here, because they are independent of the archive_url
option
auto_update = true | |
auto_update_interval_hours = 24 |
docs/src/config_updates.md
Outdated
[updates] | ||
auto_update = true | ||
auto_update_interval_hours = 24 | ||
archive_url = https://tldr.infra.local/assets/tldr.zip |
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.
Let's go with something more neutral like
archive_url = https://tldr.infra.local/assets/tldr.zip | |
archive_url = https://my-company.example.com/tldr.zip |
src/config.rs
Outdated
@@ -16,6 +16,7 @@ use crate::types::PathSource; | |||
pub const CONFIG_FILE_NAME: &str = "config.toml"; | |||
pub const MAX_CACHE_AGE: Duration = Duration::from_secs(2_592_000); // 30 days | |||
const DEFAULT_UPDATE_INTERVAL_HOURS: u64 = MAX_CACHE_AGE.as_secs() / 3600; // 30 days | |||
const ARCHIVE_URL: &str = "https://tldr.sh/assets/tldr.zip"; |
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.
Since this is now only used in default_archive_url
, I think we can just inline it there (and also update it to the new recommended URL, which is https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip)
c4e2fd5
to
8daabd2
Compare
docs/src/config_updates.md
Outdated
@@ -24,3 +24,13 @@ is set to `false`. | |||
auto_update = true | |||
auto_update_interval_hours = 24 | |||
|
|||
### archive_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.
Given that we will soon switch to using a URL where we append pages.en.zip
, pages.de.zip
etc. ourselves, maybe we should prefer something more neutral as the name. How do you feel about "archive_source"?
Thanks for the review. I agree with all your comments. I started switching from For the time being I would hard-code update() to always append |
Very cool that you are coming back to this after the long time waiting for us! You can disregard the details of #345, I have been working on a rewrite on a separate branch anyways and I am trying to push out smaller changes like #400 first. At some point, I will update #345 or make a new PR. I think For this PR, it would be okay to have |
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.
One more thing I spotted :)
docs/src/config_updates.md
Outdated
URL for the location of tldr pages archive. By default is the pages are | ||
fetched from the latest `tldr-pages/thdr` GitHub release. |
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.
URL for the location of tldr pages archive. By default is the pages are | |
fetched from the latest `tldr-pages/thdr` GitHub release. | |
URL for the location of the tldr pages archive. By default the pages are | |
fetched from the latest `tldr-pages/tldr` GitHub release. |
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.
Very cool, thanks!
src/cache.rs
Outdated
self.ensure_cache_dir_exists()?; | ||
|
||
let archive_url = format!("{}{}", archive_source, "tldr.zip"); |
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.
I think we can be more cautious here and add the /
. If is not present in archive_source
, the archive_url
will be unexpected, and if it was already present, having //
does not change the behavior
let archive_url = format!("{}{}", archive_source, "tldr.zip"); | |
let archive_url = format!("{}/tldr.zip", archive_source); |
archive_source
This allows for specifying a custom archive URL
as an alternative approach to Custom Pages.