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

View file

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

View file

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