Skip to content

Commit

Permalink
Improve template readability
Browse files Browse the repository at this point in the history
  • Loading branch information
heinrichreimer committed Mar 4, 2024
1 parent 6e00a55 commit a5b6827
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 43 deletions.
4 changes: 2 additions & 2 deletions layouts/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ <h1>{{- i18n "pageNotFound" -}}</h1>
{{- i18n "pageNotFoundAction" . -}}
</p>
<p>
<a href="{{ $.Site.Home.RelPermalink }}" title='{{ i18n "homepage" }}'>{{ i18n "homepage" }}</a>
<a href='{{ relref page "/" }}' title='{{ i18n "homepage" }}'>{{ i18n "homepage" }}</a>
<a href='{{ relref . "/imprint" }}' title='{{ i18n "contact" }}'>{{ i18n "contact" }}</a>
<a href='{{ relref page "/imprint" }}' title='{{ i18n "contact" }}'>{{ i18n "contact" }}</a>
</p>
</article>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/robots.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
User-agent: *
{{/* If ENV production variable is false robots will be disallowed. */}}
{{ if eq $.Site.Params.env "production" }}
{{ if eq site.Params.env "production" }}
Disallow:
{{ else }}
Disallow: /
Expand Down
4 changes: 2 additions & 2 deletions layouts/shortcodes/cv/awards.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $awards := $.Site.Data.awards -}}
{{- $awards := site.Data.awards -}}
{{- $awards = sort $awards "month" "desc" -}}
{{- $awards = sort $awards "year" "desc" -}}
<figure>
Expand Down Expand Up @@ -26,7 +26,7 @@
{{- end -}}
{{- with .value -}}
&nbsp;
<small>{{- lang.NumFmt 0 .sum "- , ." -}} {{- .unit -}}</small>
<small>{{- lang.FormatNumberCustom 0 .sum "- , ." -}} {{- .unit -}}</small>
{{- end -}}
{{- with .description -}}
<br>
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/cv/education.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $education := $.Site.Data.education -}}
{{- $education := site.Data.education -}}
{{- $education = sort $education "from.month" "desc" -}}
{{- $education = sort $education "from.year" "desc" -}}
<figure>
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/cv/experience.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $experience := $.Site.Data.experience -}}
{{- $experience := site.Data.experience -}}
<figure>
<table>
<tbody>
Expand Down
4 changes: 2 additions & 2 deletions layouts/shortcodes/cv/facts.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- with $.Site.Data.facts -}}
{{- with site.Data.facts -}}
<figure>
<table>
<tbody>
Expand All @@ -17,7 +17,7 @@
</tr>
<tr>
<th>{{- i18n "birthday" -}}</th>
<td>{{- time.Format ":date_long" .birthday -}}</td>
<td>{{- dateFormat ":date_long" .birthday -}}</td>
</tr>
<tr>
<th>{{- i18n "email" -}}</th>
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/cv/highest-degree.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- with $.Site.Data.education -}}
{{- with site.Data.education -}}
{{- $education := . -}}
{{- $education = where $education "to.year" ">" 0 -}}
{{- $education = sort $education "to.month" "desc" -}}
Expand Down
8 changes: 4 additions & 4 deletions layouts/shortcodes/cv/open-source.gohtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $username := $.Site.Data.social.github -}}
{{- with $.Site.Params.gitHubToken -}}
{{- $username := site.Data.social.github -}}
{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}

