made the file index work on phones
This commit is contained in:
parent
581d3e6da5
commit
523e519a3b
3 changed files with 36 additions and 5 deletions
|
|
@ -48,6 +48,13 @@ footer {
|
|||
color: #666;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
body {
|
||||
padding: 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -139,20 +139,36 @@ footer a:hover {
|
|||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 430px) {
|
||||
body {
|
||||
padding: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.ty {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="crumbs">{{range $i, $c := .Crumbs}}{{if $i}} / {{end}}<a href="{{$c.URL}}">{{$c.Name}}</a>{{end}}</nav>
|
||||
<div class="wrap">
|
||||
<table>
|
||||
<thead><tr>{{range .Headers}}<th><a href="{{.URL}}">{{.Label}}{{if .Active}}{{if .Desc}} ▼{{else}} ▲{{end}}{{end}}</a></th>{{end}}</tr></thead>
|
||||
<thead><tr>{{range .Headers}}<th{{if .Class}} class="{{.Class}}"{{end}}><a href="{{.URL}}">{{.Label}}{{if .Active}}{{if .Desc}} ▼{{else}} ▲{{end}}{{end}}</a></th>{{end}}</tr></thead>
|
||||
<tbody>
|
||||
{{if .HasParent}}<tr><td><a href="../">../</a></td><td class="num">-</td><td class="num"></td><td class="num mod"></td></tr>{{end}}
|
||||
{{if .HasParent}}<tr><td><a href="../">../</a></td><td class="num ty">-</td><td class="num sz"></td><td class="num mod"></td></tr>{{end}}
|
||||
{{range .Rows}}
|
||||
<tr{{if .IsDir}} class="dir"{{end}}>
|
||||
<td><a href="{{.URL}}"{{if not .IsDir}} download{{end}}>{{.Name}}</a></td>
|
||||
<td class="num">{{.Type}}</td>
|
||||
<td class="num">{{if .IsDir}}-{{else}}{{.SizeS}}{{end}}</td>
|
||||
<td class="num ty">{{.Type}}</td>
|
||||
<td class="num sz">{{if .IsDir}}-{{else}}{{.SizeS}}{{end}}</td>
|
||||
<td class="num mod">{{.ModS}}</td>
|
||||
</tr>
|
||||
{{else}}<tr><td colspan="4" class="empty">empty directory</td></tr>{{end}}
|
||||
|
|
|
|||
10
server.go
10
server.go
|
|
@ -61,6 +61,7 @@ func (r row) ModS() string { return r.ModTime.Format("2006-01-02 15:04") }
|
|||
|
||||
type headerCol struct {
|
||||
Label string
|
||||
Class string
|
||||
URL string
|
||||
Active bool
|
||||
Desc bool
|
||||
|
|
@ -226,11 +227,18 @@ func (s *server) serveListing(w http.ResponseWriter, r *http.Request, dirPath, u
|
|||
headers := []struct {
|
||||
Label string
|
||||
Key string
|
||||
}{{"Name", "name"}, {"Type", "type"}, {"Size", "size"}, {"Modified", "modified"}}
|
||||
Class string
|
||||
}{
|
||||
{"Name", "name", ""},
|
||||
{"Type", "type", "ty"},
|
||||
{"Size", "size", "sz"},
|
||||
{"Modified", "modified", "mod"},
|
||||
}
|
||||
cols := make([]headerCol, len(headers))
|
||||
for i, h := range headers {
|
||||
cols[i] = headerCol{
|
||||
Label: h.Label,
|
||||
Class: h.Class,
|
||||
Active: h.Key == sortKey,
|
||||
Desc: h.Key == sortKey && desc,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue