moved to web, forgot to exclude in gitignore

This commit is contained in:
2026-11-21 18:05:30 -05:00
parent 18b1172f93
commit 67849def05
14 changed files with 881 additions and 2 deletions
+336
View File
@@ -0,0 +1,336 @@
:root {
--bg: #191919;
--surface: #2a2a2a;
--surface-between: #3a3a3a;
--surface-hover: #4a4a4a;
--text: #eee;
--text-muted: #aaa;
--border: #4e4e4e;
--border-strong: #7e7e7e;
}
* {
box-sizing: border-box;
}
body {
min-height: 100vh;
background-color: var(--bg);
color: var(--text);
margin: 0;
font-family: Consolas, monospace;
font-size: 14px;
background-image: var(--qt-url);
background-repeat: no-repeat;
background-position: bottom right;
background-size: auto 256px;
background-attachment: fixed;
}
b {
font-weight: bold;
}
h1,
h2 {
margin: 0;
font-weight: 400;
}
h4 {
margin: 6px 0;
}
h1 {
font-size: 18px;
font-weight: 700;
}
a {
color: var(--text);
}
main {
width: min(100% - 36px, 720px);
margin: 0 auto;
padding: 11px 0 64px;
}
.site-header {
width: min(100% - 36px, 720px);
margin: 0 auto;
padding: 44px 0 0;
display: flex;
justify-content: space-between;
}
textarea {
background: var(--bg);
display: block;
width: 100%;
min-height: 120px;
height: 120px;
resize: vertical;
border: 1px solid var(--border);
font: inherit;
padding: 12px;
outline: none;
color: var(--text);
margin-bottom: 12px;
}
textarea:focus {
border-color: var(--border-strong);
}
input[type="text"] {
background: var(--bg);
display: block;
width: 100%;
border: 1px solid var(--border);
font: inherit;
padding: 12px;
outline: none;
color: var(--text);
margin-top: 6px;
margin-bottom: 12px;
}
input[type="text"]:focus {
border-color: var(--border-strong);
}
.upload-tabs {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
}
.upload-tabs > label {
cursor: pointer;
border-bottom: 1px solid transparent;
color: var(--text-muted);
}
.upload-tabs > input {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
.upload-tabs > input:checked + label {
border-bottom-color: currentColor;
color: var(--text);
}
.upload-tabs > input:focus-visible + label {
border: 1px solid currentColor;
}
.file-panel,
.paste-panel {
display: none;
width: 100%;
}
#type-file:checked ~ .file-panel,
#type-paste:checked ~ .paste-panel {
display: block;
}
input[type="file"] {
display: block;
border: 1px solid var(--border);
color: var(--text);
width: 100%;
cursor: pointer;
margin-bottom: 12px;
font: inherit;
}
input[type="file"]:hover {
background-color: var(--surface);
}
input[type="file"]:hover::file-selector-button {
background-color: var(--surface-hover);
}
input[type="file"]::file-selector-button {
background-color: var(--surface);
border: none;
color: var(--text);
padding: 10px;
font: inherit;
}
.muted {
color: var(--text-muted);
}
select {
padding: 0 0 2px;
background: var(--bg);
border: none;
color: var(--text);
border-bottom: 1px solid var(--border-strong);
border-radius: 0;
font: inherit;
margin-bottom: 12px;
}
option {
background-color: var(--bg);
font: inherit;
}
.btn {
border-radius: 0;
border: none;
background-color: var(--text);
padding: 11px;
color: var(--surface);
font: inherit;
cursor: pointer;
}
.btn:hover {
background-color: var(--text-muted);
}
.btn:disabled {
background-color: var(--surface);
color: var(--text-muted);
cursor: not-allowed;
}
.link-btn {
border: none;
background: none;
padding: 0;
text-decoration: underline;
color: var(--text);
cursor: pointer;
font: inherit;
}
img,
video,
audio {
max-width: 100%;
max-height: 80dvh;
}
.upload-links {
margin-top: 12px;
display: flex;
flex-direction: row;
gap: 12px;
align-items: baseline;
}
.upload-links form {
margin: 0;
}
body.dragging::after {
content: "drop file to select";
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: rgb(0 0 0 / 30%);
color: var(--text);
font-size: 1.5rem;
pointer-events: none;
}
.upload-metadata {
width: 100%;
table-layout: fixed;
border-collapse: collapse;
}
.upload-metadata th,
.upload-metadata td {
padding: 8px 0;
border-bottom: 1px solid var(--border);
text-align: left;
vertical-align: top;
overflow-wrap: anywhere;
}
.upload-metadata th:first-child {
width: 20%;
padding-right: 16px;
}
.upload-metadata th[scope="row"] {
color: var(--text-muted);
font-weight: bold;
}
code {
background-color: var(--surface-between);
padding-inline: 3px;
border: 1px solid var(--surface-hover);
}
.submit-container {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.noscript {
border: var(--border-strong);
background-color: var(--surface-between);
width: 100%;
display: block;
font-size: larger;
padding: 0.5rem;
margin-bottom: 5px;
}
.full-dropdown {
background: var(--bg);
display: block;
width: 100%;
border: 1px solid var(--border);
font: inherit;
padding: 12px;
outline: none;
color: var(--text);
margin-top: 6px;
margin-bottom: 12px;
}
.loading {
position: relative;
overflow: hidden;
background: var(--surface);
isolation: isolate;
}
.loading::before {
content: "";
position: absolute;
inset: 0;
width: 200%;
background: repeating-linear-gradient(
45deg,
var(--surface-hover) 0 25%,
transparent 25% 50%
);
background-size: 1em 1em;
animation: barStripe 1s linear infinite;
z-index: -1;
}
@keyframes barStripe {
to {
transform: translateX(-1em);
}
}
+18
View File
@@ -0,0 +1,18 @@
const link = document.getElementById("copy-link");
if (link && navigator.clipboard?.writeText) {
link.style.display = "";
link.hidden = false;
link.onclick = async (e) => {
e.preventDefault();
try {
await navigator.clipboard.writeText(`${location.origin}/${link.dataset.id}${link.dataset.extension}`);
link.textContent = "copied";
setTimeout(() => {
link.textContent = "copy link";
}, 2000);
} catch (error) {
console.error("failed to copy link:", error);
}
};
}
+46
View File
@@ -0,0 +1,46 @@
const fileInput = document.getElementById("upload-file");
function isFile(event) {
return event.dataTransfer.types.includes("Files");
}
function resetDrag() {
document.body.classList.remove("dragging");
}
document.addEventListener("dragenter", (event) => {
if (!isFile(event)) return;
event.preventDefault();
document.body.classList.add("dragging");
});
document.addEventListener("dragover", (event) => {
if (!isFile(event)) return;
event.preventDefault();
event.dataTransfer.dropEffect = "copy";
});
document.addEventListener("dragleave", () => {
resetDrag();
});
document.addEventListener("drop", (event) => {
resetDrag();
if (!isFile(event)) return;
event.preventDefault();
const file = event.dataTransfer.files[0];
if (!file) return;
const transfer = new DataTransfer();
transfer.items.add(file);
fileInput.files = transfer.files;
document.getElementById("type-file").checked = true;
fileInput.dispatchEvent(new Event("change", { bubbles: true }));
});
document.addEventListener("dragend", resetDrag);
+32
View File
@@ -0,0 +1,32 @@
function hasLeadingZeroBits(bytes, requiredBits) {
const whole = Math.floor(requiredBits / 8);
const remaining = requiredBits % 8;
for (let i = 0; i < whole; i++) {
if (bytes[i] !== 0) return false;
}
return remaining === 0 || bytes[whole] >>> (8 - remaining) === 0;
}
self.onmessage = async ({ data }) => {
const { challenge, difficulty, startNonce = 0 } = data;
if (difficulty < 0 || difficulty > 256 || !Number.isInteger(difficulty)) {
throw new Error("Invalid difficulty");
}
console.log(`[PoW] Difficulty: ${difficulty}, Starting Nonce: ${startNonce}, Challenge: ${challenge}`)
const startTime = performance.now();
const encoder = new TextEncoder();
for (let nonce = startNonce; ; nonce++) {
const input = encoder.encode(`${challenge}${nonce}`);
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", input));
if (hasLeadingZeroBits(digest, difficulty)) {
const hashHex = Array.from(digest).map((b) => b.toString(16).padStart(2, "0")).join("");
const elapsed = performance.now() - startTime;
const attempts = nonce - startNonce + 1;
console.log(`[PoW] took ${elapsed} ms to solve challenge`)
console.log(`[PoW] ${(attempts / (elapsed / 1000)).toFixed(0)} hashes/s`)
console.log(`[PoW] Result: ${hashHex}, Nonce: ${nonce}`)
self.postMessage({ nonce: nonce, hash: hashHex, });
return;
}
}
};
+17
View File
@@ -0,0 +1,17 @@
const worker = new Worker("/js/pow-worker.js");
const reportForm = document.getElementById("report-form");
const submitBtn = document.getElementById("submit-btn");
const powLabel = document.getElementById("pow-label");
const challenge = reportForm.dataset;
submitBtn.disabled = true;
worker.onmessage = ({ data }) => {
submitBtn.disabled = false;
powLabel.style.display = "none";
submitBtn.classList.remove("loading");
document.getElementById("pow-result").value = data.hash;
document.getElementById("pow-nonce").value = data.nonce;
}
worker.postMessage({
challenge: reportForm.dataset.challengeData,
difficulty: Number.parseInt(reportForm.dataset.challengeDifficulty, 10),
})
+69
View File
@@ -0,0 +1,69 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>faq | minibin</title>
<link rel="stylesheet" href="/css/main.css" />
{{if .Qt}}
<style>
:root {
--qt-url: url("{{.Qt}}");
}
</style>
{{end}}
</head>
<body>
{{template "site-header"}}
<main>
<h2>frequently asked questions</h2>
<h3>how long are uploads/files kept for?</h3>
<p>
minibin will store them for as long as their set expiry, unless they
violate the TOS or have not been accessed in a long time.
</p>
<h3>are uploads modified in any way?</h3>
<p>
no, all uploads are exactly the same as what you uploaded. uploads are
not compressed, transformed, or modified in any way, not even exif data.
</p>
<p>
be wary of any metadata included in the files you are uploading,
especially photos from a phone as they may contain GPS data.
</p>
{{if .NormalizeMIMETypes}}
<h3>why are my html/svg/pdf uploads not being rendered?</h3>
<p>they are being normalized for security.</p>
{{end}}
<h2>api usage</h2>
<h3>how do i upload via the api?</h3>
<p>
send a POST request to <code>/upload</code>. for files, use multipart
form data with a field named <code>file</code>. for pastes, send the
text with <code>Content-Type: text/plain</code>.
</p>
<p>
to add an expiry, append <code>?expiry={value}</code>. <br />supported
values are:
<code
>{{range $i, $expiry := .Expiries}}{{if
$i}},{{end}}{{$expiry.Label}}{{end}}</code
>. omitting an expiry will use the first expiry listed.
</p>
<p>
you can also specify if you would prefer a long or short upload id, just
append <br> <code>?idlength=short</code> to get a shorter id (10 characters),
otherwise it defaults to long (16 character)
</p>
<h4>uploading the output of a command</h4>
<code>cat super-cool-text.txt | curl -T - {{.Host}}/upload</code>
<h4>upload a file via curl</h4>
<code>curl -F "file=@very-cool-image.png" {{.Host}}/upload</code>
<h3>getting upload info</h3>
<p>
you can retrieve an upload's metadata by simply appending <code>/info</code> to the end of an upload, like <code>/{id}/info</code>.
it returns all stored metadata except for the original filename.
</p>
</main>
</body>
</html>
+12
View File
@@ -0,0 +1,12 @@
{{define "site-header"}}
<div class="site-header">
<h1><a style="text-decoration: none" href="/">minibin</a></h1>
<div>
<a href="/tos">tos</a>
<a href="/privacy">privacy</a>
<a href="/faq">faq</a>
<a href="/report">report</a>
<a href="https://git.whoswhip.dev/whoswhip/minibin">src</a>
</div>
</div>
{{end}}
+73
View File
@@ -0,0 +1,73 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>minibin</title>
<link rel="stylesheet" href="/css/main.css" />
<script defer src="/js/dnd.js"></script>
{{if .Qt}}
<style>
:root {
--qt-url: url("{{.Qt}}");
}
</style>
{{end}}
<meta name="description" content="simple file and paste hosting service" />
<meta property="og:title" content="minibin" />
<meta property="og:description" content="simple file and paste hosting service" />
</head>
<body class="home-page" id="home-page">
{{template "site-header"}}
<main>
<p>simple file and paste hosting service</p>
<div class="upload-tabs">
<input type="radio" name="upload-type" id="type-file" checked />
<label for="type-file">file</label>
<input type="radio" name="upload-type" id="type-paste" />
<label for="type-paste">paste</label>
<div class="file-panel">
<form action="/upload?return=html" method="post" enctype="multipart/form-data">
<label class="muted" for="file-expiry">expiry</label>
<select id="file-expiry" name="expiry">
{{range .Expiries}}
<option value="{{.Label}}">{{.Label}}</option>
{{end}}
</select>
<label class="muted" for="file-id-length">id length</label>
<select id="file-id-length" name="idlength">
<option value="long">16 characters</option>
<option value="short">10 characters</option>
</select>
<input id="upload-file" type="file" required name="file" />
<div class="submit-container">
<button type="submit" class="btn">upload file</button>
<span class="muted">max {{.FileMaxSize}}</span>
</div>
</form>
</div>
<div class="paste-panel">
<form action="/upload?return=html" method="post">
<label class="muted" for="paste-expiry">expiry</label>
<select id="paste-expiry" name="expiry">
{{range .Expiries}}
<option value="{{.Label}}">{{.Label}}</option>
{{end}}
</select>
<label class="muted" for="paste-id-length">id length</label>
<select id="paste-id-length" name="idlength">
<option value="long">16 characters</option>
<option value="short">10 characters</option>
</select>
<textarea id="content" name="content" rows="10" required placeholder="{{.PastePlaceholder}}"></textarea>
<div class="submit-container">
<button type="submit" class="btn">upload paste</button>
<span class="muted">max {{.PasteMaxSize}}</span>
</div>
</form>
</div>
</div>
</main>
</body>
</html>
+47
View File
@@ -0,0 +1,47 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>privacy | minibin</title>
<link rel="stylesheet" href="/css/main.css" />
{{if .}}
<style>
:root {
--qt-url: url("{{.}}");
}
</style>
{{end}}
</head>
<body>
{{template "site-header"}}
<main>
<h2>privacy policy</h2>
<h3>what we store</h3>
<p>when you upload a file or paste, we store:</p>
<ul>
<li>the file or paste content</li>
<li>the original filename, type, and size</li>
<li>an upload id and a SHA256 hash of the content</li>
<li>timestamps and the selected expiry</li>
<li>a deletion token</li>
</ul>
<p>
this information is used to serve uploads, check expiry, and allow
deletion of uploads.
</p>
<h3>who can access uploads</h3>
<p>
anyone with the id of an upload can access and share it. minibin's
operator can also access stored uploads. avoid uploading anything
private.
</p>
<h3>changes to this policy</h3>
<p>
this policy may change as minibin changes. updates will be posted on
this page.
</p>
</main>
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>report | minibin</title>
<link rel="stylesheet" href="/css/main.css" />
<script defer src="/js/report.js"></script>
{{if .Qt}}
<style>
:root {
--qt-url: url("{{.Qt}}");
}
</style>
{{end}}
</head>
<body>
{{template "site-header"}}
<main>
<noscript class="noscript">
Javascript is required when reporting to compute a proof-of-work challenge. Without solving the challenge you cannot submit a report.
</noscript>
<form
method="post"
id="report-form"
data-challenge-difficulty="{{.Challenge.Difficulty}}"
data-challenge-expires-at="{{.Challenge.ExpiresAt}}"
data-challenge-data="{{.Challenge.Data}}"
>
<input id="pow-result" type="hidden" name="pow_result">
<input id="pow-nonce" type="hidden" name="pow_nonce">
<input type="hidden" name="pow_challenge_id" value="{{.Challenge.Id}}">
<label class="muted" for="upload_id">upload id</label>
<input type="text" name="upload_id" required>
<label class="muted" for="report_reason">reason</label>
<select class="full-dropdown" id="report-reason" name="report_reason">
{{range .ReportOptions}}
<option value="{{.}}">{{.}}</option>
{{end}}
</select>
<div class="submit-container">
<button id="submit-btn" type="submit" class="btn loading" disabled>submit</button>
<span id="pow-label">computing proof of work</span>
</div>
</form>
</main>
</body>
</html>
+23
View File
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{.Title}} | minibin</title>
<link rel="stylesheet" href="/css/main.css" />
{{if .Qt}}
<style>
:root {
--qt-url: url("{{.Qt}}");
}
</style>
{{end}}
</head>
<body>
{{template "site-header"}}
<main>
<h2>{{.Title}}</h2>
<p>{{.Message}}</p>
</main>
</body>
</html>
+53
View File
@@ -0,0 +1,53 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>tos | minibin</title>
<link rel="stylesheet" href="/css/main.css" />
{{if .}}
<style>
:root {
--qt-url: url("{{.}}");
}
</style>
{{end}}
</head>
<body>
{{template "site-header"}}
<main>
<h2>terms of service</h2>
<p>by using minibin, you agree to these terms.</p>
<h3>acceptable use</h3>
<p>
you are responsible for what you upload and share. only upload content
that you own or are allowed to share.
</p>
<h3>prohibited content</h3>
<p>do not upload or share:</p>
<ul>
<li>child sexual abuse or exploitation material</li>
<li>malware, viruses, or files intended to harm other people</li>
<li>extreme gore</li>
<li>copyright infringing material</li>
</ul>
<h3>storage and expiry</h3>
<p>
uploads have an expiry based on the option selected when uploading.
indefinite means there is no scheduled expiry.
</p>
<p>
uploads may be removed earlier for breaking these terms, maintenance or
storage limits. ensure you keep a copy of anything important.
</p>
<h3>deleting uploads</h3>
<p>
keep the delete token provided after uploading. anyone with that token
is able to delete the upload, so keep it private.
</p>
<h3>changes to these terms</h3>
<p>these terms may change, updates with be posted on this page.</p>
</main>
</body>
</html>
+105
View File
@@ -0,0 +1,105 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{.ID}} | minibin</title>
<link rel="stylesheet" href="/css/main.css" />
{{if .Qt}}
<style>
:root {
--qt-url: url("{{.Qt}}");
}
</style>
{{end}}
</head>
<script src="/js/copy.js" defer></script>
<body>
{{template "site-header"}}
<main>
<div>
{{if hasPrefix .MIMEType "image/"}}
<img src="/{{.ID}}{{.FileExtension}}" />
{{else if hasPrefix .MIMEType "video/"}}
<video src="/{{.ID}}{{.FileExtension}}" controls></video>
{{else if hasPrefix .MIMEType "audio/"}}
<audio src="/{{.ID}}{{.FileExtension}}" controls></audio>
{{else}}
<h2>{{.Filename}}</h2>
<h2>{{.ID}}{{.FileExtension}}</h2>
{{end}}
</div>
<details>
<summary>upload metadata</summary>
<table class="upload-metadata">
<thead>
<tr>
<th scope="col">key</th>
<th scope="col">value</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">id</th>
<td>{{.ID}}</td>
</tr>
<tr>
<th scope="row">type</th>
<td>{{.Type}}</td>
</tr>
<tr>
<th scope="row">filename</th>
<td>{{.Filename}}</td>
</tr>
<tr>
<th scope="row">mimetype</th>
<td>{{.MIMEType}}</td>
</tr>
<tr>
<th scope="row">size</th>
<td>{{.Size}}</td>
</tr>
<tr>
<th scope="row">sha256</th>
<td>{{.SHA256}}</td>
</tr>
<tr>
<th scope="row">created at</th>
<td>{{.CreatedAt}}</td>
</tr>
<tr>
<th scope="row">expires at</th>
<td>{{if .ExpiresAt}}{{.ExpiresAt}}{{else}}indefinite{{end}}</td>
</tr>
<tr>
<th scope="row">last accessed at</th>
<td>{{.LastAccessedAt}}</td>
</tr>
<tr>
<th scope="row">file extension</th>
<td>{{.FileExtension}}</td>
</tr>
<tr>
<th scope="row">delete token</th>
<td>{{.DeleteToken}}</td>
</tr>
</tbody>
</table>
</details>
<div class="upload-links">
<a href="/{{.ID}}{{.FileExtension}}">view raw upload</a>
<!--
copying is only available with javascript
we will make this element visible with javascript
-->
<a id="copy-link" data-id="{{.ID}}" data-extension="{{.FileExtension}}" href="#" style="display: none">copy link</a>
<form action="/{{.ID}}/delete?redirect=true" method="post">
<input type="hidden" name="delete_token" value="{{.DeleteToken}}" />
<button type="submit" class="link-btn">delete upload</button>
</form>
</div>
</main>
</body>
</html>