Filesystem

/views/vfile/List.html (898 B)

 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
{% import (
"path/filepath"

"{{{ .Package }}}/app"
"{{{ .Package }}}/app/controller/cutil"
"{{{ .Package }}}/app/lib/filesystem"
"{{{ .Package }}}/views/components"
) %}

{% func List(path []string, files filesystem.FileInfos, fl filesystem.FileLoader, urlPrefix string, as *app.State, ps *cutil.PageState) %}
<h3><a href="{%s urlPrefix %}">.</a>{%- for idx, p := range path -%}/<a href="{%s urlPrefix %}/{%s filepath.Join(path[:idx + 1]...) %}">{%s p %}</a>{%- endfor -%}</h3>
<div class="mt">
{%- for _, f := range files -%}
{%- code
icon := "file"
if f.IsDir {
icon = "folder"
}
x := []string{urlPrefix}
x = append(x, path...)
x = append(x, f.Name)
u := filepath.Join(x...)
-%}
<div><a href="{%s u %}">{%= components.SVGRef(icon, 16, 16, `icon`, ps) %}{%s f.Name %}</a></div>
{%- endfor -%}
</div>
{% endfunc %}