File tree Expand file tree Collapse file tree 5 files changed +29
-26
lines changed Expand file tree Collapse file tree 5 files changed +29
-26
lines changed Original file line number Diff line number Diff line change @@ -17,22 +17,23 @@ type pathEntry struct {
17
17
Path string `json:"path"`
18
18
}
19
19
20
- type subItemSort struct {
20
+ type itemSort struct {
21
21
Name []byte
22
22
}
23
23
24
- type subItemHtml struct {
24
+ type itemHtml struct {
25
25
IsDir bool
26
+ Link string
26
27
Name template.HTML
27
28
Size template.HTML
28
29
ModTime template.HTML
29
30
}
30
31
31
32
type subItem struct {
32
- sort subItemSort
33
+ sort itemSort
33
34
34
35
Info os.FileInfo
35
- Html * subItemHtml
36
+ Html * itemHtml
36
37
}
37
38
38
39
type responseData struct {
@@ -222,7 +223,7 @@ func getSubItems(subInfos []os.FileInfo) []*subItem {
222
223
for i := 0 ; i < len (subInfos ); i ++ {
223
224
info := subInfos [i ]
224
225
subItems [i ] = & subItem {
225
- sort : subItemSort {
226
+ sort : itemSort {
226
227
Name : []byte (info .Name ()),
227
228
},
228
229
Info : info ,
@@ -235,9 +236,11 @@ func getSubItems(subInfos []os.FileInfo) []*subItem {
235
236
func updateSubsItemHtml (subItems []* subItem ) {
236
237
for _ , item := range subItems {
237
238
info := item .Info
238
- item .Html = & subItemHtml {
239
+ name := info .Name ()
240
+ item .Html = & itemHtml {
239
241
IsDir : info .IsDir (),
240
- Name : tplutil .FormatFilename (info .Name ()),
242
+ Link : name ,
243
+ Name : tplutil .FormatFilename (name ),
241
244
Size : tplutil .FormatSize (info .Size ()),
242
245
ModTime : tplutil .FormatTime (info .ModTime ()),
243
246
}
Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ input, button {
41
41
padding : 0.25em 0 ;
42
42
}
43
43
44
+ em {
45
+ font-style : normal;
46
+ font-weight : normal;
47
+ padding : 0 0.2em ;
48
+ border : 1px # ddd solid;
49
+ border-radius : 3px ;
50
+ }
51
+
44
52
.path-list {
45
53
font-size : 1.5em ;
46
54
overflow : hidden;
@@ -191,14 +199,6 @@ input, button {
191
199
word-break : break-all;
192
200
}
193
201
194
- .item-list .name em {
195
- font-style : normal;
196
- font-weight : normal;
197
- padding : 0 0.2em ;
198
- border : 1px # ddd solid;
199
- border-radius : 3px ;
200
- }
201
-
202
202
.item-list .size {
203
203
white-space : nowrap;
204
204
text-align : right;
Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ input, button {
36
36
margin: 0;
37
37
padding: 0.25em 0;
38
38
}
39
+ em {
40
+ font-style: normal;
41
+ font-weight: normal;
42
+ padding: 0 0.2em;
43
+ border: 1px #ddd solid;
44
+ border-radius: 3px;
45
+ }
39
46
.path-list {
40
47
font-size: 1.5em;
41
48
overflow: hidden;
@@ -165,13 +172,6 @@ font-size: 1.5em;
165
172
white-space: pre-wrap;
166
173
word-break: break-all;
167
174
}
168
- .item-list .name em {
169
- font-style: normal;
170
- font-weight: normal;
171
- padding: 0 0.2em;
172
- border: 1px #ddd solid;
173
- border-radius: 3px;
174
- }
175
175
.item-list .size {
176
176
white-space: nowrap;
177
177
text-align: right;
Original file line number Diff line number Diff line change 16
16
17
17
< ol class ="path-list ">
18
18
{{range .Paths}}
19
- < li > < a href ="{{.Path}} "> {{.Name}}</ a > </ li >
19
+ < li > < a href ="{{.Path}} "> {{fmtFilename .Name}}</ a > </ li >
20
20
{{end}}
21
21
</ ol >
22
22
47
47
</ li >
48
48
{{range .SubItems}}{{with .Html}}
49
49
< li class ="{{if .IsDir}}dir{{else}}file{{end}} ">
50
- < a href ="{{$subItemPrefix}}{{.Name }}{{if .IsDir}}/{{end}} ">
50
+ < a href ="{{$subItemPrefix}}{{.Link }}{{if .IsDir}}/{{end}} ">
51
51
< span class ="name "> {{.Name}}{{if .IsDir}}/{{end}}</ span >
52
52
< span class ="size "> {{if not .IsDir}}{{.Size}}{{end}}</ span >
53
53
< span class ="time "> {{.ModTime}}</ span >
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const pageTplStr = `
24
24
<body class="{{if .IsRoot}}root-dir{{else}}sub-dir{{end}}">
25
25
<ol class="path-list">
26
26
{{range .Paths}}
27
- <li><a href="{{.Path}}">{{.Name}}</a></li>
27
+ <li><a href="{{.Path}}">{{fmtFilename .Name}}</a></li>
28
28
{{end}}
29
29
</ol>
30
30
{{if .CanUpload}}
@@ -52,7 +52,7 @@ const pageTplStr = `
52
52
</li>
53
53
{{range .SubItems}}{{with .Html}}
54
54
<li class="{{if .IsDir}}dir{{else}}file{{end}}">
55
- <a href="{{$subItemPrefix}}{{.Name }}{{if .IsDir}}/{{end}}">
55
+ <a href="{{$subItemPrefix}}{{.Link }}{{if .IsDir}}/{{end}}">
56
56
<span class="name">{{.Name}}{{if .IsDir}}/{{end}}</span>
57
57
<span class="size">{{if not .IsDir}}{{.Size}}{{end}}</span>
58
58
<span class="time">{{.ModTime}}</span>
You can’t perform that action at this time.
0 commit comments