Compare commits
3 Commits
97e965feec
...
df22cb2b87
Author | SHA1 | Date | |
---|---|---|---|
df22cb2b87 | |||
4b19da5006 | |||
ec7b58c8ec |
|
@ -1,13 +1,27 @@
|
||||||
|
{{- $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 -}}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{{- page.Scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
|
{{- $scratch := newScratch -}}
|
||||||
|
{{- $scratch.Set "highlightGroupAttrs" (printf "data-base-path=\"%s\" data-file-path=\"%v\"" .basePath .path) -}}
|
||||||
{{- if (or .firstLine .lastLine) -}}
|
{{- if (or .firstLine .lastLine) -}}
|
||||||
{{- page.Scratch.Add "highlightGroupAttrs" (printf " data-first-line=\"%v\" data-last-line=\"%v\"" .firstLine .lastLine) -}}
|
{{- $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" -}}
|
||||||
{{- page.Scratch.Add "highlightGroupAttrs" " data-agda-block" -}}
|
{{- $scratch.Add "highlightGroupAttrs" " data-agda-block" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" (page.Scratch.Get "highlightGroupAttrs")) }}
|
{{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" ($scratch.Get "highlightGroupAttrs")) }}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<div class="block">
|
<div class="block">
|
||||||
{{ .Inner }}
|
{{- .Inner -}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{- $scratch := newScratch -}}
|
||||||
|
{{- 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 -}}
|
||||||
|
|
|
@ -1,40 +1,41 @@
|
||||||
{{- $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) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) -}}
|
{{- 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 "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 -}}
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{- $scratch := newScratch -}}
|
||||||
{{- .Scratch.Get "bestUrl" -}}
|
{{- partial "geturl.html" (dict "scratch" $scratch "path" (.Get 0)) -}}
|
||||||
|
{{- $scratch.Get "bestUrl" -}}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<details>
|
<details>
|
||||||
<summary>{{ .Get "summary" | markdownify }}</summary>
|
<summary>{{- .Get "summary" | markdownify -}}</summary>
|
||||||
{{ .Inner | markdownify }}
|
{{- .Inner | markdownify -}}
|
||||||
</details>
|
</details>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<p class="dialog">
|
<p class="dialog">
|
||||||
{{ .Inner }}
|
{{- .Inner -}}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
{{- $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) -}}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{- $scratch := newScratch -}}
|
||||||
|
{{- 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 -}}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user