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

Added new 'GitForge' param for non GitHub repos #403

Merged
merged 4 commits into from
Sep 7, 2021

Conversation

MarionMoseby
Copy link
Contributor

@MarionMoseby MarionMoseby commented Aug 29, 2021

Issue

I use a gitea repository; with the current setup, there is no way to use it with toha

Description

Makes the"Improve this page" button compatible with gitea and gitlab repos, while keeping backwards compatibility, I also tried to establish "main" as the default branch by doing:
`
{{ if site.Params.GitBranch }}
{{ $GitBranch = site.Params.GitBranch }}
{{ else }}
{{ $GitBranch = main }}
{{ end }}

`

But I couldnt get it to work

Copy link
Member

@hossainemruz hossainemruz left a comment

Choose a reason for hiding this comment

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

Thank you @MarionMoseby . Can you please acknowledge the comments?

@@ -71,7 +71,13 @@ <h1>{{ .Page.Title }}</h1>
<!--- Improve this page button --->
{{ if site.Params.GitRepo }}
<div class="btn-improve-page">
<a href="{{ site.Params.GitRepo }}/edit/{{ site.Params.GitBranch }}/content/{{ .File.Path }}" title="{{ i18n "improve_this_page" }}" target="_blank" rel="noopener">
{{ if ( eq site.Params.GitForge "gitlab" ) }}
<a href="{{ site.Params.GitRepo }}-/edit/{{ site.Params.GitBranch }}/{{ .File.Path }}" title="{{ i18n "improve_this_page" }}" target="_blank" rel="noopener">
Copy link
Member

Choose a reason for hiding this comment

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

Should it be "{{ site.Params.GitRepo }}/-/edit/ instead of "{{ site.Params.GitRepo }}-/edit/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum I see, I believe the problem is my GitRepo param is styled as https://codeberg.org/FlyingFlamingo/pablomarcos.me/ instead of https://codeberg.org/FlyingFlamingo/pablomarcos.me, so the {{ site.Params.GitRepo }} makes the / redundant. I guess for backwards compatibility I should add this change, even though I dont know which is more common, to have the final / or not

{{ if ( eq site.Params.GitForge "gitlab" ) }}
<a href="{{ site.Params.GitRepo }}-/edit/{{ site.Params.GitBranch }}/{{ .File.Path }}" title="{{ i18n "improve_this_page" }}" target="_blank" rel="noopener">
{{ else if ( eq site.Params.GitForge "gitea" ) }}
<a href="{{ site.Params.GitRepo }}_edit/{{ site.Params.GitBranch }}/content/{{ .File.Path }}" title="{{ i18n "improve_this_page" }}" target="_blank" rel="noopener">
Copy link
Member

Choose a reason for hiding this comment

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

Should it be {{ site.Params.GitRepo }}/_edit/{{ site.Params.GitBranch }} instead of {{ site.Params.GitRepo }}_edit/{{ site.Params.GitBranch }} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here really

@hossainemruz hossainemruz added the enhancement New feature or request label Aug 29, 2021
@hossainemruz hossainemruz changed the title Added new 'GitForge' param for non-git repos Added new 'GitForge' param for non GitHub repos Aug 29, 2021
@MarionMoseby
Copy link
Contributor Author

Also, do you see if there is a way of making main the default Gitbranch? So that it does not have to be specified for most projects

@MarionMoseby
Copy link
Contributor Author

Everything should be ready now :p

Copy link
Member

@hossainemruz hossainemruz left a comment

Choose a reason for hiding this comment

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

Looks good now. Thank you @MarionMoseby

@kodiakhq kodiakhq bot merged commit e8e23ed into hugo-toha:main Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants