progresses on #5

pull/144/head
Henrique Dias 2016-07-01 10:01:31 +01:00
parent 9b92b17e1d
commit d294d1b116
6 changed files with 588 additions and 479 deletions

View File

@ -8,6 +8,7 @@
// assets/public/js/form2js.js
// assets/templates/actions.tmpl
// assets/templates/base.tmpl
// assets/templates/buttons.tmpl
// assets/templates/editor.tmpl
// assets/templates/frontmatter.tmpl
// assets/templates/listing.tmpl
@ -183,6 +184,24 @@ func templatesBaseTmpl() (*asset, error) {
return a, err
}
// templatesButtonsTmpl reads file data from disk. It returns an error on failure.
func templatesButtonsTmpl() (*asset, error) {
path := "D:\\Code\\Go\\src\\github.com\\hacdias\\caddy-filemanager\\assets\\templates\\buttons.tmpl"
name := "templates/buttons.tmpl"
bytes, err := bindataRead(path, name)
if err != nil {
return nil, err
}
fi, err := os.Stat(path)
if err != nil {
err = fmt.Errorf("Error reading asset info %s at %s: %v", name, path, err)
}
a := &asset{bytes: bytes, info: fi}
return a, err
}
// templatesEditorTmpl reads file data from disk. It returns an error on failure.
func templatesEditorTmpl() (*asset, error) {
path := "D:\\Code\\Go\\src\\github.com\\hacdias\\caddy-filemanager\\assets\\templates\\editor.tmpl"
@ -333,6 +352,7 @@ var _bindata = map[string]func() (*asset, error){
"public/js/form2js.js": publicJsForm2jsJs,
"templates/actions.tmpl": templatesActionsTmpl,
"templates/base.tmpl": templatesBaseTmpl,
"templates/buttons.tmpl": templatesButtonsTmpl,
"templates/editor.tmpl": templatesEditorTmpl,
"templates/frontmatter.tmpl": templatesFrontmatterTmpl,
"templates/listing.tmpl": templatesListingTmpl,
@ -395,6 +415,7 @@ var _bintree = &bintree{nil, map[string]*bintree{
"templates": &bintree{nil, map[string]*bintree{
"actions.tmpl": &bintree{templatesActionsTmpl, map[string]*bintree{}},
"base.tmpl": &bintree{templatesBaseTmpl, map[string]*bintree{}},
"buttons.tmpl": &bintree{templatesButtonsTmpl, map[string]*bintree{}},
"editor.tmpl": &bintree{templatesEditorTmpl, map[string]*bintree{}},
"frontmatter.tmpl": &bintree{templatesFrontmatterTmpl, map[string]*bintree{}},
"listing.tmpl": &bintree{templatesListingTmpl, map[string]*bintree{}},

File diff suppressed because it is too large Load Diff

View File

@ -357,11 +357,11 @@ var handleViewType = function(viewList) {
if (viewList == "true") {
listing.classList.add('list');
button.innerHTML = '<i class="material-icons">view_module</i>';
button.innerHTML = '<i class="material-icons">view_module</i> <span>Switch view</span>';
return false;
}
button.innerHTML = '<i class="material-icons">view_list</i>';
button.innerHTML = '<i class="material-icons">view_list</i> <span>Switch view</span>';
listing.classList.remove('list');
return false;
}
@ -766,6 +766,7 @@ document.addEventListener("editor", (event) => {
* BOOTSTRAP *
* *
* * * * * * * * * * * * * * * */
document.addEventListener("DOMContentLoaded", function(event) {
// Add event to logout button
document.getElementById("logout").addEventListener("click", event => {
@ -783,6 +784,9 @@ document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("open").addEventListener("click", openEvent);
document.getElementById("delete").addEventListener("click", deleteEvent);
document.getElementById("download").addEventListener("click", downloadEvent);
document.getElementById("open-nav").addEventListener("click", event => {
let sidebar = document.querySelector("header > div:nth-child(2)").classList.toggle("active");
});
if (document.getElementById('listing')) {
document.sendCostumEvent('listing');
@ -793,4 +797,4 @@ document.addEventListener("DOMContentLoaded", function(event) {
}
return false;
});
});

View File

@ -27,6 +27,10 @@
</a>
{{ end }}
<div class="action" id="open-nav">
<i class="material-icons">menu</i>
</div>
<p>
<a href="{{ if eq .Config.BaseURL "" }}/{{ else }}{{ .Config.BaseURL }}{{ end }}">
{{ if .Config.HugoEnabled }}Hugo{{ else }}File Manager{{ end }}
@ -38,27 +42,7 @@
</div>
<div>
{{ if .IsDir}}
<div id="search">
<i class="material-icons">storage</i>
<input type="text" placeholder="Execute a command...">
<div>Write your git, mercurial or svn command and press enter.</div>
</div>
<div class="action" id="view">
<i class="material-icons">view_headline</i>
</div>
<div class="action" id="upload">
<i class="material-icons">file_upload</i>
</div>
{{ else }}
{{ template "actions" . }}
{{ end }}
<div class="action" id="logout">
<i class="material-icons">exit_to_app</i>
</div>
{{ template "buttons" . }}
</div>
</header>

View File

@ -0,0 +1,23 @@
{{ define "buttons" }}
{{ if .IsDir}}
<div id="search">
<i class="material-icons">storage</i>
<input type="text" placeholder="Execute a command...">
<div>Write your git, mercurial or svn command and press enter.</div>
</div>
<div class="action" id="view">
<i class="material-icons">view_headline</i> <span>Switch view</span>
</div>
<div class="action" id="upload">
<i class="material-icons">file_upload</i> <span>Upload</span>
</div>
{{ else }}
{{ template "actions" . }}
{{ end }}
<div class="action" id="logout">
<i class="material-icons">exit_to_app</i> <span>Logout</span>
</div>
{{ end }}

View File

@ -82,7 +82,7 @@ func (p Page) PrintAsHTML(w http.ResponseWriter, templates ...string) (int, erro
if p.Minimal {
templates = append(templates, "actions", "minimal")
} else {
templates = append(templates, "actions", "base")
templates = append(templates, "buttons", "actions", "base")
}
var tpl *template.Template