1
1
package serverHandler
2
2
3
- import "html/template"
4
-
5
3
type dirSort int
6
4
7
5
const (
@@ -15,34 +13,42 @@ type SortState struct {
15
13
key byte
16
14
}
17
15
18
- func (info SortState ) mergeDirWithKey (key byte ) template.HTML {
16
+ func (info SortState ) DirSort () dirSort {
17
+ return info .dirSort
18
+ }
19
+
20
+ func (info SortState ) Key () string {
21
+ return string (info .key )
22
+ }
23
+
24
+ func (info SortState ) mergeDirWithKey (key byte ) string {
19
25
switch info .dirSort {
20
26
case dirSortFirst :
21
- return "/" + template . HTML (key )
27
+ return "/" + string (key )
22
28
case dirSortLast :
23
- return template . HTML (key ) + "/"
29
+ return string (key ) + "/"
24
30
default :
25
- return template . HTML (key )
31
+ return string (key )
26
32
}
27
33
}
28
34
29
- func (info SortState ) CurrentSort () template. HTML {
35
+ func (info SortState ) CurrentSort () string {
30
36
return info .mergeDirWithKey (info .key )
31
37
}
32
38
33
- func (info SortState ) NextDirSort () template. HTML {
39
+ func (info SortState ) NextDirSort () string {
34
40
switch info .dirSort {
35
41
case dirSortFirst : // next is dirSortLast
36
- return template . HTML (info .key ) + "/"
42
+ return string (info .key ) + "/"
37
43
case dirSortLast : // next is dirSortMixed
38
- return template . HTML (info .key )
44
+ return string (info .key )
39
45
case dirSortMixed : // next is dirSortFirst
40
- return "/" + template . HTML (info .key )
46
+ return "/" + string (info .key )
41
47
}
42
- return "/" + template . HTML (info .key )
48
+ return "/" + string (info .key )
43
49
}
44
50
45
- func (info SortState ) NextNameSort () template. HTML {
51
+ func (info SortState ) NextNameSort () string {
46
52
var nextKey byte
47
53
switch info .key {
48
54
case 'n' :
@@ -53,7 +59,7 @@ func (info SortState) NextNameSort() template.HTML {
53
59
return info .mergeDirWithKey (nextKey )
54
60
}
55
61
56
- func (info SortState ) NextSizeSort () template. HTML {
62
+ func (info SortState ) NextSizeSort () string {
57
63
var nextKey byte
58
64
switch info .key {
59
65
case 's' :
@@ -64,7 +70,7 @@ func (info SortState) NextSizeSort() template.HTML {
64
70
return info .mergeDirWithKey (nextKey )
65
71
}
66
72
67
- func (info SortState ) NextTimeSort () template. HTML {
73
+ func (info SortState ) NextTimeSort () string {
68
74
var nextKey byte
69
75
switch info .key {
70
76
case 't' :
@@ -74,11 +80,3 @@ func (info SortState) NextTimeSort() template.HTML {
74
80
}
75
81
return info .mergeDirWithKey (nextKey )
76
82
}
77
-
78
- func (info SortState ) DirSort () dirSort {
79
- return info .dirSort
80
- }
81
-
82
- func (info SortState ) Key () template.HTML {
83
- return template .HTML (info .key )
84
- }
0 commit comments