pull/144/head
Henrique Dias 2016-08-21 20:10:12 +01:00
parent 63184da48f
commit b9ca7e2a9c
10 changed files with 134 additions and 97 deletions

View File

@ -400,6 +400,16 @@ pre {
border: 1px solid #e6e6e6;
border-radius: 0.5em;
background-color: #f5f5f5;
white-space: pre-wrap;
/* css-3 */
white-space: -moz-pre-wrap;
/* Mozilla, since 1999 */
white-space: -pre-wrap;
/* Opera 4-6 */
white-space: -o-pre-wrap;
/* Opera 7 */
word-wrap: break-word;
/* Internet Explorer 5.5+ */
}
@media (max-width: 600px) {
@ -1107,4 +1117,4 @@ i.spin {
column-count: 1;
column-gap: 0;
}
}
}

View File

@ -509,62 +509,73 @@ document.addEventListener('listing', event => {
}
});
document.querySelector('#search input').addEventListener('focus', event => {
document.getElementById('search').classList.add('active');
});
document.querySelector('#search input').addEventListener('blur', event => {
document.getElementById('search').classList.remove('active');
document.querySelector('#search input').value = '';
});
document.querySelector('#search input').addEventListener('keyup', searchEvent);
// Enables upload button
document.getElementById("upload").addEventListener("click", (event) => {
document.getElementById("upload-input").click();
});
// Enables rename button
document.getElementById("rename").addEventListener("click", renameEvent);
document.getElementById('new').addEventListener('click', event => {
let newdir = document.getElementById('newdir');
newdir.classList.add('enabled');
newdir.focus();
});
document.getElementById('newdir').addEventListener('blur', event => {
document.getElementById('newdir').classList.remove('enabled');
});
document.getElementById('newdir').addEventListener('keydown', newDirEvent);
// Drag and Drop
let items = document.getElementsByClassName('item');
document.addEventListener("dragover", function(event) {
event.preventDefault();
}, false);
document.addEventListener("dragover", (event) => {
Array.from(items).forEach(file => {
file.style.opacity = 0.5;
if (document.getElementById('search')) {
document.querySelector('#search input').addEventListener('focus', event => {
document.getElementById('search').classList.add('active');
});
}, false);
document.addEventListener("dragleave", (event) => {
Array.from(items).forEach(file => {
file.style.opacity = 1;
document.querySelector('#search input').addEventListener('blur', event => {
document.getElementById('search').classList.remove('active');
document.querySelector('#search input').value = '';
});
}, false);
document.addEventListener("drop", function(event) {
event.preventDefault();
var dt = event.dataTransfer;
var files = dt.files;
document.querySelector('#search input').addEventListener('keyup', searchEvent);
}
handleFiles(files);
}, false);
if (document.getElementById("upload")) {
// Enables upload button
document.getElementById("upload").addEventListener("click", (event) => {
document.getElementById("upload-input").click();
});
}
if (document.getElementById("rename")) {
// Enables rename button
document.getElementById("rename").addEventListener("click", renameEvent);
}
if (document.getElementById('new')) {
document.getElementById('new').addEventListener('click', event => {
let newdir = document.getElementById('newdir');
newdir.classList.add('enabled');
newdir.focus();
});
}
if (document.getElementById('newdir')) {
document.getElementById('newdir').addEventListener('blur', event => {
document.getElementById('newdir').classList.remove('enabled');
});
document.getElementById('newdir').addEventListener('keydown', newDirEvent);
// Drag and Drop
let items = document.getElementsByClassName('item');
document.addEventListener("dragover", function(event) {
event.preventDefault();
}, false);
document.addEventListener("dragover", (event) => {
Array.from(items).forEach(file => {
file.style.opacity = 0.5;
});
}, false);
document.addEventListener("dragleave", (event) => {
Array.from(items).forEach(file => {
file.style.opacity = 1;
});
}, false);
document.addEventListener("drop", function(event) {
event.preventDefault();
var dt = event.dataTransfer;
var files = dt.files;
handleFiles(files);
}, false);
}
});
/* * * * * * * * * * * * * * * *
@ -833,7 +844,11 @@ document.addEventListener("DOMContentLoaded", function(event) {
// Enables open, delete and download buttons
document.getElementById("open").addEventListener("click", openEvent);
document.getElementById("delete").addEventListener("click", deleteEvent);
if (document.getElementById("delete")) {
document.getElementById("delete").addEventListener("click", deleteEvent);
}
document.getElementById("download").addEventListener("click", downloadEvent);
document.getElementById("open-nav").addEventListener("click", event => {
document.querySelector("header > div:nth-child(2)").classList.toggle("active");

View File

@ -2,7 +2,7 @@
<div class="action" id="open">
<i class="material-icons" title="See raw">open_in_new</i> <span>See raw</span>
</div>
{{ if .IsDir }}
{{ if and .IsDir .User.AllowEdit }}
<div class="action" id="rename">
<i class="material-icons" title="Edit">mode_edit</i>
</div>
@ -10,7 +10,9 @@
<div class="action" id="download">
<i class="material-icons" title="Download">file_download</i> <span>Download</span>
</div>
{{ if .User.AllowEdit }}
<div class="action" id="delete">
<i class="material-icons" title="Delete">delete</i> <span>Delete</span>
</div>
{{ end }}
{{ end }}

View File

@ -63,18 +63,22 @@
{{ if .IsDir}}
{{ if .User.AllowCommands }}
<div id="search">
<i class="material-icons" title="Storage">storage</i>
<input type="text" placeholder="Execute a command...">
<div>Write your git, mercurial or svn command and press enter.</div>
</div>
{{ end }}
<div class="action" id="view">
<i class="material-icons" title="Switch view">view_headline</i> <span>Switch view</span>
</div>
{{ if .User.AllowNew }}
<div class="action" id="upload">
<i class="material-icons" title="Upload">file_upload</i> <span>Upload</span>
</div>
{{ end }}
{{ else }}
{{ template "actions" . }}
{{ end }}
@ -103,7 +107,7 @@
{{ end }}
<main>
{{ template "content" .Data }}
{{ template "content" . }}
<span id="token">{{ .Config.Token }}</span>
</main>

View File

@ -1,4 +1,5 @@
{{ define "content" }}
{{ with .Data }}
<div id="editor" class="container" data-kind="{{ .Class }}">
<form method="POST" action="./">
{{ if or (eq .Class "frontmatter-only") (eq .Class "complete") }}
@ -30,3 +31,4 @@
</form>
</div>
{{ end }}
{{ end }}

View File

@ -1,42 +1,46 @@
{{ define "content" }}
<div class="listing">
<div class="container" id="listing">
{{- range .Items}}
<div class="item" data-dir="{{- if .IsDir}}true{{ else }}false{{ end }}" id="{{.URL}}">
<div>
<a href="{{.URL}}">
{{- if .IsDir}}
<i class="material-icons">folder</i>
{{- else}}
<i class="material-icons">insert_drive_file</i>
{{- end}}
</a>
</div>
<div>
<a href="{{.URL}}">
<span class="name">{{.Name}}</span>
{{- if .IsDir}}
<p data-order="-1">&mdash;</p>
{{- else}}
<p data-order="{{.Size}}">{{.HumanSize}}</p>
{{- end}}
<p>
<time datetime="{{.HumanModTime " 2006-01-02T15:04:05Z"}}">{{.HumanModTime "01/02/2006 03:04:05 PM -07:00"}}</time>
</p>
</a>
</div>
<span class="checkbox" data-href="{{.URL}}"><i class="material-icons">check</i></div>
{{ with .Data }}
<div class="listing">
<div class="container" id="listing">
{{- range .Items}}
<div class="item" data-dir="{{- if .IsDir}}true{{ else }}false{{ end }}" id="{{.URL}}">
<div>
<a href="{{.URL}}">
{{- if .IsDir}}
<i class="material-icons">folder</i>
{{- else}}
<i class="material-icons">insert_drive_file</i>
{{- end}}
</a>
</div>
<div>
<a href="{{.URL}}">
<span class="name">{{.Name}}</span>
{{- if .IsDir}}
<p data-order="-1">&mdash;</p>
{{- else}}
<p data-order="{{.Size}}">{{.HumanSize}}</p>
{{- end}}
<p>
<time datetime="{{.HumanModTime " 2006-01-02T15:04:05Z"}}">{{.HumanModTime "01/02/2006 03:04:05 PM -07:00"}}</time>
</p>
</a>
</div>
<span class="checkbox" data-href="{{.URL}}"><i class="material-icons">check</i>
</div>
{{- end}}
</div>
</div>
</div>
</div>
<input style="display:none" type="file" id="upload-input" onchange="handleFiles(this.files)" value="Upload" multiple>
<input style="display:none" type="file" id="upload-input" onchange="handleFiles(this.files)" value="Upload" multiple>
{{ end }}
{{ if .User.AllowNew }}
<input id="newdir" type="text" placeholder="Name...">
<div class="floating">
<div class="action" id="new">
<i class="material-icons" title="New">add</i>
</div>
</div>
{{ end }}
<div class="floating">
<div class="action" id="new">
<i class="material-icons" title="New">add</i>
</div>
</div>
{{ end }}
{{ end }}

View File

@ -1,2 +1,2 @@
{{ template "content" .Data }}
{{ template "content" . }}
<span id="token">{{ .Config.Token }}</span>

View File

@ -1,5 +1,5 @@
{{ define "content" }}
{{ with .Data}}
<main class="container">
{{ if eq .Type "image" }}
<img src="{{ .URL }}?raw=true">
@ -11,5 +11,5 @@
<pre>{{ .Content }}</pre>
{{ end }}
</main>
{{ end }}
{{ end }}

View File

@ -66,7 +66,7 @@ func Parse(c *caddy.Controller) ([]Config, error) {
for c.Next() {
var cfg = Config{UserConfig: &UserConfig{}}
cfg.PathScope = "."
cfg.PathScope = "./"
cfg.BaseURL = ""
cfg.FrontMatter = "yaml"
cfg.HugoEnabled = false

View File

@ -171,7 +171,7 @@ func (i *Info) serveSingleFile(w http.ResponseWriter, r *http.Request, c *config
},
}
if CanBeEdited(i.Name) {
if CanBeEdited(i.Name) && u.AllowEdit {
editor, err := i.GetEditor()
if err != nil {