Skip to content

Commit dae32eb

Browse files
committed
refactor(tpl): simplify sub item class name
BREAKING CHANGE Sub items' class names of a directory are changed. This may break external customized templates. Before: Class names are on <a> elements, which are children of <li> elements. directory class names: "item", "item-dir" file class names: "item", "item-file" After: Class names are on <li> elements. directory class name: "dir" file class name: "file"
1 parent f06da90 commit dae32eb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/tpl/page.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<link rel="stylesheet" type="text/css" href="{{.RootRelPath}}/../assert/main.css"/>
1414
</head>
15-
<body>
15+
<body class="{{if .IsRoot}}root-dir{{else}}sub-dir{{end}}">
1616

1717
<ol class="path-list">
1818
{{range .Paths}}
@@ -38,18 +38,18 @@
3838
{{end}}
3939

4040
<ul class="item-list">
41-
<li>
41+
<li class="dir parent">
4242
<a href="{{if .IsRoot}}./{{else}}../{{end}}">
4343
<span class="name">../</span>
4444
<span class="size"></span>
4545
<span class="time"></span>
4646
</a>
4747
</li>
4848
{{range .SubItems}}
49-
{{$isDir := .IsDir}}
50-
<li>
51-
<a href="{{$subItemPrefix}}{{.Name}}{{if $isDir}}/{{end}}" class="item {{if $isDir}}item-dir{{else}}item-file{{end}}">
52-
<span class="name">{{fmtFilename .Name}}{{if $isDir}}/{{end}}</span>
49+
{{$isDir := .IsDir}}{{$subItemName := .Name}}
50+
<li class="{{if $isDir}}dir{{else}}file{{end}}">
51+
<a href="{{$subItemPrefix}}{{$subItemName}}{{if $isDir}}/{{end}}">
52+
<span class="name">{{fmtFilename $subItemName}}{{if $isDir}}/{{end}}</span>
5353
<span class="size">{{if not $isDir}}{{fmtSize .Size}}{{end}}</span>
5454
<span class="time">{{fmtTime .ModTime}}</span>
5555
</a>

src/tpl/page.html.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const pageTplStr = `
2121
<title>{{.Path}}</title>
2222
<link rel="stylesheet" type="text/css" href="{{.RootRelPath}}?assert=main.css"/>
2323
</head>
24-
<body>
24+
<body class="{{if .IsRoot}}root-dir{{else}}sub-dir{{end}}">
2525
<ol class="path-list">
2626
{{range .Paths}}
2727
<li><a href="{{.Path}}">{{.Name}}</a></li>
@@ -43,18 +43,18 @@ const pageTplStr = `
4343
</div>
4444
{{end}}
4545
<ul class="item-list">
46-
<li>
46+
<li class="dir parent">
4747
<a href="{{if .IsRoot}}./{{else}}../{{end}}">
4848
<span class="name">../</span>
4949
<span class="size"></span>
5050
<span class="time"></span>
5151
</a>
5252
</li>
5353
{{range .SubItems}}
54-
{{$isDir := .IsDir}}
55-
<li>
56-
<a href="{{$subItemPrefix}}{{.Name}}{{if $isDir}}/{{end}}" class="item {{if $isDir}}item-dir{{else}}item-file{{end}}">
57-
<span class="name">{{fmtFilename .Name}}{{if $isDir}}/{{end}}</span>
54+
{{$isDir := .IsDir}}{{$subItemName := .Name}}
55+
<li class="{{if $isDir}}dir{{else}}file{{end}}">
56+
<a href="{{$subItemPrefix}}{{$subItemName}}{{if $isDir}}/{{end}}">
57+
<span class="name">{{fmtFilename $subItemName}}{{if $isDir}}/{{end}}</span>
5858
<span class="size">{{if not $isDir}}{{fmtSize .Size}}{{end}}</span>
5959
<span class="time">{{fmtTime .ModTime}}</span>
6060
</a>

0 commit comments

Comments
 (0)