-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
More powerful repository config #57
Comments
I'm taking this up, and I'm going to implement the pattern formatting. Can you however describe what the issue with the current URL is and are you using GitLab self-hosted or GitLab cloud? |
Sorry, I must have gotten confused. GitLab works fine with the current template. I guess I mistakenly thought GitLab subgroups like But there's still an issue with the current template that the one from Joe Mooring does not suffer from (since it uses I just tested it with the following three files changed to:
|
Yeah the GitLab links looked fine to me too but I think in general this is a good idea. and appreciate the insight. I'd ideally prefer to prevent a change which breaks existing users without warning and allow for the backwards compatibility. I also think the subpath compatibility for users hosting the docs in a subpath is useful, admittedly this affects me. |
Also are you saying you confirm this works with the langs in subfolders too? |
Yes.
Sure, I understand. Note that subpaths are still supported with the above (by setting |
Can you give this a try when you get a chance to see there isn't anything obvious missed? [doks]
editPage = true # false (default) or true
lastMod = true # false (default) or true
## Edit Link Generation Options. The 'repoHost' option sets a default 'repoURLPattern'.
repoHost = "GitHub" # GitHub (default), Gitea, GitLab, Bitbucket, or BitbucketServer
## The format string override to build the edit URL.
## First parameter is docsRepo, second is docsRepoBranch, and third is the file path (prefixed with docsRepoSubPath if set).
## The format defaults (which this setting overrides) are:
## GitHub: %s/blob/%s/%s
## Gitea: %s/_edit/%s/%s
## GitLab: '%s/~blob/%s/%s'
## Bitbucket: '%s/src/%s/%s'
## BitbucketServer: '%s/browse/%s/%s'
repoURLPattern = ""
docsRepo = "https://github.com/authelia/authelia"
docsRepoBranch = "master" # main (default), master, or <branch name>
docsRepoSubPath = "" # "" (none, default) or <sub path> {{ $pattern := site.Params.doks.repoURLPattern | default "" }}
{{ if not $pattern }}
{{ if (eq site.Params.doks.repoHost "GitHub") }}
{{ $pattern = "%s/blob/%s/%s" }}
{{ else if (eq site.Params.doks.repoHost "Gitea") }}
{{ $pattern = "%s/_edit/%s/%s" }}
{{ else if (eq site.Params.doks.repoHost "GitLab") }}
{{ $pattern = "%s/~blob/%s/%s" }}
{{ else if (eq site.Params.doks.repoHost "Bitbucket") }}
{{ $pattern = "%s/src/%s/%s" }}
{{ else if (eq site.Params.doks.repoHost "BitbucketServer") }}
{{ $pattern = "%s/browse/%s/%s" }}
{{ end }}
{{ end }}
{{ $path := strings.TrimPrefix "/" (replace (strings.TrimPrefix hugo.WorkingDir .File.Filename) "\\" "/") }}
{{ $url := "" }}
{{ if and (isset .Site.Params.doks "docsreposubpath") (not (eq site.Params.doks.docsRepoSubPath "")) }}
{{ $url = printf $pattern site.Params.doks.docsRepo site.Params.doks.docsRepoBranch (path.Join site.Params.doks.docsRepoSubPath $path) }}
{{ else }}
{{ $url = printf $pattern site.Params.doks.docsRepoBranch $path }}
{{ end }}
<div class="edit-page">
<a href="{{ $url }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2">
<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path>
</svg>
{{ i18n "edit_page" }} {{ site.Params.doks.repoHost }}
</a>
</div> |
This is an incomplete implementation since you only allow the user to configure a single pattern to build URLs, while there should be multiple (at least three are relevant for Doks: Also I would prefer the
|
Are any of these used currently? If not realistically users can just arbitrarily add their own params.
Yeah I prefer your structure too. Just avoiding breaking people when it's just nice and not necessary.
Yep, it also fits with the vibe of the existing implementation.
Not entirely sure I didn't initially implement that normalization, but I can check. |
Yes, see
Your snippet above includes the normalization. But it would be nice if you could check if it's actually necessary (if you have a Windows machine to test). Furthermore, two observations:
It would be easier to review if you'd include your changes in your current PR (or submit a new one if you like) :)
I think such a breaking change is fine if it's really an improvement (I think it is) and it is mentioned in the release notes :) |
Yeah that's fine, I'm happy to include that in the discussion I'm not against it - just to me at this point it's a finer detail and functionality is my end-goal. I'll double check everything else you've mentioned then put it in the PR. |
Currently, the variable parts for the "Edit this page on ..." and "Last edited on ..." functionality are supposed to be defined via keys
repoHost
anddocsRepo*
insite.Params.doks
. Although this suggests that Doks would work with a lot of different forges (GitHub, GitLab, Gitea etc. pp.), it actually doesn't. This is because the current template hardcodes an incomplete implementation how forge URLs are constructed.Currently, it is e.g. broken for GitLab.I suggest to switch to a more elegant approach by allowing to configure the URL construction scheme directly in the config. A full example how this can be done is found in this great post on the Hugo forum. The example only misses the subdirectory part (currently encoded in
docsRepoSubPath
), besides it should be adaptable pretty-much 1:1 on Doks.The text was updated successfully, but these errors were encountered: