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 -}} {{- $scratch := .scratch -}}
{{- $lines := .lines -}}
{{- $scratch.Set "bestLength" -1 -}} {{- $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" "" -}} {{- $scratch.Set "bestPath" "" -}}
{{- $filePath := .path -}} {{- $filePath := .path -}}
{{- range $path, $url := $submoduleLinks -}} {{- range $path, $url := .submoduleLinks -}}
{{- $bestLength := $scratch.Get "bestLength" -}} {{- $bestLength := $scratch.Get "bestLength" -}}
{{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}} {{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
{{- $scratch.Set "bestLength" (len $path) -}} {{- $scratch.Set "bestLength" (len $path) -}}
{{- $scratch.Set "bestPath" $path -}} {{- $scratch.Set "bestPath" $path -}}
{{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}} {{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}}
{{- end -}}
{{- end -}} {{- 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 -}} {{- end -}}

View File

@ -1,9 +1,8 @@
{{- $scratch := newScratch -}} {{- page.Scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- $scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
{{- if (or .firstLine .lastLine) -}} {{- 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 -}} {{- end -}}
{{- if eq (lower .language) "agda" -}} {{- if eq (lower .language) "agda" -}}
{{- $scratch.Add "highlightGroupAttrs" " data-agda-block" -}} {{- page.Scratch.Add "highlightGroupAttrs" " data-agda-block" -}}
{{- end -}} {{- 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"> <div class="block">
{{- .Inner -}} {{ .Inner }}
</div> </div>

View File

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

View File

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

View File

@ -1,3 +1,2 @@
{{- $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)) -}} {{- .Scratch.Get "bestUrl" -}}
{{- $scratch.Get "bestUrl" -}}

View File

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

View File

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

View File

@ -5,7 +5,6 @@
{{- $line := .Get 4 -}} {{- $line := .Get 4 -}}
{{- $lines := split (trim .Inner "\n") "\n" -}} {{- $lines := split (trim .Inner "\n") "\n" -}}
{{- $scratch := newScratch -}}
{{- $url := printf "https://github.com/%s/blob/%s/%s#L%d" $repo $commit $file $line -}} {{- $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 "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 "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 side-{{ .Get 0 }}">
<span class="message-sender"> <span class="message-sender">
{{- if (eq (.Get 1) "reader") -}} {{ if (eq (.Get 1) "reader") }}
{{- partial "icon.html" "moon" -}} {{ partial "icon.html" "moon" }}
{{- else -}} {{ else }}
{{- partial "icon.html" "sun" -}} {{ partial "icon.html" "sun" }}
{{- end -}} {{ end }}
</span> </span>
<span class="message-text">{{- .Inner -}}</span> <span class="message-text">{{ .Inner }}</span>
</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 {{- $groupconfig := dict
"url" ($scratch.Get "bestUrl") "url" (.Scratch.Get "bestUrl")
"basePath" ($scratch.Get "bestPath") "basePath" (.Scratch.Get "bestPath")
"path" (.Get 0) "path" (.Get 0)
"comment" ", entire file" "comment" ", entire file"
"content" (safeHTML (printf "<pre><code>%s</code></pre>" (htmlEscape (readFile (printf "code/%s" (.Get 0)))))) "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"> <span class="sidenote">
<label class="sidenote-label" for="{{- .Get 1 -}}">{{- .Get 2 -}}</label> <label class="sidenote-label" for="{{ .Get 1 }}">{{ .Get 2 }}</label>
<input class="sidenote-checkbox" type="checkbox" id="{{- .Get 1 -}}"></input> <input class="sidenote-checkbox" type="checkbox" id="{{ .Get 1 }}"></input>
{{- if $offset := .Get 3 -}} {{ if $offset := .Get 3 }}
<span class="sidenote-content sidenote-{{- .Get 0 -}}" style="margin-top: {{- $offset -}}rem"> <span class="sidenote-content sidenote-{{ .Get 0 }}" style="margin-top: {{ $offset }}rem">
{{- else -}} {{ else }}
<span class="sidenote-content sidenote-{{- .Get 0 -}}"> <span class="sidenote-content sidenote-{{ .Get 0 }}">
{{- end -}} {{ end }}
<span class="sidenote-delimiter">[{{- i18n "note" -}}:</span> <span class="sidenote-delimiter">[{{ i18n "note" }}:</span>
{{- .Inner -}} {{ .Inner }}
<span class="sidenote-delimiter">]</span> <span class="sidenote-delimiter">]</span>
</span> </span>
</span> </span>

View File

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