From b5fae83f28800ad6ef5a34180d84f05c8fe72849 Mon Sep 17 00:00:00 2001 From: welpo Date: Tue, 15 Aug 2023 12:58:36 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20support=20for=20remot?= =?UTF-8?q?e=20codeberg=20repositories?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds on #109 --- config.toml | 4 ++-- templates/macros/create_history_url.html | 9 ++++----- theme.toml | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config.toml b/config.toml index 13268e8..e3f37d9 100644 --- a/config.toml +++ b/config.toml @@ -137,10 +137,10 @@ language_name.es = "Español" # Remote repository for your Zola site. # Only used to link to the commit history of updated posts, right next to the updated date. -# Supports GitHub, GitLab and Gitea. +# Supports GitHub, GitLab, Gitea, and Codeberg. remote_repository_url = "https://github.com/welpo/tabi" # Set this to "auto" to try and auto-detect the platform based on the repository URL. -# Accepted values are "github", "gitlab", and "gitea". +# Accepted values are "github", "gitlab", "gitea", and "codeberg". # Defaults to "auto". remote_repository_git_platform = "auto" # Branch in the repo hosting the Zola site. Defaults to "main". diff --git a/templates/macros/create_history_url.html b/templates/macros/create_history_url.html index 618ba23..74a34cc 100644 --- a/templates/macros/create_history_url.html +++ b/templates/macros/create_history_url.html @@ -8,22 +8,21 @@ {% if git_platform == "auto" %} {% if repository_url is containing("github.") %} {% set git_platform = "github" %} - {% elif repository_url is containing("gitea.") %} - {% set git_platform = "gitea" %} {% elif repository_url is containing("gitlab.") %} {% set git_platform = "gitlab" %} + {% elif repository_url is matching("(gitea\.|codeberg\.)") %} + {% set git_platform = "gitea" %} {% endif %} {% endif %} {# Generate the commit history URL based on the git platform #} {% if git_platform == "github" %} {{ repository_url ~ '/commits/' ~ branch ~ '/content/' }}{{ relative_path | urlencode }} -{% elif git_platform == "gitea" %} - {{ repository_url ~ '/commits/branch/' ~ branch ~ '/' }}{{ relative_path | urlencode }} {% elif git_platform == "gitlab" %} {{ repository_url ~ '/-/commits/' ~ branch ~ '/' }}{{ relative_path | urlencode }} +{% elif git_platform in ["gitea", "codeberg"] %} + {{ repository_url ~ '/commits/branch/' ~ branch ~ '/' }}{{ relative_path | urlencode }} {% else %} - {# Throw an error with a direct link to report a bug for unsupported or unspecified platforms #} {{ throw(message="ERROR: Unknown, unsupported, or unspecified git platform. If you're using a custom domain, please specify the 'git_platform' in the config. If you think this is a bug, please report it: https://github.com/welpo/tabi/issues/new?assignees=&labels=bug&template=bug_report.md&title=Unsupported%20Git%20Platform%20Detected") }} {% endif %} diff --git a/theme.toml b/theme.toml index affe16e..e6c996e 100644 --- a/theme.toml +++ b/theme.toml @@ -28,10 +28,10 @@ language_name.es = "Español" # Remote repository for your Zola site. # Only used to link to the commit history of updated posts, right next to the updated date. -# Supports GitHub, GitLab and Gitea. +# Supports GitHub, GitLab, Gitea, and Codeberg. remote_repository_url = "https://github.com/welpo/tabi" # Set this to "auto" to try and auto-detect the platform based on the repository URL. -# Accepted values are "github", "gitlab", and "gitea". +# Accepted values are "github", "gitlab", "gitea", and "codeberg". # Defaults to "auto". remote_repository_git_platform = "auto" # Branch in the repo hosting the Zola site. Defaults to "main".