improve error handling at page
parent
6bc5b881d6
commit
7493a2d3f9
|
@ -20,7 +20,7 @@
|
|||
{{ $lnk := .PreviousLink }}
|
||||
{{ if ne $lnk ""}}<a href="{{ if eq $lnk "/" }}/{{else }}../../{{.PreviousLink}}{{ end }}"><div class="action" id="prev"><i class="material-icons">subdirectory_arrow_left</i></div></a>{{ else }}
|
||||
<div class="action disabled" id="prev"><i class="material-icons">subdirectory_arrow_left</i></div>{{ end }}
|
||||
<p><a href="{{ if eq .Config.BaseURL "" }}/{{ else }}{{ .Config.BaseURL }}{{ end }}">File Manager</a> {{ if ne .Name "/"}}<i class="material-icons">chevron_right</i> {{ .Name }}</p>{{ end }}
|
||||
<p><a href="{{ if eq .Config.BaseURL "" }}/{{ else }}{{ .Config.BaseURL }}{{ end }}">{{ if .Config.HugoEnabled }}Hugo{{ else }}File Manager{{ end }}</a> {{ if ne .Name "/"}}<i class="material-icons">chevron_right</i> {{ .Name }}</p>{{ end }}
|
||||
</div>
|
||||
<div>
|
||||
{{ if .IsDir}}
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
{{ if .Config.HugoEnabled }}
|
||||
<!-- Hugo plugin stuff -->
|
||||
<div class="action" id="settings"><i class="material-icons">settings</i></div>
|
||||
<a href="{{ .Config.BaseURL }}/settings"><div class="action"><i class="material-icons">settings</i></div></a>
|
||||
<div class="action" id="logout"><i class="material-icons">exit_to_app</i></div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
|
|
@ -133,7 +133,7 @@ func templatesActionsTmpl() (*asset, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
var _templatesBaseTmpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x56\x51\x8f\xdb\x36\x0c\x7e\xbe\x01\xfb\x0f\xaa\x30\x20\x0f\xab\xad\x0c\xd8\x5e\x0e\x76\x06\xec\xae\xc3\x0a\xb4\x5b\xd1\xdb\x30\xec\x29\x50\x6c\xda\x56\x2b\x4b\x9e\x24\xe7\x1a\x04\xf9\xef\xa3\x64\x39\xc9\x39\x8d\xd1\x0e\x57\x14\x38\xc7\xa4\x3e\x92\x1f\xf9\xd1\xca\x5e\xdc\xff\x71\xf7\xe7\x3f\xef\x5e\x91\xc6\xb5\x72\xf5\xed\x37\x59\xfc\x7b\x93\x35\xc0\x4b\xff\x70\x93\x39\xe1\x24\xac\xf6\xfb\xf4\x77\xde\xc2\xe1\x90\xb1\xe1\x45\xb0\xb5\xe0\x38\x51\xf8\x3e\xa7\x5b\x01\x8f\x9d\x36\x8e\x92\x42\x2b\x07\xca\xe5\xf4\x51\x94\xae\xc9\x4b\xd8\x8a\x02\x92\xf0\xe3\x25\x11\x4a\x38\xc1\x65\x62\x0b\x2e\x21\xff\x21\x5d\xd2\x80\x74\x93\x49\xa1\x3e\x92\xc6\x40\x95\xd3\xc6\xb9\xce\xde\x32\x56\x21\x90\x4d\x6b\xad\x6b\x09\xbc\x13\x36\x2d\x74\xcb\x04\xc2\xff\x5c\xf1\x56\xc8\x5d\xfe\x96\x3b\x30\x88\xf6\xfd\x6b\x7c\x69\x29\x31\x20\x73\x6a\xdd\x4e\x82\x6d\x00\xdc\x25\xf4\x62\x16\xba\xb0\x76\x44\x7e\xaf\x37\xda\xe9\xdb\x1f\x97\xcb\x97\x3f\x2d\x97\x8b\x80\xbc\x38\x21\x2f\x88\xdb\x75\x90\x2f\x1c\x7c\x72\xfe\xd8\x22\x44\x22\x64\x08\x35\x4d\x23\x96\xb5\xdf\x93\xf4\x4e\xab\x4a\xd4\xe9\x2f\xdc\xc2\x5f\xef\xdf\x90\xc3\x81\xad\x2b\x21\xa1\xe5\x8a\xd7\x58\x0a\x12\x67\x14\x97\x1e\x92\x0d\x00\x29\x3e\x8e\x75\xd8\xc2\x88\xce\x11\x6b\x8a\xaf\x02\xfb\x60\x19\xef\x3a\x29\x0a\xee\x84\x56\xe9\x07\xc4\xcb\xd8\x80\x35\x00\x23\x96\xa8\x88\x82\x23\xe2\x83\x0f\xfd\xe0\x73\x27\x94\x22\x6e\x16\x72\x59\x9d\xc5\x3c\x79\xf8\x89\x38\x9a\x41\x95\xe8\x7e\x06\x3a\xfa\xff\xd6\xd7\xfa\x95\xe2\x1b\x09\x47\x87\x9b\xec\x45\x92\x10\x6f\x20\x9d\xec\x6b\xa1\x88\x75\x7d\x55\x91\x24\x59\x45\xfb\xff\x20\xb3\x41\xb8\x79\x16\xbf\x88\xc6\x27\x30\x5f\xc2\xdf\xb1\xf0\x8c\x8d\xca\xc9\x36\xba\xdc\xe1\x03\xc1\x7f\x41\x4e\x60\x62\x1f\x4b\xb1\x8d\xb9\xe0\xc9\xef\x24\x16\x79\x9b\x93\xf4\x9d\x41\xa1\xe8\xde\xbe\xf1\x55\x8f\x1c\x1d\x5b\x13\xdc\x28\x45\xb6\xf9\x89\x01\x34\xc1\xbf\xd1\xc4\x7c\xa3\xd8\x7e\x0f\xd2\x02\x3e\xa5\x29\xc3\xff\xa8\xda\x73\xd8\xc3\xe1\x98\x2a\xd6\x80\x69\x90\x42\x72\x6b\x73\xca\x0b\x5f\x1a\x25\xa2\xcc\x69\x87\x07\xd0\x2a\x46\x5b\x1b\x45\x96\x88\x20\xb2\x95\xed\x37\xa5\x30\x50\x38\x6d\x76\x6b\x6e\x8c\x7e\x5c\x4b\xa8\x5c\xc6\x04\xd2\xe2\x4b\xcb\x18\x0f\xb3\x30\x24\x12\x49\xbf\x08\x46\x4a\x61\xc3\x3c\x3c\x53\xd4\xa7\xd3\x77\x93\x75\xab\x4b\xa6\xa6\xad\xa6\x91\xb3\x31\xd7\xcf\x4e\xc3\x19\x65\xbf\xa2\xba\xc8\xdb\x41\x5e\xbe\x4a\x72\x52\x8e\x5f\x8e\xbe\x09\xd8\xa0\xab\x35\x14\x0d\x6c\x8d\x56\x6b\x23\xea\x26\x64\xee\xcf\x0f\x27\xbd\x8a\xba\x49\x0d\x43\x5d\x93\x91\x89\xb2\x7a\x6d\xef\x85\x19\xfd\x2a\x6d\xda\x71\xb8\xaf\x13\x08\xdc\x14\x4d\x88\x9a\x09\xd5\xf5\x6e\x58\x61\xd4\xaf\x30\x8a\x0a\xe4\x05\x34\x5a\xe2\x90\xe6\xf4\x21\xb8\x8e\x5b\x87\x9d\xe0\xaf\x8d\x8c\xdf\xfd\x73\xcd\xf3\xf6\xb5\x97\x00\x2a\x1a\x4e\x2d\x9b\xc5\xec\x3b\xa9\x79\x39\x87\xea\x77\xdd\x7a\x70\x9b\x60\x4e\xa6\x0f\x7f\x3a\x68\xb1\x44\x87\x2d\x1a\x62\xe0\xc7\x22\x3d\x33\x8f\xac\x3f\xcf\xe6\x42\xbd\x5f\x29\xca\x82\x73\x42\xd5\x76\x76\xd2\xa3\xcf\xa4\xa6\xeb\xa0\x52\xd7\xba\x77\x73\x90\xf0\x49\xb8\xb5\xd3\x6b\x5c\x63\x9f\x61\xea\x72\xe2\xc2\xca\x62\xc7\x9d\xe5\x6d\xe7\x73\x17\xdd\x43\x3e\x3e\x01\xa7\xb5\xdc\x70\x43\x2f\xd6\xdb\xb5\x8c\x37\xbc\xf8\x38\x97\xef\xa0\x6f\xef\x35\x49\x37\xc8\xda\x76\x5c\x45\x36\x25\x2e\x04\x28\x13\xd5\xb7\x1b\xc0\xf8\x4b\xdc\xcb\x68\x5c\x91\xd1\x92\x7a\x55\x4d\xc5\x34\x3f\x0e\x27\xc7\x33\x6e\x02\x21\x2d\x17\x2a\x92\x43\xc8\x13\x90\x78\xe3\x41\x90\x7b\x8e\x17\xa2\xe3\x09\x16\x8f\x04\x8d\x6a\x37\x7e\x00\x1e\xc0\x6c\x71\x9a\x1e\x85\x6b\x08\x2e\xa9\xf0\x85\x53\x5a\x77\xa0\xc0\x10\xa5\x71\x67\x81\x31\x58\xcf\xe4\x3a\x54\xf0\xb2\xdc\x59\x7f\xd6\xf8\xeb\x0a\x5d\xdd\xf9\x17\x61\x0f\x71\xcc\xf3\x2b\x90\x6a\x8c\xdc\x6f\xc2\x9d\xa7\xe1\x45\x29\xb8\x1d\xc0\x93\xb3\xeb\xc3\xe5\xb6\x4b\xc9\x9c\x32\xfe\xf6\xd5\x70\x52\x49\xbe\xd5\xbd\x21\xba\x7a\xfe\x84\x7c\xc0\x90\xc8\x93\xa9\xf5\x0b\x6a\xe4\x36\x63\xf1\xa3\x8b\xd3\x3b\xdc\x64\xff\x0b\x00\x00\xff\xff\x20\x2b\x3d\x87\xe3\x0a\x00\x00")
|
||||
var _templatesBaseTmpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x56\xdf\x8b\xe3\x36\x10\x7e\x4e\xa1\xff\x83\x4e\x14\xf2\xd0\x8b\x95\x42\xfb\x72\xd8\x29\x74\xf7\x4a\x0f\xee\xda\xe3\xb6\xa5\xf4\x29\x28\xf6\xd8\xd6\x9d\x2c\xb9\x92\x9c\xbd\x10\xf2\xbf\x77\x24\xff\x88\xe3\x6c\xcc\x5d\xd9\x65\x21\xb6\x67\xf4\xcd\xcc\xa7\x99\x4f\x8a\x5f\xdc\xff\x71\xf7\xe7\x3f\xef\x5f\x93\xd2\x55\x72\xf3\xed\x37\x71\xf7\xbb\x88\x4b\xe0\x99\x7f\x58\xc4\x4e\x38\x09\x9b\xe3\x31\xfa\x9d\x57\x70\x3a\xc5\xac\xfd\x10\x6c\x15\x38\x4e\x14\x7e\x4f\xe8\x5e\xc0\x63\xad\x8d\xa3\x24\xd5\xca\x81\x72\x09\x7d\x14\x99\x2b\x93\x0c\xf6\x22\x85\x55\x78\x79\x49\x84\x12\x4e\x70\xb9\xb2\x29\x97\x90\xfc\x10\xad\x69\x40\x5a\xc4\x52\xa8\x4f\xa4\x34\x90\x27\xb4\x74\xae\xb6\xaf\x18\xcb\x11\xc8\x46\x85\xd6\x85\x04\x5e\x0b\x1b\xa5\xba\x62\x02\xe1\x7f\xce\x79\x25\xe4\x21\x79\xc7\x1d\x18\x44\xfb\xfe\x0d\x7e\xb4\x94\x18\x90\x09\xb5\xee\x20\xc1\x96\x00\xee\x1a\x7a\x39\x0b\x9d\x5a\xdb\x23\x7f\xd0\x3b\xed\xf4\xab\x1f\xd7\xeb\x97\x3f\xad\xd7\xcb\x80\xbc\x3c\x23\x2f\x89\x3b\xd4\x90\x2c\x1d\x7c\x76\x7e\xd9\x32\x44\x22\xa4\x0d\x35\x4d\xa3\x2b\xeb\x78\x24\xd1\x9d\x56\xb9\x28\xa2\x5f\xb8\x85\xbf\x3e\xbc\x25\xa7\x13\xdb\xe6\x42\x42\xc5\x15\x2f\xb0\x14\x24\xce\x28\x2e\x3d\x24\x6b\x01\x22\x7c\xec\xeb\xb0\xa9\x11\xb5\x23\xd6\xa4\x5f\x05\xf6\xd1\x32\x5e\xd7\x52\xa4\xdc\x09\xad\xa2\x8f\x88\x17\xb3\x16\xab\x05\x46\x2c\x91\x13\x05\x03\xe2\x83\x0f\xfd\xe0\x73\x27\x94\x22\x6e\x1c\x72\xd9\x8c\x62\x9e\x3d\x7c\x47\x0c\x66\x50\x19\xba\x8f\x40\x7b\xff\xdf\x9a\x42\xbf\x56\x7c\x27\x61\x70\x58\xc4\x2f\x56\x2b\xe2\x0d\xa4\x96\x4d\x21\x14\xb1\xae\xc9\x73\xb2\x5a\x6d\x3a\xfb\xff\x20\xb3\x44\xb8\x79\x16\xbf\x88\xc6\x0b\x98\x2f\xe1\x6f\x28\x3c\x66\xfd\xe4\xc4\x3b\x9d\x1d\xf0\x81\xe0\x5f\x18\x27\x30\xdd\x3e\x66\x62\xdf\xe5\x82\x2b\xbf\x93\x58\xe4\xab\x84\x44\xef\x0d\x0e\x8a\x6e\xec\x5b\x5f\x75\xcf\xd1\xb0\x35\xc1\x8d\x52\x64\x9b\x9f\x19\x40\x13\xfc\xdb\x99\x98\xdf\x28\x76\x3c\x82\xb4\x80\x4f\x51\xc4\xf0\x1f\xa7\x76\x0c\x7b\x3a\x0d\xa9\x62\x0d\x98\x06\x49\x25\xb7\x36\xa1\x3c\xf5\xa5\x51\x22\xb2\x84\xd6\xb8\x00\xad\xa2\xb7\x55\xdd\x90\xad\x44\x18\xb2\x8d\x6d\x76\x99\x30\x90\x3a\x6d\x0e\x5b\x6e\x8c\x7e\xdc\x4a\xc8\x5d\xcc\x04\xd2\xe2\x4b\x8b\x19\x0f\xbd\xd0\x26\xd2\x91\x7e\x15\x8c\x64\xc2\x86\x7e\x78\xa6\xa8\x97\xdd\xb7\x88\xeb\xcd\x35\x53\xd3\xad\xa6\x1d\x67\x7d\xae\x4f\x76\xc3\x88\xb2\xb9\x9e\xf6\x6f\x67\xa4\x5f\x71\x0e\xc9\xbb\x76\x10\x07\x00\x4f\x0c\x39\x0f\x9b\xd7\x53\xbf\x6f\x68\xb8\x59\x76\x5a\xc2\xde\x68\xb5\x35\xa2\x28\x43\xb1\x7e\x7d\xbb\xd2\xe3\xd5\x93\xb2\x5b\x2a\x26\x5d\xd6\x65\xfd\xc6\xde\x0b\xd3\xfb\xe5\xda\x54\xfd\x3c\xdc\xe6\x1c\xb8\x49\xcb\x10\x35\x16\xaa\x6e\x5c\xab\x7a\xd4\xab\x1e\xc5\xa1\xe5\x29\x94\x5a\x62\x5f\x27\xf4\x21\xb8\xf6\x42\xc5\xce\xf0\xb7\xba\xcc\x1f\x17\x73\xfb\xed\xed\x5b\x3f\x35\x28\x02\x70\xde\xe5\x59\xcc\xa6\x96\x9a\x67\x73\xa8\x5e\x1e\xb7\xad\xdb\x04\x73\xd2\xb0\xf8\xea\xa0\xc2\x12\x1d\x6e\x51\x1b\x03\xcf\x97\x68\x64\xee\x59\x7f\x1e\xb1\x43\x89\xe0\xb3\xca\x66\xc1\x39\xa1\x0a\xfb\xe4\xdc\xce\xcd\x4d\xb7\xee\x72\x3c\xfb\x98\x37\x88\x94\xba\xd0\x8d\x9b\x83\x85\xcf\xc2\x6d\x9d\xde\xa2\x30\x3e\x41\xe4\x75\x43\x06\x11\x64\x83\x0a\x7a\xdb\xb8\x2d\x3b\xf7\x90\x8f\x4f\xc0\x69\x2d\x77\xdc\xd0\x2b\xc1\xbc\x95\xf1\x8e\xa7\x9f\xe6\xf2\x6d\x15\xc3\x7b\x4d\xd2\x0d\x42\x61\x6b\xae\x02\x8c\x05\x89\x12\x03\xd9\x4a\x35\xd5\x0e\x30\xfe\x1a\x95\x1e\x8d\x1b\xd2\x5b\x22\x3f\x74\xd3\x59\x9b\xef\x96\xb3\xe3\x88\x9b\x40\x48\xc5\x85\xea\xc8\x21\xe4\x02\xa4\xbb\x43\x21\xc8\x3d\xc7\x2b\xd6\xb0\x82\x75\x4b\xc2\x08\x6b\xd7\x1f\x29\x0f\x60\xf6\xd8\x6c\x8f\xc2\x95\xbe\x91\xc2\x99\xa9\xb4\xae\x41\x81\x21\x4a\x63\x5f\x81\x31\x58\xcf\xe4\x82\x95\xf2\x2c\x3b\x58\xbf\xd6\xf8\x0b\x10\xdd\xdc\xf9\x0f\x41\xa6\x38\xe6\xf9\x15\x48\x05\x46\x6e\x76\xe1\x16\x55\xf2\x34\x13\xdc\xb6\xe0\xab\xd1\x85\x84\x6e\xc6\xaa\xe8\xa3\x44\x64\x6e\x70\xfe\xf6\xd5\x70\x92\x4b\xbe\xd7\x8d\x21\x3a\x7f\xfe\x84\x7c\xc0\x90\xc8\x45\xd7\x7a\xfd\xea\xb9\x8d\x59\x77\x8c\x63\xf7\xb6\x77\xe3\xff\x02\x00\x00\xff\xff\x30\x80\xac\x89\x35\x0b\x00\x00")
|
||||
|
||||
func templatesBaseTmplBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
|
@ -148,7 +148,7 @@ func templatesBaseTmpl() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "templates/base.tmpl", size: 2787, mode: os.FileMode(438), modTime: time.Unix(1466625777, 0)}
|
||||
info := bindataFileInfo{name: "templates/base.tmpl", size: 2869, mode: os.FileMode(438), modTime: time.Unix(1466626339, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
|
12
page.go
12
page.go
|
@ -1,6 +1,7 @@
|
|||
package filemanager
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"log"
|
||||
|
@ -100,18 +101,15 @@ func (p *Page) AddTemplate(name string, assets AssetFunc, functions template.Fun
|
|||
|
||||
// PrintAsHTML formats the page in HTML and executes the template
|
||||
func (p Page) PrintAsHTML(w http.ResponseWriter) (int, error) {
|
||||
// var buffer bytes.Buffer
|
||||
//writer := bufio.NewWriter(&buffer)
|
||||
err := p.Tpl.Execute(w, p.Info)
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
buf := &bytes.Buffer{}
|
||||
err := p.Tpl.Execute(buf, p.Info)
|
||||
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
// _, err = buffer.WriteTo(w)
|
||||
// w.Write(buffer.Bytes())
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
_, err = buf.WriteTo(w)
|
||||
return http.StatusOK, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue