Skip to content

Commit

Permalink
Add Codeberg as an available forge for the revision plugin setup (#155)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mark-pitblado authored Dec 17, 2024
1 parent b773724 commit e20c9ec
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
18 changes: 16 additions & 2 deletions documentation/docs/configuration/plugins/git-revision.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,26 @@ theme:
- revision.history
```

## Codeberg
### MkDocs projet in root directory
```yaml
repo_url: https://codeberg.org/exampleUser/exampleRepository
edit_url_template: _edit/main/docs/{path}
plugins:
- git-revision-date
theme:
name: terminal
features:
- revision.date
- revision.history
```

## Adding Repository Hosts
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.
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.

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

[submit a feature request]: https://github.com/ntno/mkdocs-terminal/issues/new/choose
[Blocks]: ../../blocks
[Blocks]: ../../blocks
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mkdocs-terminal",
"version": "4.6.1",
"version": "4.7.0",
"description": "Terminal.css theme for MkDocs",
"keywords": [
"mkdocs",
Expand Down
5 changes: 4 additions & 1 deletion terminal/partials/page-content/revision.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
{%- if config.repo_name == "Bitbucket" -%}
See revision history on <a href="{{ page.edit_url | replace('mode=edit','mode=read') }}">{{ config.repo_name }}</a>.
{%- endif -%}
{%- if config.repo_name == "Codeberg" -%}
See revision history on <a href="{{ page.edit_url | replace('/_edit/','/commits/branch/') }}">{{ config.repo_name }}</a>.
{%- endif -%}
{%- endif -%}
</i>
</small>
</p>
</aside>
</section>
{%- endif -%}
{%- endif -%}
{%- endif -%}
2 changes: 1 addition & 1 deletion terminal/theme_version.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-terminal-4.6.1">
<meta name="generator" content="mkdocs-{{ mkdocs_version }}, mkdocs-terminal-4.7.0">
11 changes: 11 additions & 0 deletions tests/test_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ def test_bitbucket_history_link(self, revision_partial, enabled_context):
assert "<a href=\"" + expected_page_source_url + "\">Bitbucket</a>" in rendered_revision
assert_valid_html(rendered_revision)

def test_codeberg_history_link(self, revision_partial, enabled_context):
expected_page_history_url = "https://codeberg.org/myUsername/myRepository/commits/branch/main/docs/index.md"
enabled_context["page"]["meta"]["revision_date"] = "2023/03/04"
enabled_context["page"]["edit_url"] = "https://codeberg.org/myUsername/myRepository/_edit/main/docs/index.md"
enabled_context["config"]["repo_name"] = "Codeberg"
context_data = enabled_context
rendered_revision = revision_partial.render(context_data)
assert "Page last updated 2023/03/04. See revision history on" in rendered_revision
assert "<a href=\"" + expected_page_history_url + "\">Codeberg</a>" in rendered_revision
assert_valid_html(rendered_revision)

def test_last_updated_text_hidden_when_date_disabled_on_page(self, revision_partial, enabled_context):
enabled_context["page"]["meta"]["hide"] = [page_features.HIDE_REVISION_DATE_ON_PAGE]
context_data = enabled_context
Expand Down

0 comments on commit e20c9ec

Please sign in to comment.