121 lines
4.5 KiB
Plaintext
121 lines
4.5 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<%- include('../partials/head'); -%>
|
|
<%- include('../partials/admin-editor-css'); -%>
|
|
<title>Admin - Meta editor</title>
|
|
</head>
|
|
<body>
|
|
<%- include('../winter'); -%>
|
|
|
|
<div class="editor-container">
|
|
<a class="btn btn-back" href="<%= endpoint %>/dashboard">Back to dashboard</a>
|
|
<h1>The Metadata Editor</h1>
|
|
<section>
|
|
<h2>Page metadata</h2>
|
|
<form action="<%= endpoint %>/edit-meta" method="post" class="editor-form editor-form--stacked">
|
|
<div class="field">
|
|
<span>Title</span>
|
|
<input name="title" type="text" value="<%= title %>">
|
|
</div>
|
|
<div class="field">
|
|
<span>Title (short)</span>
|
|
<input name="titleShort" type="text" value="<%= titleShort %>">
|
|
</div>
|
|
<div class="field">
|
|
<span>Description</span>
|
|
<input name="description" type="text" value="<%= description %>">
|
|
</div>
|
|
<div class="field">
|
|
<span>Bio lines</span>
|
|
<% for (let i = 0; i < bio.length; i++) { %>
|
|
<input name="<%= i %>" type="text" value="<%= bio[i] %>">
|
|
<% } %>
|
|
<input name="new" type="text" placeholder="Add new bio line">
|
|
</div>
|
|
<button type="submit">Save changes</button>
|
|
</form>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Background Image</h2>
|
|
<form action="<%= endpoint %>/update/background" enctype="multipart/form-data" method="post" class="editor-form editor-form--stacked">
|
|
<input type="file" name="background">
|
|
<button type="submit">Upload</button>
|
|
</form>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Preview Icon</h2>
|
|
<form action="<%= endpoint %>/update/avatar" enctype="multipart/form-data" method="post" class="editor-form editor-form--stacked">
|
|
<input type="file" name="avatar">
|
|
<button type="submit">Upload</button>
|
|
</form>
|
|
</section>
|
|
|
|
<section>
|
|
<h2>Favicon</h2>
|
|
<form action="<%= endpoint %>/update/favicon" enctype="multipart/form-data" method="post" class="editor-form editor-form--stacked">
|
|
<input type="file" name="favicon">
|
|
<button type="submit">Upload</button>
|
|
</form>
|
|
</section>
|
|
|
|
<section id="page-font">
|
|
<h2>Page Font</h2>
|
|
<p class="font-note">
|
|
Upload a font file (.woff2, .woff, .ttf or .otf) to change the font used across the site.
|
|
A preview appears below before you apply it.
|
|
<% if (typeof font !== 'undefined' && font && font.file) { %>
|
|
Currently applied: <strong><%= font.name || font.file %></strong>
|
|
<% } else { %>
|
|
Currently using the default font.
|
|
<% } %>
|
|
</p>
|
|
<form action="<%= endpoint %>/update/font" enctype="multipart/form-data" method="post" class="editor-form editor-form--stacked">
|
|
<input type="file" id="font-input" name="font" accept=".woff2,.woff,.ttf,.otf,font/*">
|
|
<div id="font-preview" class="font-preview">The quick brown fox jumps over the lazy dog 0123456789</div>
|
|
<div class="font-actions">
|
|
<button type="submit" id="font-apply" disabled>Apply font</button>
|
|
<% if (typeof font !== 'undefined' && font && font.file) { %>
|
|
<button type="submit" class="delete" formaction="<%= endpoint %>/remove/font" formnovalidate>Remove font</button>
|
|
<% } %>
|
|
</div>
|
|
</form>
|
|
<script>
|
|
(function () {
|
|
var input = document.getElementById('font-input');
|
|
var preview = document.getElementById('font-preview');
|
|
var apply = document.getElementById('font-apply');
|
|
if (!input || !preview || !apply) { return; }
|
|
input.addEventListener('change', function () {
|
|
var file = input.files && input.files[0];
|
|
if (!file) {
|
|
apply.disabled = true;
|
|
return;
|
|
}
|
|
var family = 'font_preview_' + Date.now();
|
|
var url = URL.createObjectURL(file);
|
|
preview.classList.remove('is-active');
|
|
var face = new FontFace(family, 'url(' + url + ')');
|
|
face.load().then(function (loaded) {
|
|
document.fonts.add(loaded);
|
|
preview.style.fontFamily = '"' + family + '", "Courier New", monospace';
|
|
preview.classList.add('is-active');
|
|
apply.disabled = false;
|
|
}).catch(function () {
|
|
preview.style.fontFamily = '';
|
|
apply.disabled = true;
|
|
alert('That file could not be loaded as a font.');
|
|
});
|
|
});
|
|
})();
|
|
</script>
|
|
</section>
|
|
</div>
|
|
|
|
|
|
<%- include('../footer'); -%>
|
|
</body>
|
|
</html>
|