move templates to separate file

This commit is contained in:
Henrique Dias 2017-06-25 22:43:43 +01:00
parent cca2d9c4c6
commit b466ad616c
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
3 changed files with 90 additions and 85 deletions

View File

@ -198,91 +198,7 @@
</div>
{{- end }}
<template id="question-template">
<form class="prompt">
<h3></h3>
<p></p>
<input autofocus type="text">
<div>
<button type="submit" autofocus class="ok">OK</button>
<button class="cancel" onclick="closePrompt(event);">Cancel</button>
</div>
</form>
</template>
<template id="info-template">
<div class="prompt">
<h3>File Information</h3>
<p><strong>Display Name:</strong> <span id="display_name"></span></p>
<p><strong>Content Length:</strong> <span id="content_length"></span> Bytes</p>
<p><strong>Last Modified:</strong> <span id="last_modified"></span></p>
<section class="file-only">
<p><strong>MD5:</strong> <code id="md5"><a href="#" onclick="getHash(event, 'md5')">show</a></code></p>
<p><strong>SHA1:</strong> <code id="sha1"><a href="#" onclick="getHash(event, 'sha1')">show</a></code></p>
<p><strong>SHA256:</strong> <code id="sha256"><a href="#" onclick="getHash(event, 'sha256')">show</a></code></p>
<p><strong>SHA512:</strong> <code id="sha512"><a href="#" onclick="getHash(event, 'sha512')">show</a></code></p>
</section>
<div>
<button type="submit" onclick="closePrompt(event);" class="ok">OK</button>
</div>
</div>
</template>
<template id="message-template">
<div class="prompt">
<h3></h3>
<p></p>
<div>
<button type="submit" onclick="closePrompt(event);" class="ok">OK</button>
</div>
</div>
</template>
<template id="move-template">
<form class="prompt">
<h3>Move</h3>
<p>Choose new house for your file(s)/folder(s):</p>
<div class="file-list">
<ul>
</ul>
</div>
<p>Currently navigating on: <code></code>.</p>
<div>
<button type="submit" autofocus class="ok">Move</button>
<button class="cancel" onclick="closePrompt(event);">Cancel</button>
</div>
</form>
</template>
<div class="help">
<h3>Help</h3>
<ul>
<li><strong>F1</strong> - this information</li>
<li><strong>F2</strong> - rename file</li>
<li><strong>DEL</strong> - delete selected items</li>
<li><strong>ESC</strong> - clear selection and/or close the prompt</li>
<li><strong>CTRL + S</strong> - save a file or download the directory where you are</li>
<li><strong>CTRL + Click</strong> - select multiple files or directories</li>
<li><strong>Double click</strong> - open a file or directory</li>
<li><strong>Click</strong> - select file or directory</li>
</ul>
<p>Not available yet</p>
<ul>
<li><strong>Alt + Click</strong> - select a group of files</li>
</ul>
<div>
<button type="submit" onclick="closeHelp(event);" class="ok">OK</button>
</div>
</div>
{{ template "templates" . }}
<footer>Served with <a rel="noopener noreferrer" href="https://caddyserver.com">Caddy</a> and <a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>.</footer>
</body>

View File

@ -0,0 +1,87 @@
{{ define "templates" }}
<template id="question-template">
<form class="prompt">
<h3></h3>
<p></p>
<input autofocus type="text">
<div>
<button type="submit" autofocus class="ok">OK</button>
<button class="cancel" onclick="closePrompt(event);">Cancel</button>
</div>
</form>
</template>
<template id="info-template">
<div class="prompt">
<h3>File Information</h3>
<p><strong>Display Name:</strong> <span id="display_name"></span></p>
<p><strong>Content Length:</strong> <span id="content_length"></span> Bytes</p>
<p><strong>Last Modified:</strong> <span id="last_modified"></span></p>
<section class="file-only">
<p><strong>MD5:</strong> <code id="md5"><a href="#" onclick="getHash(event, 'md5')">show</a></code></p>
<p><strong>SHA1:</strong> <code id="sha1"><a href="#" onclick="getHash(event, 'sha1')">show</a></code></p>
<p><strong>SHA256:</strong> <code id="sha256"><a href="#" onclick="getHash(event, 'sha256')">show</a></code></p>
<p><strong>SHA512:</strong> <code id="sha512"><a href="#" onclick="getHash(event, 'sha512')">show</a></code></p>
</section>
<div>
<button type="submit" onclick="closePrompt(event);" class="ok">OK</button>
</div>
</div>
</template>
<template id="message-template">
<div class="prompt">
<h3></h3>
<p></p>
<div>
<button type="submit" onclick="closePrompt(event);" class="ok">OK</button>
</div>
</div>
</template>
<template id="move-template">
<form class="prompt">
<h3>Move</h3>
<p>Choose new house for your file(s)/folder(s):</p>
<div class="file-list">
<ul>
</ul>
</div>
<p>Currently navigating on: <code></code>.</p>
<div>
<button type="submit" autofocus class="ok">Move</button>
<button class="cancel" onclick="closePrompt(event);">Cancel</button>
</div>
</form>
</template>
<div class="help">
<h3>Help</h3>
<ul>
<li><strong>F1</strong> - this information</li>
<li><strong>F2</strong> - rename file</li>
<li><strong>DEL</strong> - delete selected items</li>
<li><strong>ESC</strong> - clear selection and/or close the prompt</li>
<li><strong>CTRL + S</strong> - save a file or download the directory where you are</li>
<li><strong>CTRL + Click</strong> - select multiple files or directories</li>
<li><strong>Double click</strong> - open a file or directory</li>
<li><strong>Click</strong> - select file or directory</li>
</ul>
<p>Not available yet</p>
<ul>
<li><strong>Alt + Click</strong> - select a group of files</li>
</ul>
<div>
<button type="submit" onclick="closeHelp(event);" class="ok">OK</button>
</div>
</div>
{{ end }}

View File

@ -103,6 +103,8 @@ func (p page) PreviousLink() string {
// PrintAsHTML formats the page in HTML and executes the template
func (p page) PrintAsHTML(w http.ResponseWriter, m *FileManager, templates ...string) (int, error) {
templates = append(templates, "templates")
if p.minimal {
templates = append(templates, "minimal")
} else {