style the home page, get rid of nojs pages
instead of having dedicated nojs pages, i will instead just use javascript to enhance the already existing pages
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
!LICENSE
|
||||
!/templates/**
|
||||
!/static/**
|
||||
!.prettierrc
|
||||
|
||||
# !Makefile
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"printWidth": 1000
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func loadConfig() (Config, error) {
|
||||
|
||||
databasePath := envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite")
|
||||
|
||||
expiriesSetting := envOrDefault("MINIBIN_EXPIRIES", "1h,12h,1d,7d,2w,1mo,6mo,1y,5y, 0")
|
||||
expiriesSetting := envOrDefault("MINIBIN_EXPIRIES", "1h,12h,1d,7d,2w,1mo,6mo,1y,5y,0")
|
||||
var expiries []Expiry
|
||||
for entry := range strings.SplitSeq(expiriesSetting, ",") {
|
||||
expiry, err := parseExpiry(entry)
|
||||
|
||||
@@ -27,12 +27,16 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
pages, err := template.ParseFiles("templates/home.html", "templates/nojs/home.html")
|
||||
pages, err := template.ParseFiles("templates/home.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
fs := http.FileServer(http.Dir("static"))
|
||||
mux.Handle("GET /css/", fs)
|
||||
mux.Handle("GET /js/", fs)
|
||||
mux.Handle("GET /static/", http.StripPrefix("/static/", fs))
|
||||
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
|
||||
data := HomePageData{
|
||||
Expiries: config.Expiries,
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
:root {
|
||||
--bg: #191919;
|
||||
--surface: #2a2a2a;
|
||||
--text: #eee;
|
||||
--text-muted: #aaa;
|
||||
--border: #4e4e4e;
|
||||
--border-strong: #7e7e7e;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
margin: 0;
|
||||
font-family: Consolas, monospace;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
main {
|
||||
width: min(100% - 36px, 720px);
|
||||
margin: 0 auto;
|
||||
padding: 44px 0 64px;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
.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"]::file-selector-button {
|
||||
background-color: var(--surface);
|
||||
border: none;
|
||||
color: var(--text);
|
||||
padding: 10px;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
label[for="file-expiry"],
|
||||
label[for="paste-expiry"] {
|
||||
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;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
background-color: var(--text);
|
||||
padding: 11px;
|
||||
color: var(--surface);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
+27
-18
@@ -4,34 +4,43 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>minibin</title>
|
||||
<link rel="stylesheet" href="/css/main.css" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>minibin</h1>
|
||||
<p>simple file and paste hosting service</p>
|
||||
<noscript>
|
||||
Javascript is required for drag and drop upload, upload progress, and a few other features. <a href="/nojs/">No Javascript version</a>
|
||||
</noscript>
|
||||
<form action="/upload?redirect=true" method="post">
|
||||
<label for="content">paste content</label>
|
||||
<textarea id="content" name="content" rows="10" required></textarea>
|
||||
<label for="paste-expiry">Expiry</label>
|
||||
<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?redirect=true" method="post" enctype="multipart/form-data">
|
||||
<label for="file-expiry">expiry</label>
|
||||
<select id="paste-expiry" name="expiry">
|
||||
{{range .Expiries}}
|
||||
<option value="{{.Label}}">{{.Label}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<input type="file" required name="file" />
|
||||
<button type="submit">upload file</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="paste-panel">
|
||||
<form action="/upload?redirect=true" method="post">
|
||||
<label for="paste-expiry">expiry</label>
|
||||
|
||||
<select id="paste-expiry" name="expiry">
|
||||
{{range .Expiries}}
|
||||
<option value="{{.Label}}">{{.Label}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<textarea id="content" name="content" rows="10" required placeholder="cmon, paste something already!"></textarea>
|
||||
<button type="submit">upload paste</button>
|
||||
</form>
|
||||
|
||||
<form action="/upload?redirect=true" method="post" enctype="multipart/form-data">
|
||||
<input type="file" required name="file"/>
|
||||
<label for="file-expiry">Expiry</label>
|
||||
<select id="paste-expiry" name="expiry">
|
||||
{{range .Expiries}}
|
||||
<option value="{{.Label}}">{{.Label}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<button type="submit">upload File</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>minibin</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>minibin</h1>
|
||||
<p>simple file and paste hosting service</p>
|
||||
<form action="/upload?redirect=true" method="post">
|
||||
<label for="content">paste content</label>
|
||||
<textarea id="content" name="content" rows="10" required></textarea>
|
||||
<label for="paste-expiry">Expiry</label>
|
||||
<select id="paste-expiry" name="expiry">
|
||||
{{range .Expiries}}
|
||||
<option value="{{.Label}}">{{.Label}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<button type="submit">upload paste</button>
|
||||
</form>
|
||||
|
||||
<form action="/upload?redirect=true" method="post" enctype="multipart/form-data">
|
||||
<input type="file" required name="file"/>
|
||||
<label for="file-expiry">Expiry</label>
|
||||
<select id="paste-expiry" name="expiry">
|
||||
{{range .Expiries}}
|
||||
<option value="{{.Label}}">{{.Label}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<button type="submit">upload File</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user