リファクタリングと再設計

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/marisa/trunk@67 d6811dac-2434-b64a-9ddc-f563ab233461
This commit is contained in:
yakumo.izuru
2024-02-11 02:08:18 +00:00
parent 0f18a4e48e
commit c83cad8164
19 changed files with 431 additions and 530 deletions

View File

@@ -1,36 +1,35 @@
# TCP or unix Socket to listen on.
# When unix sockets are used, the content will be served over FastCGI.
#listen = /var/run/marisa-fcgi.sock
listen = 127.0.0.1:9000
# Base to use when constructing URI to files uploaded.
# The full URI must be specified, in the form SCHEME://HOST[:PORT]
baseuri = http://127.0.0.1:9000
[marisa]
# TCP or Unix socket to listen on.
# When the Unix socket is used, the content will be served through FastCGI
# listen = /var/run/marisa.sock
# listen = 127.0.0.1:9000
# Drop privilege to the user and group specified.
# When only the user is specified, the default group of the user will
# be used.
#user = www
#group = daemon
# When only the user is specified, the default group of the user
# will be used.
# user = www
# group = www
# Change the root directory to the following directory.
# When a chroot is set, all path must be given according to the chroot.
# Note: the configuration file is read before chrooting.
#chroot = /var/www
# When a chroot(2) is set, all paths must be given according to it.
# Note: the configuration file is read before it happens
# chroot =
[www]
# baseuri = http://127.0.0.1:9000
# Path to the different path used by the server. Must take into account
# the chroot if set.
rootdir = static
tmplpath = templates
filepath = files
metapath = meta
# Path to the resources used by the server, must take into account
# the chroot is set
# rootdir = ./static
# tmplpath = ./templates
# filepath = ./files
# metapath = ./meta
# URI context that files will be served on
filectx = /f/
# filectx = /f/
# Maximum per-file upload size (in bytes)
maxsize = 536870912 # 512Mib
# maxsize = 536870912 # 512 MiB
# Default expiration time (in seconds). An expiration time of 0 seconds
# means no expiration.
expiry = 86400 # 24 hours
# Default expiration time (in seconds).
# An expiration time of 0 seconds means no expiration.
# expiry = 86400 # 24 hours

View File

@@ -1,98 +0,0 @@
// Handle drag and drop into a dropzone_element div:
// send the files as a POST request to the server
"use strict";
// Only start once the DOM tree is ready
if(document.readyState === "complete") {
setupzone();
} else {
document.addEventListener("DOMContentLoaded", setupzone);
}
function setupzone() {
let dropzone = document.getElementById("dropzone");
let fileinput = document.getElementById("filebox");
let fallbackform = document.getElementById("fallbackform");
fallbackform.style.display = "none";
dropzone.className = "dropzone";
dropzone.innerHTML = "Click or drop file(s)";
dropzone.onclick = function() {
fileinput.click()
return false;
}
dropzone.ondragover = function() {
this.className = "dropzone dragover";
return false;
}
dropzone.ondragleave = function() {
this.className = "dropzone";
return false;
}
dropzone.ondrop = function(e) {
// Stop browser from simply opening that was just dropped
e.preventDefault();
// Restore original dropzone appearance
this.className = "dropzone";
sendfiles(e.dataTransfer.files)
}
fileinput.onchange = function(e) {
sendfiles(this.files)
}
}
function sendfiles(files) {
let uploads = document.getElementById("uploads");
let progressbar = document.createElement("progress");
let uploadlist = document.createElement("ul");
let uploadtext = document.createElement("textarea");
let formData = new FormData(), xhr = new XMLHttpRequest();
// used for clipboard only
uploadtext.style.display = "none";
uploads.appendChild(progressbar);
uploads.appendChild(uploadlist);
uploads.appendChild(uploadtext);
formData.append("expiry", 10);
for(let i=0; i < files.length; i++) {
formData.append("file", files[i]);
}
// triggers periodically
xhr.upload.onprogress = function(e) {
// e.loaded - how many bytes downloaded
// e.lengthComputable = true if the server sent Content-Length header
// e.total - total number of bytes (if lengthComputable)
}
xhr.onreadystatechange = function() {
if(xhr.readyState === XMLHttpRequest.DONE) {
progressbar.remove();
this.response.split(/\r?\n/).forEach(function(link) {
let li = document.createElement("li");
li.innerHTML = `<a href="${link}">${link}</a>`;
uploadlist.appendChild(li);
});
let clippy = document.createElement("button");
uploads.appendChild(clippy);
clippy.innerText = " 📋 copy ";
clippy.onclick = function(e) {
uploadtext.select();
document.execCommand("copy");
}
}
}
xhr.open('POST', window.location.href, true); // async = true
xhr.send(formData);
}

