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 {
1717 Path string `json:"path"`
1818}
1919
20- type subItemSort struct {
20+ type itemSort struct {
2121 Name []byte
2222}
2323
24- type subItemHtml struct {
24+ type itemHtml struct {
2525 IsDir bool
26+ Link string
2627 Name template.HTML
2728 Size template.HTML
2829 ModTime template.HTML
2930}
3031
3132type subItem struct {
32- sort subItemSort
33+ sort itemSort
3334
3435 Info os.FileInfo
35- Html * subItemHtml
36+ Html * itemHtml
3637}
3738
3839type responseData struct {
@@ -222,7 +223,7 @@ func getSubItems(subInfos []os.FileInfo) []*subItem {
222223 for i := 0 ; i < len (subInfos ); i ++ {
223224 info := subInfos [i ]
224225 subItems [i ] = & subItem {
225- sort : subItemSort {
226+ sort : itemSort {
226227 Name : []byte (info .Name ()),
227228 },
228229 Info : info ,
@@ -235,9 +236,11 @@ func getSubItems(subInfos []os.FileInfo) []*subItem {
235236func updateSubsItemHtml (subItems []* subItem ) {
236237 for _ , item := range subItems {
237238 info := item .Info
238- item .Html = & subItemHtml {
239+ name := info .Name ()
240+ item .Html = & itemHtml {
239241 IsDir : info .IsDir (),
240- Name : tplutil .FormatFilename (info .Name ()),
242+ Link : name ,
243+ Name : tplutil .FormatFilename (name ),
241244 Size : tplutil .FormatSize (info .Size ()),
242245 ModTime : tplutil .FormatTime (info .ModTime ()),
243246 }
Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ input, button {
4141 padding : 0.25em 0 ;
4242}
4343
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+
4452.path-list {
4553 font-size : 1.5em ;
4654 overflow : hidden;
@@ -191,14 +199,6 @@ input, button {
191199 word-break : break-all;
192200}
193201
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-
202202.item-list .size {
203203 white-space : nowrap;
204204 text-align : right;
Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ input, button {
3636margin: 0;
3737padding: 0.25em 0;
3838}
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+ }
3946.path-list {
4047font-size: 1.5em;
4148overflow: hidden;
@@ -165,13 +172,6 @@ font-size: 1.5em;
165172white-space: pre-wrap;
166173word-break: break-all;
167174}
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- }
175175.item-list .size {
176176white-space: nowrap;
177177text-align: right;
Original file line number Diff line number Diff line change 1616
1717< ol class ="path-list ">
1818 {{range .Paths}}
19- < li > < a href ="{{.Path}} "> {{.Name}}</ a > </ li >
19+ < li > < a href ="{{.Path}} "> {{fmtFilename .Name}}</ a > </ li >
2020 {{end}}
2121</ ol >
2222
4747 </ li >
4848 {{range .SubItems}}{{with .Html}}
4949 < li class ="{{if .IsDir}}dir{{else}}file{{end}} ">
50- < a href ="{{$subItemPrefix}}{{.Name }}{{if .IsDir}}/{{end}} ">
50+ < a href ="{{$subItemPrefix}}{{.Link }}{{if .IsDir}}/{{end}} ">
5151 < span class ="name "> {{.Name}}{{if .IsDir}}/{{end}}</ span >
5252 < span class ="size "> {{if not .IsDir}}{{.Size}}{{end}}</ span >
5353 < span class ="time "> {{.ModTime}}</ span >
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const pageTplStr = `
2424<body class="{{if .IsRoot}}root-dir{{else}}sub-dir{{end}}">
2525<ol class="path-list">
2626{{range .Paths}}
27- <li><a href="{{.Path}}">{{.Name}}</a></li>
27+ <li><a href="{{.Path}}">{{fmtFilename .Name}}</a></li>
2828{{end}}
2929</ol>
3030{{if .CanUpload}}
@@ -52,7 +52,7 @@ const pageTplStr = `
5252</li>
5353{{range .SubItems}}{{with .Html}}
5454<li class="{{if .IsDir}}dir{{else}}file{{end}}">
55- <a href="{{$subItemPrefix}}{{.Name }}{{if .IsDir}}/{{end}}">
55+ <a href="{{$subItemPrefix}}{{.Link }}{{if .IsDir}}/{{end}}">
5656<span class="name">{{.Name}}{{if .IsDir}}/{{end}}</span>
5757<span class="size">{{if not .IsDir}}{{.Size}}{{end}}</span>
5858<span class="time">{{.ModTime}}</span>
You can’t perform that action at this time.
0 commit comments