partage

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/partage.git
Log | Files | Refs | README | LICENSE

commit 46826d3f0a786487dbdcc7638e568dd057612251
parent 8f1f9b5cd01c58ed94a0ebfb3bd685983d047bc7
Author: Willy Goiffon <dev@z3bra.org>
Date:   Thu, 21 Oct 2021 00:03:58 +0200

Reuse index.html template for file upload

Diffstat:
Mexample/templates/index.html | 7+++++--
Dexample/templates/upload.html | 22----------------------
Mpartage.go | 7+++++--
3 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/example/templates/index.html b/example/templates/index.html @@ -33,7 +33,10 @@ </section> </form> <p>File size limited to {{.Maxsize}}.</p> - <div id="uploads"></div> - <script src="/dz.js"></script> + <div id="uploads">{{if .Links}} + <ul> + {{range .Links}}<li><a href="{{.}}">{{.}}</a></li>{{end}} + </ul> + {{end}}</div> </body> </html> diff --git a/example/templates/upload.html b/example/templates/upload.html @@ -1,22 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <meta charset="utf-8"> - <meta name="author" content="z3bra"> - <meta name="viewport" content="width=device-width"> - <link rel="stylesheet" type="text/css" href="/partage.css" /> - <link rel="icon" type="image/ico" href="/favicon.ico" /> - <title>Partage</title> -</head> -<body> - <header> - <img id="logo" src="/partage.png" /> - <h1>partage</h1> - </header> - <ul> - {{range .Links}} - <li><a href="{{.}}">{{.}}</a></li> - {{end}} - </ul> -</body> -</html> diff --git a/partage.go b/partage.go @@ -204,8 +204,11 @@ func uploaderPost(w http.ResponseWriter, r *http.Request) { switch r.PostFormValue("output") { case "html": - data := templatedata{Links: links} - servetemplate(w, "/upload.html", data) + data := templatedata{ + Maxsize: humanize.IBytes(uint64(conf.maxsize)), + Links: links, + } + servetemplate(w, "/index.html", data) case "json": data, _ := json.Marshal(links) w.Write(data)