remove viper dep, template site a bit more

This commit is contained in:
hgc 2024-02-12 09:27:33 +00:00
джерело 68da26718b
коміт 676c1178cc
3 змінених файлів з 12 додано та 15 видалено

@ -1,3 +0,0 @@
bind = "127.0.0.1:8000"
database = "filehole.db"
filedir = "./data"

@ -1,18 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>filehole.org</title>
<title>{{ .SiteName }}</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
body{background-color:#1a1c1d;color:#fff;font-family:monospace;font-size:14px;padding:20px;text-align:center}h1{font-size:32px;margin-bottom:2px}h1 small{font-size:8px;margin-bottom:-5px;vertical-align:top}.slogan{background:-webkit-linear-gradient(#1a4e1d,#c8ffa5);-webkit-background-clip:text;-webkit-text-fill-color:transparent;margin-top:-10px;font-size:12px;vertical-align:top}h2{font-size:12px;margin-bottom:20px}#hole{display:flex;justify-content:center;cursor:pointer;margin:0 auto;margin-bottom:20px}#hole:hover{border-color:#ccc}#filelist{list-style:none;margin:0 auto;max-width:600px;padding:0}.file{border-radius:5px;background-color:#333;border:1px solid #555;color:#fff;display:flex;align-items:center;justify-content:space-between;margin:5px 0;padding:10px;transition:all .3s ease-in-out}.file:hover{background-color:#444;box-shadow:0 1px 3px rgba(0,0,0,.3)}.file a{color:#fff;margin-right:10px;text-decoration:none}.file a:hover{text-decoration:underline}.file button{background-color:transparent;border:none;color:#fff;cursor:pointer;font-size:18px;margin-left:10px;margin-right:-7px;padding:0;transition:opacity .3s ease-in-out}.file button:hover{opacity:.7}button{background-color:transparent;border:2px solid #3e4446;border-radius:5px;color:#fff;cursor:pointer;font-size:16px;margin-top:10px;padding:7px 20px;text-transform:uppercase;transition:background-color .3s ease-in-out}button:hover{background-color:#444;border-color:#fff}#options{align-items:center;display:flex;flex-wrap:wrap;justify-content:center;margin-top:20px}.option{background-color:#222;border:2px solid #444;border-radius:5px;color:#fff;cursor:pointer;font-size:16px;margin:5px;padding:7px 20px;transition:all .3s ease-in-out}.option:hover{background-color:#444;border-color:#fff}#options label{font-size:16px;margin-right:10px}#options input[type=number],#options select[name=expiry]{background-color:#333;border:none;border-radius:5px;color:#fff;font-size:16px;height:30px;margin-right:10px;padding:0 10px;text-align:center;transition:all .3s ease-in-out;width:80px}#options input[type=number]:hover,#options select[name=expiry]:hover{background-color:#444;cursor:pointer}#options input[type=number]:focus,#options select[name=expiry]:focus{background-color:#444;outline:none}@media(max-width:768px){body{font-size:12px;padding:10px}h1{font-size:24px;margin-bottom:10px}#hole{max-width:150px;min-height:150px;padding:10px;margin-bottom:20px}#filelist{max-width:400px}.file{border-radius:5px;padding:8px;margin:3px 0}.file a{font-size:12px;margin-right:5px}.file button{font-size:14px;margin-left:5px;margin-right:-3px}button{font-size:14px;margin-top:5px;padding:5px 12px}#options{margin-top:10px}#options label{font-size:14px;margin-right:5px}#options input[type=number],#options select[name=expiry]{font-size:14px;height:25px;margin-right:5px;padding:0 5px;width:80px}}.blackhole{width:10em;height:10em}.blackhole .mega{width:100%;height:100%;border-radius:100%;background:linear-gradient(#b494ba,#6845ba,#5f27e1);box-shadow:0 0 60px 30px #b38faf29;display:flex;justify-content:center;align-items:center;filter:blur(5px)}.blackhole .black{width:90%;height:90%;border-radius:45% 50% 50% 50%;background-color:#000;transform:rotate(0deg);animation:hole .1s linear infinite normal;color:#fff;content:"hi"}@keyframes hole{100%{transform:rotate(360deg)}}
</style>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<noscript>
<div class="container">
<h1>Filehole</h1>
<h1>{{ .SiteName }}</h1>
<form method="POST" enctype="multipart/form-data">
<label for="url_len">URL Length (5-169)</label>
<input type="number" name="url_len" id="url_len" min=5 max=169 value=24 /><br>
@ -32,8 +31,8 @@ body{background-color:#1a1c1d;color:#fff;font-family:monospace;font-size:14px;pa
<hr>
<h1>How to put your files in the hole</h1>
<h2>curl</h2>
<p><pre>curl -X POST -F 'file=@filehole.png' https://filehole.org</pre></p>
<p><pre>curl -X POST -F 'file=@filehole.png' -F "url_len=5" -F "expiry=86400" https://filehole.org</pre></p>
<p><pre>curl -X POST -F 'file=@picture.png' {{ .PublicUrl }}</pre></p>
<p><pre>curl -X POST -F 'file=@picture.png' -F "url_len=5" -F "expiry=86400" {{ .PublicUrl }}</pre></p>
<h2>Firefox</h2>
<a href="https://addons.mozilla.org/en-US/firefox/addon/post-image/">POST Image by rj1</a>
<h2>Mac OS</h2>
@ -42,7 +41,7 @@ body{background-color:#1a1c1d;color:#fff;font-family:monospace;font-size:14px;pa
</div>
<hr>
</noscript>
<h1>filehole</h1>
<h1>{{ .SiteName }}</h1>
<div class="slogan">deprogrammed edition</div>
<h2>drop some files into the hole</h2>
<div id="hole">

13
main.go

@ -118,10 +118,11 @@ func (fh FileholeServer) UploadHandler(w http.ResponseWriter, r *http.Request) {
var indexPage []byte
type FileholeServer struct {
Bind string // Address to bind ex. 127.0.0.1:8000
MetadataFile string // File metadata storage KV store filename ex. filehole.db
StorageDir string // Data storage folder ex. /data
PublicUrl string // The internet facing path of the site i.e. https://filehole.org
Bind string
MetadataFile string
StorageDir string
PublicUrl string
SiteName string
}
func getEnv(key, fallback string) string {
@ -139,6 +140,7 @@ func main() {
flag.StringVar(&fh.MetadataFile, "metadata-path", getEnv("FH_METADATA_FILE", "filehole.db"), "File metadata storage KV store filename ENV: FH_METADATA_FILE")
flag.StringVar(&fh.StorageDir, "storage-dir", getEnv("FH_STORAGE_DIR", "./data"), "Data storage folder ENV: FH_STORAGE_DIR")
flag.StringVar(&fh.PublicUrl, "public-url", getEnv("FH_PUBLIC_URL", "https://filehole.org"), "Internet facing URL of the base of the site ENV: FH_PUBLIC_URL")
flag.StringVar(&fh.SiteName, "site-name", getEnv("FH_SITE_NAME", "Filehole"), "User facing website branding ENV: FH_SITE_NAME")
flag.Parse()
@ -190,9 +192,8 @@ func main() {
t.Execute(w, map[string]interface{}{
"PublicUrl": fh.PublicUrl,
"SiteName": fh.SiteName,
})
// w.Write(indexPage)
}).Methods("GET")
r.HandleFunc("/", fh.UploadHandler).Methods("POST")