This commit is contained in:
Henrique Dias 2016-10-25 21:08:26 +01:00
parent 82cc6e77bd
commit cb72d8c6c2
4 changed files with 173 additions and 170 deletions

View File

@ -264,7 +264,7 @@ textarea {
body { body {
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
padding-top: 5em; padding-top: 5em;
background-color: #fcfcfc; background-color: #ffffff;
text-rendering: optimizespeed; text-rendering: optimizespeed;
} }
@ -473,6 +473,8 @@ header {
z-index: 999; z-index: 999;
padding: 1.7em 0; padding: 1.7em 0;
background-color: #2196f3; background-color: #2196f3;
border-bottom: 1px solid rgba(0, 0, 0, 0.075);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
} }
header h1 { header h1 {
@ -481,7 +483,9 @@ header h1 {
} }
header a, header a,
header a:hover { header a:hover,
#toolbar a,
#toolbar a:hover {
color: inherit; color: inherit;
} }
@ -680,8 +684,7 @@ header .only-side {
display: none; display: none;
} }
header #prev:hover+.prev-links, .action:hover ul {
header .prev-links:hover {
display: flex; display: flex;
} }
@ -689,9 +692,9 @@ header .prev-links:hover {
border-radius: 0; border-radius: 0;
} }
header .prev-links { .action ul {
position: absolute; position: absolute;
top: 4em; top: 3.1em;
left: 0; left: 0;
color: #7d7d7d; color: #7d7d7d;
list-style: none; list-style: none;
@ -703,37 +706,39 @@ header .prev-links {
flex-direction: column-reverse; flex-direction: column-reverse;
display: none; display: none;
transition: .2s ease all; transition: .2s ease all;
min-width: 12em; min-width: 3em;
z-index: 99999;
} }
header .prev-links:before { .action ul:before {
top: -16px; top: -16px;
left: 1em; left: 1em;
right: auto; right: auto;
border: 8px solid transparent; border: 8px solid transparent;
border-bottom-color: #68efad; border-bottom-color: #ffffff;
content: ''; content: '';
position: absolute; position: absolute;
} }
header .prev-links a { .action ul a {
padding: .5em; padding: .3em .5em;
border-bottom: 1px solid #f5f5f5; border-bottom: 1px solid #f5f5f5;
transition: .2s ease all; transition: .2s ease all;
text-align: left;
} }
header .prev-links a:first-child { .action ul a:first-child {
border: 0; border: 0;
border-bottom-right-radius: .2em; border-bottom-right-radius: .2em;
border-bottom-left-radius: .2em; border-bottom-left-radius: .2em;
} }
header .prev-links a:last-child { .action ul a:last-child {
border-top-right-radius: .2em; border-top-right-radius: .2em;
border-top-left-radius: .2em; border-top-left-radius: .2em;
} }
header .prev-links a:hover { .action ul a:hover {
background-color: #f5f5f5; background-color: #f5f5f5;
} }

View File

@ -151,22 +151,6 @@ var preventDefault = function(event) {
event.preventDefault(); event.preventDefault();
} }
// Download file event
var downloadEvent = function(event) {
if (this.classList.contains('disabled')) {
return false;
}
if (selectedItems.length) {
Array.from(selectedItems).forEach(item => {
window.open(item + "?download=true");
});
return false;
}
window.open(window.location + "?download=true");
return false;
}
// Remove the last directory of an url // Remove the last directory of an url
var RemoveLastDirectoryPartOf = function(url) { var RemoveLastDirectoryPartOf = function(url) {
var arr = url.split('/'); var arr = url.split('/');
@ -466,6 +450,8 @@ document.addEventListener("changed-selected", function(event) {
document.getElementById("rename").classList.remove("disabled"); document.getElementById("rename").classList.remove("disabled");
} }
redefineDownloadURLs();
return false; return false;
} }
@ -473,6 +459,22 @@ document.addEventListener("changed-selected", function(event) {
return false; return false;
}); });
var redefineDownloadURLs = function() {
let files = "";
for (let i = 0; i < selectedItems.length; i++) {
files += selectedItems[i].replace(window.location.pathname, "") + ",";
}
files = files.substring(0, files.length - 1);
files = encodeURIComponent(files);
let links = document.querySelectorAll("#download ul a");
Array.from(links).forEach(link => {
link.href = "?download=" + link.dataset.format + "&files=" + files;
});
}
var searchEvent = function(event) { var searchEvent = function(event) {
let value = this.value; let value = this.value;
let box = document.querySelector('#search div'); let box = document.querySelector('#search div');
@ -891,7 +893,6 @@ document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("delete").addEventListener("click", deleteEvent); document.getElementById("delete").addEventListener("click", deleteEvent);
} }
document.getElementById("download").addEventListener("click", downloadEvent);
document.getElementById("open-nav").addEventListener("click", event => { document.getElementById("open-nav").addEventListener("click", event => {
document.querySelector("header > div:nth-child(2)").classList.toggle("active"); document.querySelector("header > div:nth-child(2)").classList.toggle("active");
}); });

