chore: even more Unix line feed conversion

This commit is contained in:
Sören Weber 2025-02-16 00:29:04 +01:00
parent 177d2329cb
commit dac4cbecc1
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
3 changed files with 70 additions and 70 deletions

View file

@ -1,48 +1,48 @@
{{- $page := .page }} {{- $page := .page }}
{{- $linkObject := "" }} {{- $linkObject := "" }}
{{- $u := urls.Parse .url }} {{- $u := urls.Parse .url }}
{{- $path := strings.TrimPrefix "./" $u.Path }} {{- $path := strings.TrimPrefix "./" $u.Path }}
{{- $searchLocal := .searchLocal | default true }} {{- $searchLocal := .searchLocal | default true }}
{{- $searchGlobal := .searchGlobal | default true }} {{- $searchGlobal := .searchGlobal | default true }}
{{- $searchPage := .searchPage | default true }} {{- $searchPage := .searchPage | default true }}
{{- $searchResource := .searchResource | default true }} {{- $searchResource := .searchResource | default true }}
{{- if $path }} {{- if $path }}
{{- with or {{- with or
(and $searchLocal $searchPage ($page.Page.GetPage $path)) (and $searchLocal $searchPage ($page.Page.GetPage $path))
(and $searchLocal $searchPage ($page.Page.GetPage (strings.TrimRight "/" $path))) (and $searchLocal $searchPage ($page.Page.GetPage (strings.TrimRight "/" $path)))
(and $searchGlobal $searchPage (site.GetPage $path)) (and $searchGlobal $searchPage (site.GetPage $path))
(and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path))) (and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path)))
(and $searchLocal $searchResource ($page.Page.Resources.Get $path)) (and $searchLocal $searchResource ($page.Page.Resources.Get $path))
(and $searchGlobal $searchResource (resources.Get $path)) (and $searchGlobal $searchResource (resources.Get $path))
}} }}
{{- $linkObject = . }} {{- $linkObject = . }}
{{- else }} {{- else }}
{{- /* is it a link into another translation? */}} {{- /* is it a link into another translation? */}}
{{- if strings.HasPrefix $path "/" }} {{- if strings.HasPrefix $path "/" }}
{{- range $page.AllTranslations }} {{- range $page.AllTranslations }}
{{- $lang := .Language.Lang }} {{- $lang := .Language.Lang }}
{{- $prefix := printf "/%s" $lang }} {{- $prefix := printf "/%s" $lang }}
{{- $suffix := strings.TrimPrefix $prefix $path | default "/" }} {{- $suffix := strings.TrimPrefix $prefix $path | default "/" }}
{{- /* with the second check we check if the prefix was finished; {{- /* with the second check we check if the prefix was finished;
eg. /pir/index.html vs. /pirate/index.html, were the latter is eg. /pir/index.html vs. /pirate/index.html, were the latter is
an external address outside of this site */}} an external address outside of this site */}}
{{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }} {{- if and (strings.HasPrefix $path $prefix) (strings.HasPrefix $suffix "/") }}
{{- with or {{- with or
(and $searchLocal $searchPage (.GetPage $suffix)) (and $searchLocal $searchPage (.GetPage $suffix))
(and $searchLocal $searchPage (.GetPage (strings.TrimRight "/" $suffix))) (and $searchLocal $searchPage (.GetPage (strings.TrimRight "/" $suffix)))
(and $searchGlobal $searchPage (site.GetPage $path)) (and $searchGlobal $searchPage (site.GetPage $path))
(and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path))) (and $searchGlobal $searchPage (site.GetPage (strings.TrimRight "/" $path)))
(and $searchLocal $searchResource (.Resources.Get $suffix)) (and $searchLocal $searchResource (.Resources.Get $suffix))
(and $searchGlobal $searchResource (resources.Get $suffix)) (and $searchGlobal $searchResource (resources.Get $suffix))
}} }}
{{- $linkObject = . }} {{- $linkObject = . }}
{{- break }} {{- break }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- else }} {{- else }}
{{- $linkObject = $page.Page }} {{- $linkObject = $page.Page }}
{{- end }} {{- end }}
{{- return $linkObject }} {{- return $linkObject }}

View file

@ -1,23 +1,23 @@
{{- $pageParam := index .page.Params .param }} {{- $pageParam := index .page.Params .param }}
{{- $siteParam := index site.Params .param }} {{- $siteParam := index site.Params .param }}
{{- $applyErrorIgnore := .applyErrorIgnore | default true }} {{- $applyErrorIgnore := .applyErrorIgnore | default true }}
{{- $errorlevel := or (and $pageParam $pageParam.errorlevel) (and $siteParam $siteParam.errorlevel) }} {{- $errorlevel := or (and $pageParam $pageParam.errorlevel) (and $siteParam $siteParam.errorlevel) }}
{{- $errorignore := slice | append (.page.Params.errorignore | default slice ) | append (site.Params.errorignore | default slice ) }} {{- $errorignore := slice | append (.page.Params.errorignore | default slice ) | append (site.Params.errorignore | default slice ) }}
{{- if and (eq $errorlevel "warning") (partial "inline/show-error" (dict "errorignore" $errorignore "url" .url "applyErrorIgnore" $applyErrorIgnore)) }} {{- if and (eq $errorlevel "warning") (partial "inline/show-error" (dict "errorignore" $errorignore "url" .url "applyErrorIgnore" $applyErrorIgnore)) }}
{{- warnf .msg }} {{- warnf .msg }}
{{- else if and (eq $errorlevel "error") (partial "inline/show-error" (dict "errorignore" $errorignore "url" .url "applyErrorIgnore" $applyErrorIgnore)) }} {{- else if and (eq $errorlevel "error") (partial "inline/show-error" (dict "errorignore" $errorignore "url" .url "applyErrorIgnore" $applyErrorIgnore)) }}
{{- errorf .msg }} {{- errorf .msg }}
{{- end }} {{- end }}
{{- define "partials/inline/show-error" }} {{- define "partials/inline/show-error" }}
{{- $ret := true }} {{- $ret := true }}
{{- if .applyErrorIgnore }} {{- if .applyErrorIgnore }}
{{- range .errorignore }} {{- range .errorignore }}
{{- if findRE . $.url 1 }} {{- if findRE . $.url 1 }}
{{- $ret = false }} {{- $ret = false }}
{{- break }} {{- break }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- return $ret }} {{- return $ret }}
{{- end }} {{- end }}

View file

@ -1 +1 @@
7.3.2+6499d96e5261ebca9761a7d620dac5c062363f57 7.3.2+177d2329cbbe503311ea40321dd704ea104d6792