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

Add Codeberg as an available forge for the revision plugin setup #155

Merged
merged 12 commits into from
Dec 17, 2024

Conversation

mark-pitblado
Copy link
Contributor

@mark-pitblado mark-pitblado commented Dec 16, 2024

Description

Adds the ability to use the revision history for Codeberg. The revision front-end template has an additional condition that triggers if the repository name is set to Codeberg in the mkdocs.yml configuration, in the same way that it is done for bitbucket and github.
Maintainer note: setting repository name is not necessary as long as repo_url is set. Documentation has been updated with an example.

A redirect will occur from commits/main to commits/branch/main however I have kept commits/main in the template to align it with the same format used for bitbucket.
Maintainer note: after discussion we updated the template to point to commits/branch/main directly instead of relying on Codeberg's redirect

References

An implementation of this feature in action can be seen on any page within https://notes.markpitblado.me.

Testing

  • This change adds test coverage for new/changed/fixed functionality

I have implemented a test similar to the bitbucket revision link test and confirmed that it passes using the outlined setup.

Checklist

  • I have added documentation for new/changed functionality in this PR or in mkdocs-terminal/documentation
  • All active GitHub checks for tests, formatting, and security are passing

I have added documentation indicating that Codeberg is implemented and the required configuration

@ntno
Copy link
Owner

ntno commented Dec 17, 2024

hi @mark-pitblado
thank you so much for the contribution!
happy to add another option for source repository configuration

i've started taking a look at the PR - i will leave some additional comments / change requests inline

### MkDocs projet in root directory
```yaml
repo_url: https://codeberg.org/exampleUser/exampleRepository
edit_url_template: _edit/main/docs/{path}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice to include the edit_url_template attribute even thoughmkdocs-terminal theme doesn't support it yet
thanks!

tests/test_revision.py Outdated Show resolved Hide resolved
tests/test_revision.py Outdated Show resolved Hide resolved
Codeberg will automatically redirect if not included, but best to be precise
@ntno
Copy link
Owner

ntno commented Dec 17, 2024

@mark-pitblado
Copy link
Contributor Author

@ntno okay think I got everything! Sorry for the wait, first couple of commits were on mobile, but the others wanted to wait until I was back at my desk. Apologies for missing the instructions regarding the theme bump

@ntno
Copy link
Owner

ntno commented Dec 17, 2024

hi @mark-pitblado
can you review the suggestion about adding leading/trailing slashes and resolve the merge conflicts? (i updated the upstream)
after that i think this is good to go :D

this prevents a file with the name `_edit` from causing an error
@ntno
Copy link
Owner

ntno commented Dec 17, 2024

hi @mark-pitblado
just FYI i believe this will work without overwriting the repo config in mkdocs.yml
i tested locally with the following settings:

site_name: Terminal for MkDocs
site_url: https://ntno.github.io/mkdocs-terminal
#repo_url: https://github.com/ntno/mkdocs-terminal
#edit_uri_template: https://github.com/ntno/mkdocs-terminal/edit/main/documentation/docs/{path}
copyright: Copyright 2023 Natan Organick, All rights reserved
site_author: ntno
repo_url: https://codeberg.org/ntno/demo/
edit_uri_template: _edit/main/docs/{path}

i did not set the repo_name attribute
i think it is determined from the repo_url if unset
see https://www.mkdocs.org/user-guide/configuration/#repo_name

@ntno
Copy link
Owner

ntno commented Dec 17, 2024

added some notes to PR description; will merge now and create a release

@ntno ntno merged commit e20c9ec into ntno:main Dec 17, 2024
15 checks passed
@mark-pitblado
Copy link
Contributor Author

Hmmm maybe! But the mkdocs documentation only mentions that it supports the github, gitlab, or bitbucket domains. Perhaps they added codeberg and just didn't note it down?

@ntno
Copy link
Owner

ntno commented Dec 17, 2024

default: 'GitHub', 'Bitbucket' or 'GitLab' if the repo_url matches those domains, otherwise the hostname from the repo_url.

i read the above as "if you don't provide a repo_name value AND repo_url does not match one of the top 3 then we will set the value of repo_name to the hostname from the URL"

@ntno
Copy link
Owner

ntno commented Dec 17, 2024

ok package is published to pypi
can you try out installing it to your website and let me know how it goes?
once you confirm that it is working as expected i will set the release to "latest" in GitHub

ty again for your contribution!

@ntno
Copy link
Owner

ntno commented Dec 17, 2024

TODO / reminder for @ntno

  • publish doc update after setting "latest" to 4.7.0

@mark-pitblado
Copy link
Contributor Author

Now deployed with 4.7.0 to https://notes.markpitblado.me, everything seems to be functioning as expected.

@ntno ntno added enhancement New feature or request documentation Improvements or additions to documentation labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants