Compare commits

..

No commits in common. "df22cb2b87cf9bc1a9da372e17d4c4eedfc3efff" and "97e965feece9fd3d3a5328156c043bd2a0cca80f" have entirely different histories.

13 changed files with 58 additions and 78 deletions

View File

@ -1,27 +1,13 @@
{{- $siteSourceUrl := site.Params.siteSourceUrl -}}
{{- $submoduleLinks := site.Data.submodules -}}
{{- $hostData := site.Data.hosts -}}
{{- $scratch := .scratch -}}
{{- $lines := .lines -}}
{{- $scratch.Set "bestLength" -1 -}}
{{- $scratch.Set "bestUrl" (printf "%s/code/%s" $siteSourceUrl .path) -}}
{{- $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) -}}
{{- $scratch.Set "bestPath" "" -}}
{{- $filePath := .path -}}
{{- range $path, $url := $submoduleLinks -}}
{{- $bestLength := $scratch.Get "bestLength" -}}
{{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
{{- $scratch.Set "bestLength" (len $path) -}}
{{- $scratch.Set "bestPath" $path -}}
{{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}}
{{- end -}}
{{- range $path, $url := .submoduleLinks -}}
{{- $bestLength := $scratch.Get "bestLength" -}}
{{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
{{- $scratch.Set "bestLength" (len $path) -}}
{{- $scratch.Set "bestPath" $path -}}
{{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}}
{{- end -}}
{{- if .lines -}}
{{- /* If the user provided a line range, see if we can tack it on to the end of the link. */ -}}
{{- range $host, $data := $hostData -}}
{{- if hasPrefix ($scratch.Get "bestUrl") $host -}}
{{- with $data.linesSuffix -}}
{{- $scratch.Add "bestUrl" (printf . (index $lines 0) (index $lines 1)) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@ -1,9 +1,8 @@
{{- $scratch := newScratch -}}
{{- $scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- page.Scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- if (or .firstLine .lastLine) -}}
{{- $scratch.Add "highlightGroupAttrs" (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}}
{{- page.Scratch.Add "highlightGroupAttrs" (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}}
{{- end -}}
{{- if eq (lower .language) "agda" -}}
{{- $scratch.Add "highlightGroupAttrs" " data-agda-block" -}}
{{- page.Scratch.Add "highlightGroupAttrs" " data-agda-block" -}}
{{- end -}}
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" ($scratch.Get "highlightGroupAttrs")) }}
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" (page.Scratch.Get "highlightGroupAttrs")) }}

View File

@ -1,3 +1,3 @@
<div class="block">
{{- .Inner -}}
{{ .Inner }}
</div>

View File

@ -1,12 +1,11 @@
{{- $scratch := newScratch -}}
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1)) -}}
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
{{- $groupconfig := dict
"url" ($scratch.Get "bestUrl")
"basePath" ($scratch.Get "bestPath")
"url" (.Scratch.Get "bestUrl")
"basePath" (.Scratch.Get "bestPath")
"path" (.Get 1)
"comment" ", entire file"
"code" (readFile (printf "code/%s" (.Get 1)))
"language" (.Get 0)
"opts" "linenos=table"
-}}
{{- partial "highlightgroup.html" $groupconfig -}}
{{ partial "highlightgroup.html" $groupconfig }}

View File

@ -1,41 +1,40 @@
{{- $source := (readFile (printf "code/%s" (.Get 1))) -}}
{{- $allLines := split $source "\n" -}}
{{- $scratch := newScratch -}}
{{- if not (eq (int (.Get 2)) 1) -}}
{{- $scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}}
{{- .Scratch.Set "remLines" (after (sub (int (.Get 2)) 1) $allLines) -}}
{{- else -}}
{{- $scratch.Set "remLines" $allLines -}}
{{- .Scratch.Set "remLines" $allLines -}}
{{- end -}}
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) ($scratch.Get "remLines") -}}
{{- $lines := first (add (sub (int (.Get 3)) (int (.Get 2))) 1) (.Scratch.Get "remLines") -}}
{{- if (.Get 4) -}}
{{- $scratch.Set "opts" (printf ",%s" (.Get 4)) -}}
{{- .Scratch.Set "opts" (printf ",%s" (.Get 4)) -}}
{{- else -}}
{{- $scratch.Set "opts" "" -}}
{{- .Scratch.Set "opts" "" -}}
{{- end -}}
{{- if (.Get 5) -}}
{{- $scratch.Set "hidden" (.Get 5) -}}
{{- .Scratch.Set "hidden" (.Get 5) -}}
{{- end -}}
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 1) "lines" (slice (.Get 2) (.Get 3))) -}}
{{- partial "linerangestr.html" (dict "scratch" $scratch "from" (.Get 2) "to" (.Get 3)) -}}
{{- partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) -}}
{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}}
{{- with ($scratch.Get "hidden") -}}
<details><summary>{{- . | markdownify -}}</summary>
{{- with (.Scratch.Get "hidden") -}}
<details><summary>{{ . | markdownify }}</summary>
{{- end -}}
{{- $groupconfig := dict
"url" ($scratch.Get "bestUrl")
"basePath" ($scratch.Get "bestPath")
"url" (.Scratch.Get "bestUrl")
"basePath" (.Scratch.Get "bestPath")
"path" (.Get 1)
"comment" ($scratch.Get "comment")
"comment" (.Scratch.Get "comment")
"code" (delimit $lines "\n")
"firstLine" (int (.Get 2))
"lastLine" (int (.Get 3))
"language" (.Get 0)
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) ($scratch.Get "opts"))
"opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) (.Scratch.Get "opts"))
-}}
{{- partial "highlightgroup.html" $groupconfig -}}
{{- with ($scratch.Get "hidden") -}}
{{- with (.Scratch.Get "hidden") -}}
</details>
{{- end -}}

View File

@ -1,3 +1,2 @@
{{- $scratch := newScratch -}}
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 0)) -}}
{{- $scratch.Get "bestUrl" -}}
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
{{- .Scratch.Get "bestUrl" -}}

View File

@ -1,4 +1,4 @@
<details>
<summary>{{- .Get "summary" | markdownify -}}</summary>
{{- .Inner | markdownify -}}
<summary>{{ .Get "summary" | markdownify }}</summary>
{{ .Inner | markdownify }}
</details>

View File

@ -1,3 +1,3 @@
<p class="dialog">
{{- .Inner -}}
{{ .Inner }}
</p>

View File

@ -5,7 +5,6 @@
{{- $line := .Get 4 -}}
{{- $lines := split (trim .Inner "\n") "\n" -}}
{{- $scratch := newScratch -}}
{{- $url := printf "https://github.com/%s/blob/%s/%s#L%d" $repo $commit $file $line -}}
{{- partial "linerangestr.html" (dict "scratch" $scratch "from" 0 "to" $line) -}}
{{- partial "highlightgroup.html" (dict "url" $url "path" $file "comment" ($scratch.Get "comment") "code" (trim .Inner "\n") "language" $lang) -}}
{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" 0 "to" $line) -}}
{{- partial "highlightgroup.html" (dict "url" $url "path" $file "comment" (.Scratch.Get "comment") "code" (trim .Inner "\n") "language" $lang) -}}

View File

@ -1,10 +1,10 @@
<span class="message side-{{ .Get 0 }}">
<span class="message-sender">
{{- if (eq (.Get 1) "reader") -}}
{{- partial "icon.html" "moon" -}}
{{- else -}}
{{- partial "icon.html" "sun" -}}
{{- end -}}
{{ if (eq (.Get 1) "reader") }}
{{ partial "icon.html" "moon" }}
{{ else }}
{{ partial "icon.html" "sun" }}
{{ end }}
</span>
<span class="message-text">{{- .Inner -}}</span>
<span class="message-text">{{ .Inner }}</span>
</span>

View File

@ -1,10 +1,9 @@
{{- $scratch := newScratch -}}
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) -}}
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
{{- $groupconfig := dict
"url" ($scratch.Get "bestUrl")
"basePath" ($scratch.Get "bestPath")
"url" (.Scratch.Get "bestUrl")
"basePath" (.Scratch.Get "bestPath")
"path" (.Get 0)
"comment" ", entire file"
"content" (safeHTML (printf "<pre><code>%s</code></pre>" (htmlEscape (readFile (printf "code/%s" (.Get 0))))))
-}}
{{- partial "group.html" $groupconfig -}}
{{ partial "group.html" $groupconfig }}

View File

@ -1,13 +1,13 @@
<span class="sidenote">
<label class="sidenote-label" for="{{- .Get 1 -}}">{{- .Get 2 -}}</label>
<input class="sidenote-checkbox" type="checkbox" id="{{- .Get 1 -}}"></input>
{{- if $offset := .Get 3 -}}
<span class="sidenote-content sidenote-{{- .Get 0 -}}" style="margin-top: {{- $offset -}}rem">
{{- else -}}
<span class="sidenote-content sidenote-{{- .Get 0 -}}">
{{- end -}}
<span class="sidenote-delimiter">[{{- i18n "note" -}}:</span>
{{- .Inner -}}
<label class="sidenote-label" for="{{ .Get 1 }}">{{ .Get 2 }}</label>
<input class="sidenote-checkbox" type="checkbox" id="{{ .Get 1 }}"></input>
{{ if $offset := .Get 3 }}
<span class="sidenote-content sidenote-{{ .Get 0 }}" style="margin-top: {{ $offset }}rem">
{{ else }}
<span class="sidenote-content sidenote-{{ .Get 0 }}">
{{ end }}
<span class="sidenote-delimiter">[{{ i18n "note" }}:</span>
{{ .Inner }}
<span class="sidenote-delimiter">]</span>
</span>
</span>

View File

@ -1,3 +1,3 @@
<div style="background-color: tomato; color: white; padding: 10px;">
<em>TODO: </em>{{- .Inner -}}
<em>TODO: </em>{{ .Inner }}
</div>