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

✨ feat: add link to commit history on updated articles #109

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

welpo
Copy link
Owner

@welpo welpo commented Aug 15, 2023

TL;DR
  • Add a "See changes" link to the commit history of updated articles.
  • Works with GitHub, GitLab, and Gitea.
  • See screenshot below.

Features

  • Introduces a feature for sites hosted on GitHub, GitLab, or Gitea, that automatically attaches a "See changes" link to the commit history of an article right next to its 'last updated' date. This facilitates direct access to version history for updated articles.
  • Provides seamless integration with popular Git platforms: GitHub, GitLab, and Gitea.
  • Supports auto-detection of the Git platform based on the repository URL. For manual specification, the Git platform can be set in the TOML configuration.

Implementation details

  • Introduces a new Tera macro, create_history_url, to generate the commit history URLs based on each platform's URL template.
  • Adds three settings in config.toml to specify remote repository details (URL and branch) and either opt for the auto-detection feature or set the Git platform manually.
  • Adds translations for the new string.
  • Integrated the feature into the articles metadata section, displayed adjacent to the last updated date:

See changes screenshot

Note ⚠️

  • For repository URLs not containing standard identifiers like "github.", "gitea.", or "gitlab.", it's necessary to manually set the git_platform in the config. This ensures accurate behavior since auto-detection will not be work for non-standard URLs.

- Introduce the `create_history_url` macro in Tera to generate URLs.
- Add TOML configuration for specifying remote repository details.
- Integrate the new feature in the page meta for displaying a link to view changes.
@welpo welpo merged commit 0e3a4af into main Aug 15, 2023
1 check passed
@welpo welpo deleted the feat/history-link branch August 15, 2023 00:02
@Jieiku
Copy link
Contributor

Jieiku commented Aug 15, 2023

anything that works for gitea should also work for codeberg. I do something similar for the bash script that generates this page: https://github.com/Jieiku/zola-themes-benchmarks/blob/main/README.md

welpo added a commit that referenced this pull request Aug 15, 2023
@welpo
Copy link
Owner Author

welpo commented Aug 15, 2023

Thanks!

I didn't know Codeberg (Forgejo, really) was a soft-fork of Gitea. I've added support for codeberg repositories in b5fae83, which behaves identically as when Gitea is set.

welpo added a commit that referenced this pull request Aug 18, 2023
Adds two options, both defaulting to true if the remote repo URL is set:
* `show_remote_changes`: links the commit history of a post next to the updated date. (#109)
* `show_remote_source`: links to the site's repository on the footer.
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