Set mime type in static file route, add icon

This commit is contained in:
Elara 2021-04-02 16:47:08 -07:00
parent 07af6923c1
commit 062f329448
3 changed files with 100 additions and 2 deletions

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="166mm"
height="166mm"
viewBox="0 0 166 166"
version="1.1"
id="svg849"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="simpledash.svg">
<defs
id="defs843" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.72141947"
inkscape:cx="314.43883"
inkscape:cy="314.96112"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1900"
inkscape:window-height="1041"
inkscape:window-x="10"
inkscape:window-y="29"
inkscape:window-maximized="0" />
<metadata
id="metadata846">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-21.908592,-64.461929)">
<circle
style="fill:#e6e6e6;stroke-width:0;paint-order:stroke markers fill"
id="path1412"
cx="104.90859"
cy="147.46193"
r="83" />
<circle
style="fill:#00ff66;stroke-width:0;paint-order:stroke markers fill"
id="path1412-3"
cx="105.03275"
cy="147.59273"
r="77.20079" />
<path
d="m 103.72385,155.85337 v 33.3874 H 61.989468 v -33.3874 h 41.734382 m 0,-8.34694 H 61.989468 a 8.346878,8.346878 0 0 0 -8.346883,8.34694 v 33.3874 a 8.346878,8.346878 0 0 0 8.346883,8.34694 h 41.734382 a 8.346878,8.346878 0 0 0 8.34689,-8.34694 v -33.3874 a 8.346878,8.346878 0 0 0 -8.34689,-8.34694 z"
fill="#626262"
id="path2"
style="stroke-width:4.17343" />
<path
d="m 149.63169,109.94549 v 20.86725 H 107.8973 v -20.86725 h 41.73439 m 0,-8.34694 H 107.8973 a 8.346878,8.346878 0 0 0 -8.346884,8.34694 v 20.86725 a 8.346878,8.346878 0 0 0 8.346884,8.34677 h 41.73439 a 8.346878,8.346878 0 0 0 8.34689,-8.34677 v -20.86725 a 8.346878,8.346878 0 0 0 -8.34689,-8.34694 z"
fill="#626262"
id="path4"
style="stroke-width:4.17343" />
<path
d="m 149.63169,155.85337 v 20.86708 h -20.8672 v -20.86708 h 20.8672 m 0,-8.34694 h -20.8672 a 8.346878,8.346878 0 0 0 -8.34687,8.34694 v 20.86708 a 8.346878,8.346878 0 0 0 8.34687,8.34694 h 20.8672 a 8.346878,8.346878 0 0 0 8.34689,-8.34694 v -20.86708 a 8.346878,8.346878 0 0 0 -8.34689,-8.34694 z"
fill="#626262"
id="path6"
style="stroke-width:4.17343" />
<path
d="m 82.85667,109.94549 v 20.86725 H 61.989468 V 109.94549 H 82.85667 m 0,-8.34694 H 61.989468 a 8.346878,8.346878 0 0 0 -8.346883,8.34694 v 20.86725 a 8.346878,8.346878 0 0 0 8.346883,8.34677 H 82.85667 a 8.346878,8.346878 0 0 0 8.34687,-8.34677 v -20.86725 a 8.346878,8.346878 0 0 0 -8.34687,-8.34694 z"
fill="#626262"
id="path8"
style="stroke-width:4.17343" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -17,6 +17,7 @@
<title>{{.SiteTitle}} - {{.PageTitle}}</title> <title>{{.SiteTitle}} - {{.PageTitle}}</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/css/bulma.min.css"> <link rel="stylesheet" type="text/css" href="/css/bulma.min.css">
<link rel="icon" type="image/svg+xml" href="/simpledash.svg">
<style> <style>
::-webkit-scrollbar {border-radius: 24px; width: 8px;} ::-webkit-scrollbar {border-radius: 24px; width: 8px;}
::-webkit-scrollbar-thumb {background: #e5e5e5; border-radius: 10px;} ::-webkit-scrollbar-thumb {background: #e5e5e5; border-radius: 10px;}
@ -44,7 +45,9 @@
<nav class="navbar" role="navigation" aria-label="main nav" > <nav class="navbar" role="navigation" aria-label="main nav" >
<div class="container"> <div class="container">
<div class="navbar-brand"> <div class="navbar-brand">
<a class="navbar-item" href="/">{{.SiteTitle}}</a> <a class="navbar-item" href="/">
{{.SiteTitle}}
</a>
<a role="button" class="navbar-burger" onclick="toggleNavMenu()" aria-label="menu" aria-expanded="false" id="navbarBurger"> <a role="button" class="navbar-burger" onclick="toggleNavMenu()" aria-label="menu" aria-expanded="false" id="navbarBurger">
<span aria-hidden="true"></span> <span aria-hidden="true"></span>

View File

@ -22,6 +22,7 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"io" "io"
"mime"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -233,6 +234,8 @@ func registerRoutes(app App) {
httpError(res, app.Templates["error"], app.Config, http.StatusNotFound, "This file was not found") httpError(res, app.Templates["error"], app.Config, http.StatusNotFound, "This file was not found")
return return
} }
// Set Content-Type header based on file extension
res.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(filePath)))
// Close file at end of function // Close file at end of function
defer file.Close() defer file.Close()
// Compress response // Compress response