tReuse index.html template for file upload - partage - File upload system
 (HTM) git clone git://git.z3bra.org/partage.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 46826d3f0a786487dbdcc7638e568dd057612251
 (DIR) parent 8f1f9b5cd01c58ed94a0ebfb3bd685983d047bc7
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Thu, 21 Oct 2021 00:03:58 +0200
       
       Reuse index.html template for file upload
       
       Diffstat:
         M example/templates/index.html        |       7 +++++--
         D example/templates/upload.html       |      22 ----------------------
         M partage.go                          |       7 +++++--
       
       3 files changed, 10 insertions(+), 26 deletions(-)
       ---
 (DIR) diff --git a/example/templates/index.html b/example/templates/index.html
       t@@ -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>
 (DIR) diff --git a/example/templates/upload.html b/example/templates/upload.html
       t@@ -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>
 (DIR) diff --git a/partage.go b/partage.go
       t@@ -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)