View File

@ -1,18 +1,28 @@
{{ define "actions" }} {{ define "actions" }}
<div class="action" id="open"> <div class="action" id="open">
<i class="material-icons" title="See raw">open_in_new</i> <span>See raw</span> <i class="material-icons" title="See raw">open_in_new</i> <span>See raw</span>
</div> </div>
{{ if and .IsDir .User.AllowEdit }} {{ if and .IsDir .User.AllowEdit }}
<div class="action" id="rename"> <div class="action" id="rename">
<i class="material-icons" title="Edit">mode_edit</i> <i class="material-icons" title="Edit">mode_edit</i>
</div> </div>
{{ end }} {{ end }}
<div class="action" id="download"> <div class="action" id="download">
<i class="material-icons" title="Download">file_download</i> <span>Download</span> <a href="?download=true">
</div> <i class="material-icons" title="Download">file_download</i> <span>Download</span>
{{ if .User.AllowEdit }} </a>
<div class="action" id="delete"> {{ if .IsDir }}
<i class="material-icons" title="Delete">delete</i> <span>Delete</span> <ul class="prev-links">
</div> <a data-format="tarbz2" href="?download=tarbz2"><li>tar.bz2</li></a>
{{ end }} <a data-format="targz" href="?download=targz"><li>tar.gz</li></a>
<a data-format="tar" href="?download=tar"><li>tar</li></a>
<a data-format="zip" href="?download=zip"><li>zip</li></a>
</ul>
{{ end }}
</div>
{{ if .User.AllowEdit }}
<div class="action" id="delete">
<i class="material-icons" title="Delete">delete</i> <span>Delete</span>
</div>
{{ end }}
{{ end }} {{ end }}

View File

