Skip to content

Commit e20c9ec

Browse files
Add Codeberg as an available forge for the revision plugin setup (#155)
* feat: add codeberg as possible repository * fix: align style to match bitbucket * fix: add missing endif * feat: add codeberg revision link test * docs: outline configuration for codeberg * docs: add codeberg to list of already implemented * docs: add oxford comma * fix: add `branch` to revision url Codeberg will automatically redirect if not included, but best to be precise * fix: update test with `branch` * fix: bump theme version * fix: edge case with trailing slashes this prevents a file with the name `_edit` from causing an error
1 parent b773724 commit e20c9ec

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

documentation/docs/configuration/plugins/git-revision.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,26 @@ theme:
122122
- revision.history
123123
```
124124

125+
## Codeberg
126+
### MkDocs projet in root directory
127+
```yaml
128+
repo_url: https://codeberg.org/exampleUser/exampleRepository
129+
edit_url_template: _edit/main/docs/{path}
125130
131+
plugins:
132+
- git-revision-date
133+
134+
theme:
135+
name: terminal
136+
features:
137+
- revision.date
138+
- revision.history
139+
```
126140

127141
## Adding Repository Hosts
128-
If your repository is not stored on GitHub or Bitbucket and you would like to use this feature please [submit a feature request] on GitHub.
142+
If your repository is not stored on GitHub, Bitbucket, or Codeberg and you would like to use this feature please [submit a feature request] on GitHub.
129143

130144
You can further customize what revision information is included on the page by implementing your own `revision` template block. See [Blocks] for more information.
131145

132146
[submit a feature request]: https://github.com/ntno/mkdocs-terminal/issues/new/choose
133-
[Blocks]: ../../blocks
147+
[Blocks]: ../../blocks

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mkdocs-terminal",
3-
"version": "4.6.1",
3+
"version": "4.7.0",
44
"description": "Terminal.css theme for MkDocs",
55
"keywords": [
66
"mkdocs",

terminal/partials/page-content/revision.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@
3131
{%- if config.repo_name == "Bitbucket" -%}
3232
See revision history on <a href="{{ page.edit_url | replace('mode=edit','mode=read') }}">{{ config.repo_name }}</a>.
3333
{%- endif -%}
34+
{%- if config.repo_name == "Codeberg" -%}
35+
See revision history on <a href="{{ page.edit_url | replace('/_edit/','/commits/branch/') }}">{{ config.repo_name }}</a>.
36+
{%- endif -%}
3437
{%- endif -%}
3538
</i>
3639
</small>
3740
</p>
3841
</aside>
3942
</section>
4043
{%- endif -%}
41-
{%- endif -%}
44+
{%- endif -%}

terminal/theme_version.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-terminal-4.6.1">
1+
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-terminal-4.7.0">

tests/test_revision.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ def test_bitbucket_history_link(self, revision_partial, enabled_context):
138138
assert "<a href=\"" + expected_page_source_url + "\">Bitbucket</a>" in rendered_revision
139139
assert_valid_html(rendered_revision)
140140

141+
def test_codeberg_history_link(self, revision_partial, enabled_context):
142+
expected_page_history_url = "https://codeberg.org/myUsername/myRepository/commits/branch/main/docs/index.md"
143+
enabled_context["page"]["meta"]["revision_date"] = "2023/03/04"
144+
enabled_context["page"]["edit_url"] = "https://codeberg.org/myUsername/myRepository/_edit/main/docs/index.md"
145+
enabled_context["config"]["repo_name"] = "Codeberg"
146+
context_data = enabled_context
147+
rendered_revision = revision_partial.render(context_data)
148+
assert "Page last updated 2023/03/04. See revision history on" in rendered_revision
149+
assert "<a href=\"" + expected_page_history_url + "\">Codeberg</a>" in rendered_revision
150+
assert_valid_html(rendered_revision)
151+
141152
def test_last_updated_text_hidden_when_date_disabled_on_page(self, revision_partial, enabled_context):
142153
enabled_context["page"]["meta"]["hide"] = [page_features.HIDE_REVISION_DATE_ON_PAGE]
143154
context_data = enabled_context

0 commit comments

Comments
 (0)