]> BookStack Code Mirror - website/blob - themes/bookstack/layouts/shortcodes/hack.html
Fixed path handling for hack files
[website] / themes / bookstack / layouts / shortcodes / hack.html
1 {{ $filename := .Get "file" }}
2 {{ $file := path.Join .Page.Path $filename }}
3 {{ $ext := strings.TrimLeft "." (path.Ext $file) }}
4 {{ if strings.HasSuffix $file ".blade.php" }}
5     {{ $ext = "html" }}
6 {{ end }}
7 {{ $type := .Get "type" }}
8 {{ $md := printf "```%s\n%s\n```" $ext (readFile $file) }}
9 {{ $mdLen := len (split $md "\n") }}
10
11 <div class="hack-file-wrapper">
12
13     
14     <details {{if lt $mdLen 15}}open{{end}}>
15         <summary class="hack-file-block">
16             <div class="hack-file-block-filename">{{ $filename }}</div>
17         
18             <div class="hack-file-block-type type-{{ $type }}">
19                 <a target="_blank" href="{{ $file  }}">Download</a> |
20                 <a target="_blank" href="/hacks/applying/#{{ if eq $type "logical"}}logical-theme-system{{ else if eq $type "visual"}}visual-theme-system{{ else if eq $type "head"}}head-html{{end}}">
21                     {{ if eq $type "logical"}}
22                     Logical Theme System
23                     {{ else if eq $type "visual"}}
24                     Visual Theme System
25                     {{ else if eq $type "head"}}
26                     Head HTML
27                     {{ end }}
28                     <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="currentColor" class="bi bi-question-circle-fill" viewBox="0 0 16 16" data-attribution="https://icons.getbootstrap.com/icons/question-circle/">
29                     <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247zm2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/>
30                     </svg>
31                 </a>
32       
33             </div>
34         </summary>
35     {{ $md | markdownify }}
36     </details>
37 </div>