@ -1,139 +1,126 @@
{{ $absURL := .Config.AbsoluteURL }}
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> {{ $absURL := .Config.AbsoluteURL }}
<title>{{.Name}}</title> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{{.Name}}</title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="{{ .Config.AbsoluteURL }}/_filemanagerinternal/css/styles.css"> <link href='https://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{{ .Config.AbsoluteURL }}/_filemanagerinternal/css/styles.css">
{{ if ne .User.StyleSheet "" }} {{ if ne .User.StyleSheet "" }}
<style> <style>{{ CSS .User.StyleSheet }}</style>
{{ CSS .User.StyleSheet }}
</style>
{{ end }}
</head>
<body>
<header>
<div>
{{ $lnk := .PreviousLink }}
<div class="action{{ if eq $lnk ""}} disabled{{ end }}" id="prev">
{{ if ne $lnk ""}}
<a href="{{ $lnk }}">
{{ end }}
<i class="material-icons" title="Previous">subdirectory_arrow_left</i>
{{ if ne $lnk ""}}
</a>
{{ end }}
</div>
{{ if ne $lnk ""}}
<ul class="prev-links">
{{ range $link, $name := .BreadcrumbMap }}
<a href="{{ $absURL }}{{ $link }}"><li>{{ $name }}</li></a>
{{ end }}
</ul>
{{ end }}
<div class="action" id="open-nav">
<i class="material-icons" title="Menu">menu</i>
</div>
<p>
{{ if ne .Name "/"}}
{{ .Name }}
</p>
{{ end }} {{ end }}
</div> </head>
<body>
<div> <header>
<div class="only-side"> <div>
{{ $lnk := .PreviousLink }} {{ $lnk := .PreviousLink }}
{{ if ne $lnk ""}}
<a href="{{ $lnk }}">
{{ end }}
<div class="action{{ if eq $lnk ""}} disabled{{ end }}" id="prev"> <div class="action{{ if eq $lnk ""}} disabled{{ end }}" id="prev">
<i class="material-icons" title="Previous">subdirectory_arrow_left</i> {{ if ne $lnk ""}}<a href="{{ $lnk }}">{{ end }}
<i class="material-icons" title="Previous">subdirectory_arrow_left</i>
{{ if ne $lnk ""}}</a>{{ end }}
{{ if ne $lnk ""}}
<ul class="prev-links">
{{ range $link, $name := .BreadcrumbMap }}<a href="{{ $absURL }}{{ $link }}"><li>{{ $name }}</li></a>{{ end }}
</ul>
{{ end }}
</div> </div>
{{ if ne $lnk ""}} <div class="action" id="open-nav">
</a> <i class="material-icons" title="Menu">menu</i>
{{ end }} </div>
<p> {{ if ne .Name "/"}}<p>{{ .Name }}</p>{{ end }}
<a href="{{ if eq .Config.AbsoluteURL "" }}/{{ else }}{{ .Config.AbsoluteURL }}{{ end }}">
File Manager
</a>
</p>
</div>
{{ 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> </div>
{{ if .User.AllowNew }}
<div class="action" id="upload"> <div>
<i class="material-icons" title="Upload">file_upload</i> <span>Upload</span> <div class="only-side">
{{ $lnk := .PreviousLink }}
{{ if ne $lnk ""}}<a href="{{ $lnk }}">{{ end }}
<div class="action{{ if eq $lnk ""}} disabled{{ end }}" id="prev">
<i class="material-icons" title="Previous">subdirectory_arrow_left</i>
</div>
{{ if ne $lnk ""}}</a>{{ end }}
<p><a href="{{ if eq .Config.AbsoluteURL "" }}/{{ else }}{{ .Config.AbsoluteURL }}{{ end }}">File Manager</a></p>
</div>
{{ 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 }}
<div class="action">
<a href="?download=true">
<i class="material-icons" title="Download">file_download</i> <span>Download</span>
</a>
<ul class="prev-links">
<a href="?download=tarbz2"><li>tar.bz2</li></a>
<a href="?download=targz"><li>tar.gz</li></a>
<a href="?download=tar"><li>tar</li></a>
<a href="?download=zip"><li>zip</li></a>
</ul>
</div>
{{ else }}
{{ template "actions" . }}
{{ end }}
<div class="action" id="logout">
<i class="material-icons" title="Logout">exit_to_app</i> <span>Logout</span>
</div>
</div> </div>
{{ end }} <div id="overlay"></div>
{{ else }} </header>
{{ template "actions" . }}
{{ end }}
<div class="action" id="logout"> {{ if .IsDir }}
<i class="material-icons" title="Logout">exit_to_app</i> <span>Logout</span> <div id="toolbar">
</div>
</div>
<div id="overlay"></div>
</header>
{{ if .IsDir }}
<div id="toolbar">
<div> <div>
<div class="action" id="back"> <div class="action" id="back">
<i class="material-icons" title="Back">arrow_back</i> <i class="material-icons" title="Back">arrow_back</i>
</div> </div>
<p> <p>
<span id="selected-number">0</span> <span id="selected-number">0</span>
selected.</p> selected.</p>
</div> </div>
<div> <div>
{{ template "actions" . }} {{ template "actions" . }}
</div> </div>
</div> </div>
{{ end }} {{ end }}
<main> <main>
{{ template "content" . }} {{ template "content" . }}
<span id="token">{{ .Config.Token }}</span> <span id="token">{{ .Config.Token }}</span>
</main> </main>
<footer> <footer>
Served with Served with
<a rel="noopener noreferrer" href="https://caddyserver.com">Caddy</a> <a rel="noopener noreferrer" href="https://caddyserver.com">Caddy</a>
and and
<a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>. <a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>.
</footer> </footer>
<!-- SCRIPTS --> <!-- SCRIPTS -->
<!-- User Data and Permissions; WebDavURL --> <!-- User Data and Permissions; WebDavURL -->
<script>var user = JSON.parse('{{ Marshal .User }}'), webdavURL = "{{.Config.WebDavURL}}", baseURL = "{{.Config.BaseURL}}";</script> <script>var user = JSON.parse('{{ Marshal .User }}'), webdavURL = "{{.Config.WebDavURL}}", baseURL = "{{.Config.BaseURL}}";</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
<script src="{{ .Config.AbsoluteURL }}/_filemanagerinternal/js/form2js.js"></script> <script src="{{ .Config.AbsoluteURL }}/_filemanagerinternal/js/form2js.js"></script>
<script src="{{ .Config.AbsoluteURL }}/_filemanagerinternal/js/application.js"></script> <script src="{{ .Config.AbsoluteURL }}/_filemanagerinternal/js/application.js"></script>
{{ if .Config.HugoEnabled }}<script src="{{ .Config.AbsoluteURL }}/_hugointernal/js/application.js"></script>{{ end }} {{ if .Config.HugoEnabled }}<script src="{{ .Config.AbsoluteURL }}/_hugointernal/js/application.js"></script>{{ end }}
</body> </body>
</html> </html>