summaryrefslogtreecommitdiff
path: root/layouts/index.html
blob: 0a84145099544573660c3fe56e5b3d2fd4b2fc5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{{ define "main" }}
    {{ $env := printf "<strong><span id='user'>%s@%s</span><span id='terminal'>:</span><span id='dir'>~/%s</span></strong><span id='terminal'>$</span>" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName "" | safeHTML }}
    {{ $envWithDir := printf "<strong><span id='user'>%s@%s</span><span id='terminal'>:</span><span id='dir'>~/%s</span></strong><span id='terminal'>$</span>" .Site.Params.Terminal.userName .Site.Params.Terminal.pcName .Site.Params.Terminal.workDir | safeHTML }}

    {{ $cd := printf "<span id='terminal'>cd %s</span>" .Site.Params.Terminal.workDir | safeHTML }}
    {{ $cat := printf "<span id=terminal>cat %s</span>" .Site.Params.Terminal.profile | safeHTML }}

    {{ $description := "" }}
    {{ if eq (substr .Site.Params.Terminal.description -3 3) ".md" }}
        {{ $s := "" }}
        {{ with .Site.GetPage .Site.Params.Terminal.description }}
            <!-- replace the first  p tag with a br tag  -->
            {{ $s = replaceRE "</?p[^>]*>" "" .Content 1 }}
        {{ end }}
    {{ $description = printf "<span id='terminal'>%s</span>" $s | safeHTML}}
    {{ else }}
    {{ $limit := sub (len (findRE "\n" .Site.Params.Terminal.description)) 1 }}
    {{ $description = printf "<span id='terminal'>%s</span>" .Site.Params.Terminal.description }}
    {{ $description = replaceRE "\n" "<br>" $description $limit| safeHTML }}
    {{ end }}

    {{ $tree := "" }}
    {{ $leaf := "" }}
    {{ if .Site.Params.Tree.use }}
    {{ $tree = printf "<span id='terminal'>tree ./%s/</span>" .Site.Params.Tree.folderName | safeHTML}}
    {{ $leaf = printf "%s<strong><span id='dir'>./%s/</span></strong><br>" $leaf .Site.Params.Tree.folderName | safeHTML}}
        {{ range $index, $val := .Site.Params.Tree.files }}
            {{ $ac := index $val 0}}
            {{ $link := index $val 1}}

            <!-- pass link (i.e. http, https) and mailto -->
            {{ $l := $.Site.GetPage $link }}
            {{ if $l }}
                {{ $link = $l.Permalink}}
            {{ end }}
            
            {{ if eq (add $index 1) (len $.Site.Params.Tree.files) }}
            {{ $leaf = printf "<span id='terminal'>%s└── <a href='%s'>%s</a></span>" $leaf $link $ac | safeHTML}}
            {{ else }}
            {{ $leaf = printf "<span id='terminal'>%s├── <a href='%s'>%s</a></span><br>" $leaf $link $ac | safeHTML}}
            {{ end }}
        {{ end }}
    {{ end }}

    {{ $end := $env }}

    {{ $payload := delimit (slice $cd $cat $description $tree $leaf $end) "" }}

    {{ $ps1Delay := $.Site.Params.Terminal.ps1Delay }}
    {{ $stdoutDelay :=  $.Site.Params.Terminal.stdoutDelay }}
    {{ $commandDelay := $.Site.Params.Terminal.commandDelay }}

    {{ partial "partials/typeIndex.html" (dict "context" . "env" $env "cd" $cd "envWithDir" $envWithDir "cat" $cat "description" $description "tree" $tree "leaf" $leaf "ps1delay" $ps1Delay "stdoutdelay" $stdoutDelay "commanddelay" $commandDelay ) }}

{{ end }}