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
|
!LICENSE
|
||||||
!/templates/**
|
!/templates/**
|
||||||
!/static/**
|
!/static/**
|
||||||
|
!.prettierrc
|
||||||
|
|
||||||
# !Makefile
|
# !Makefile
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"tabWidth": 2,
|
||||||
|
"printWidth": 1000
|
||||||
|
}
|
||||||
@@ -46,7 +46,7 @@ func loadConfig() (Config, error) {
|
|||||||
|
|
||||||
databasePath := envOrDefault("MINIBIN_DATABASE_PATH", "minibin.sqlite")
|
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
|
var expiries []Expiry
|
||||||
for entry := range strings.SplitSeq(expiriesSetting, ",") {
|
for entry := range strings.SplitSeq(expiriesSetting, ",") {
|
||||||
expiry, err := parseExpiry(entry)
|
expiry, err := parseExpiry(entry)
|
||||||
|
|||||||
@@ -27,12 +27,16 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pages, err := template.ParseFiles("templates/home.html", "templates/nojs/home.html")
|
pages, err := template.ParseFiles("templates/home.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
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) {
|
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
|
||||||
data := HomePageData{
|
data := HomePageData{
|
||||||
Expiries: config.Expiries,
|
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;
|
||||||
|
}
|
||||||
+35
-26
@@ -4,34 +4,43 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>minibin</title>
|
<title>minibin</title>
|
||||||
|
<link rel="stylesheet" href="/css/main.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>minibin</h1>
|
<main>
|
||||||
<p>simple file and paste hosting service</p>
|
<h1>minibin</h1>
|
||||||
<noscript>
|
<p>simple file and paste hosting service</p>
|
||||||
Javascript is required for drag and drop upload, upload progress, and a few other features. <a href="/nojs/">No Javascript version</a>
|
<div class="upload-tabs">
|
||||||
</noscript>
|
<input type="radio" name="upload-type" id="type-file" checked />
|
||||||
<form action="/upload?redirect=true" method="post">
|
<label for="type-file">file</label>
|
||||||
<label for="content">paste content</label>
|
<input type="radio" name="upload-type" id="type-paste" />
|
||||||
<textarea id="content" name="content" rows="10" required></textarea>
|
<label for="type-paste">paste</label>
|
||||||
<label for="paste-expiry">Expiry</label>
|
<div class="file-panel">
|
||||||
<select id="paste-expiry" name="expiry">
|
<form action="/upload?redirect=true" method="post" enctype="multipart/form-data">
|
||||||
{{range .Expiries}}
|
<label for="file-expiry">expiry</label>
|
||||||
<option value="{{.Label}}">{{.Label}}</option>
|
<select id="paste-expiry" name="expiry">
|
||||||
{{end}}
|
{{range .Expiries}}
|
||||||
</select>
|
<option value="{{.Label}}">{{.Label}}</option>
|
||||||
<button type="submit">upload paste</button>
|
{{end}}
|
||||||
</form>
|
</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>
|
||||||
|
|
||||||
<form action="/upload?redirect=true" method="post" enctype="multipart/form-data">
|
<select id="paste-expiry" name="expiry">
|
||||||
<input type="file" required name="file"/>
|
{{range .Expiries}}
|
||||||
<label for="file-expiry">Expiry</label>
|
<option value="{{.Label}}">{{.Label}}</option>
|
||||||
<select id="paste-expiry" name="expiry">
|
{{end}}
|
||||||
{{range .Expiries}}
|
</select>
|
||||||
<option value="{{.Label}}">{{.Label}}</option>
|
<textarea id="content" name="content" rows="10" required placeholder="cmon, paste something already!"></textarea>
|
||||||
{{end}}
|
<button type="submit">upload paste</button>
|
||||||
</select>
|
</form>
|
||||||
<button type="submit">upload File</button>
|
</div>
|
||||||
</form>
|
</div>
|
||||||
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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