BIN
example/static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

17
example/static/marisa.css Normal file
View File

@@ -0,0 +1,17 @@
body {
background-color: #282c37;
color: #f8f8f2;
font-family: sans-serif;
}
a {
color: #272822;
}
a:hover, a:link {
color: #e6db74;
}
a:visited {
color: #66d9ef;
}
table {
border-color: rgb(128, 0, 0);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -1,90 +0,0 @@
body {
padding: 5%;
margin: auto;
max-width: 540px;
font-family: sans-serif;
font-size: 1.5rem;
text-align: center;
background-color: #550000;
color: #ff4444;
}
header {
display: flex;
flex-direction: column;
flex-wrap: wrap-reverse;
align-items: center;
align-content: center;
}
section {
display: flex;
justify-content: flex-end;
font-size: initial;
}
section#formsettings > * {
margin-top: 20px;
margin-left: 20px;
}
img#logo {
height: 100%;
max-height: 30vh;
}
h1 {
font-size: 4.0rem;
}
#uploads {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#uploads > ul {
list-style: none;
text-align: left;
padding: 0;
}
#uploads > button {
align-self: flex-end;
margin-right: 10%;
}
.dropzone {
padding-top: 60px;
padding-bottom: 60px;
border: 2px dashed #888888;
border-radius: 8px;
text-align: center;
margin: auto;
color: #888888;
}
.dropzone.dragover {
color: #222222;
border-color: #222222;
}
/* font attributes are not inherited by default */
input, input::file-selector-button {
text-align: inherit;
font-family: inherit;
font-size: inherit;
}
@media (min-aspect-ratio: 18/9) {
header {
flex-direction: row;
}
h1 { font-size: 3rem; margin-right: 10px; }
img#logo {
height: 50%;
max-height: 20vh;
order: 2;
}
}

View File

@@ -1,42 +1,47 @@
<!DOCTYPE HTML>
<!DOCTYPE HTML PUBLIC "//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="z3bra, Izuru Yakumo">
<meta name="robots" content="noindex,nofollow" >
<link rel="icon" href="/favicon.ico">
<link rel="stylesheet" href="/marisa.css">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="author" content="Izuru Yakumo">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="/marisa_98.css" >
<link rel="icon" href="/marisa.png">
<title>Marisa</title>
</head>
<body>
<header>
<img id="logo" src="/marisa.png" >
<h1>marisa</h1>
</header>
<form enctype="multipart/form-data" method="post">
<div id="dropzone"></div>
<div id="fallbackform" class="dropzone">
<input id="filebox" name="file" type="file" multiple>
<input id="output" name="output" type="hidden" value='html' >
<input type="submit" value="Upload">
</div>
<section id="formsettings">
<label for="expiry"> Destroy after </label>
<select id="expiry" name="expiry">
<option value="900"> 15 minutes </option>
<option value="3600"> 1 hour </option>
<option value="28800"> 8 hours </option>
<option value="86400" selected> 1 day </option>
<option value="604800"> 1 week </option>
</select>
</section>
</form>
<p>File size limited to {{.Maxsize}}.</p>
<div id="uploads">{{if .Links}}
<ul>
{{range .Links}}<li><a href="{{.}}">{{.}}</a></li>{{end}}
</ul>
{{end}}</div>
<table border="1" align="center">
<thead>
<img class="logo" src="/marisa.png">
<br>
<h1>Marisa</h1>
</thead>
<tbody>
<form enctype="multipart/form-data" method="POST">
<input class="file" name="file" type="file"><br>
<input name="output" type="hidden" value="html"><br>
<input type="submit"><br>
<label for="expiry">Destroy after</label>
<select name="expiry">
<option value="900">15 minutes</option>
<option value="3600">1 hour</option>
<option value="28800">8 hours</option>
<option value="86400">1 day</option>
<option value="604800">1 week</option>
</select>
</form>
<p>
File size limited to {{.Maxsize}}.
</p>
</tbody>
<tfoot>
{{if .Links}}
<tr>
{{range .Links}}<td><a href="{{.}}">{{.}}</a></td>{{end}}
</tr>
{{end}}
<br><hr>
<p>&copy; 2024 Izuru Yakumo</p>
</tfoot>
</table>
</body>
</html>