Expand Down Expand Up @@ -43,14 +43,14 @@ query {

{{- with resources.GetRemote "https://api.github.com/graphql" $pinnedReposOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
<figure>
<table>
<tbody>
{{- range .data.user.pinnedItems.nodes -}}
<tr>
<th>
{{- time.Format "01/2006" .createdAt -}}
{{- dateFormat "01/2006" .createdAt -}}
</th>
<td>
<a href="{{- .url -}}" rel="noreferrer" target="_blank" title="{{- .nameWithOwner -}}">
Expand Down
6 changes: 3 additions & 3 deletions layouts/shortcodes/cv/publications.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- $author := $.Site.Data.facts.name -}}
{{- $author := site.Data.facts.name -}}

{{- $webisPublicationsUrl := "https://webis.de/publications.html" -}}

Expand All @@ -20,7 +20,7 @@
{{- $xmlText = replace $xmlText "&nbsp;" " " -}}
{{- $xmlText = replace $xmlText "&" "&#38;" -}}
{{- $xmlText = replace $xmlText "&amp;" "&#38;" -}}
{{- $htmlEntities := resources.Get "csv/html-entities.csv" | transform.Unmarshal (dict "delimiter" ",") -}}
{{- $htmlEntities := resources.Get "csv/html-entities.csv" | unmarshal (dict "delimiter" ",") -}}
{{- range $htmlEntities -}}
{{- $htmlEntityGlyph := index . 0 -}}
{{- $htmlEntityName := index . 1 -}}
Expand All @@ -40,7 +40,7 @@
{{- $xmlResource := $xmlText | resources.FromString $xmlTargetPath -}}

{{/* Parse XML as map. */}}
{{- with $xmlResource | transform.Unmarshal -}}
{{- with $xmlResource | unmarshal -}}
{{/* Navigate to publication list year entries. */}}
{{- $element := . -}}
{{- $element = index $element "body" -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/cv/skills.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- with $.Site.Data.skills -}}
{{- with site.Data.skills -}}
<figure>
<table>
<tbody>
Expand Down
18 changes: 9 additions & 9 deletions layouts/shortcodes/github/repos.gohtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $username := $.Site.Data.social.github -}}
{{- with $.Site.Params.gitHubToken -}}
{{- $username := site.Data.social.github -}}
{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}
{{- if not $username -}}
Expand Down Expand Up @@ -43,7 +43,7 @@ query {
{{- $userUrl := "" -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $userOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
{{- $repositoriesCount = .data.user.repositories.totalCount -}}
{{- $userUrl = .data.user.url -}}
{{- else -}}
Expand Down Expand Up @@ -112,7 +112,7 @@ query {
{{- $reposCount := 0 -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $reposOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
{{- with .data.user.repositories.nodes -}}
{{- $repositories = append $repositories . -}}
{{- end -}}
Expand Down Expand Up @@ -216,8 +216,8 @@ query {
{{- $kilobytes := div $bytes 1000 -}}
{{- $megabytes := div $kilobytes 1000 -}}
<small>
📚 {{ .reposCount }}<br>
💾&nbsp;{{- $megabytes | lang.FormatNumber 2 -}}&thinsp;MB
📚 {{ .reposCount }}&emsp;
💾&nbsp;{{- $megabytes | lang.FormatNumber 2 -}}MB
</small>
</td>

Expand All @@ -241,7 +241,7 @@ query {
{{- $description -}}
</small><br>
<small>
📅 {{ time.Format ":date_short" .pushedAt }}&emsp;
📅 {{ dateFormat ":date_short" .pushedAt }}&emsp;
⭐ {{ .stargazerCount }}
</small>
{{- end -}}
Expand All @@ -268,9 +268,9 @@ query {
{{- $moreRepos = sort $moreRepos "stargazers_count" "desc" -}}
{{/* Cut-off after top-3. */}}
{{- $moreRepos = first 3 $moreRepos -}}
<td>
<td style="max-width:15em;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;">
{{- range $moreRepos -}}
<a href="{{ .html_url }}" rel="noreferrer" target="_blank">{{ .name }}</a><br>
<small><a href="{{ .html_url }}" rel="noreferrer" target="_blank">{{ .name }}</a></small><br>
{{- end -}}
</td>
</tr>
Expand Down
12 changes: 6 additions & 6 deletions layouts/shortcodes/github/stats.gohtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $username := $.Site.Data.social.github -}}
{{- with $.Site.Params.gitHubToken -}}
{{- $username := site.Data.social.github -}}
{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}
{{- if not $username -}}
Expand All @@ -10,7 +10,7 @@
{{- $osiApprovedLicenses := slice -}}
{{- with resources.GetRemote "https://github.com/spdx/license-list-data/raw/main/json/licenses.json" -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
{{- range (where .licenses "isOsiApproved" true) -}}
{{- $osiApprovedLicenses = append .licenseId $osiApprovedLicenses -}}
{{- end -}}
Expand Down Expand Up @@ -66,7 +66,7 @@ query {
{{- $organizationsCount := 0 -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $userOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
{{/* Count repos. */}}
{{- $repositoriesCount = .data.user.repositories.totalCount -}}
{{/* Count followers. */}}
Expand Down Expand Up @@ -124,7 +124,7 @@ query {
{{- $reposCount := 0 -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $reposOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
{{- with .data.user.repositories.nodes -}}
{{- $repositories = append $repositories . -}}
{{- end -}}
Expand Down Expand Up @@ -163,7 +163,7 @@ query {
{{- $contributionsOpts := dict "method" "post" "body" $contributionsBody "headers" $githubHeaders -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $contributionsOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
{{- with .data.user.contributionsCollection -}}
{{- $totalCommitContributions = add $totalCommitContributions .totalCommitContributions -}}
{{- $totalIssueContributions = add $totalIssueContributions .totalIssueContributions -}}
Expand Down
6 changes: 3 additions & 3 deletions layouts/shortcodes/github/tag.gohtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $username := $.Site.Data.social.github -}}
{{- with $.Site.Params.gitHubToken -}}
{{- $username := site.Data.social.github -}}
{{- with site.Params.gitHubToken -}}
{{- $username = print $username ":" . -}}
{{- end -}}
{{- if not $username -}}
Expand All @@ -26,7 +26,7 @@ query {
{{- $userOpts := dict "method" "post" "body" $userBody "headers" $githubHeaders -}}
{{- with resources.GetRemote "https://api.github.com/graphql" $userOpts -}}
{{- with .Err -}}{{- errorf "%s" . -}}{{- end -}}
{{- with .Content | transform.Unmarshal -}}
{{- with .Content | unmarshal -}}
<a href="{{ .data.user.url }}" rel="noreferrer" target="_blank">@{{ .data.user.login }}</a>
{{- else -}}
{{- errorf "Unable to parse GitHub GraphQL API response." -}}
Expand Down
9 changes: 3 additions & 6 deletions layouts/shortcodes/profile-image.gohtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{{- $resource := resources.Get "profile.jpg" -}}
{{- $title := i18n "profile" -}}
{{- with $resource -}}
{{- $link := $resource.RelPermalink -}}
{{- with resources.Get "profile.jpg" -}}
<figure class="profile">
<a href="{{ $link }}"{{ with $title }} title="{{ . }}"{{ end }}>
<a href="{{ .RelPermalink }}" title="{{ i18n "profile" }}" download="profile.jpg">
{{- with .Fit "400x400" -}}
<img src="{{ .RelPermalink }}"{{ with $title }} alt="{{ . }}"{{ end }}>
<img src="{{ .RelPermalink }}" alt="{{ i18n "profile" }}">
{{- end -}}
</a>
</figure>
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/sponsors.gohtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ with $.Site.Data.sponsors }}
{{ with site.Data.sponsors }}
<ul>
{{ range .sponsors }}
<li>
Expand Down

0 comments on commit a5b6827

Please sign in to comment.