Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0002243ffd | ||
|
|
d90ef4c1a5 | ||
|
|
1c45c4d7a2 | ||
|
|
c130c3af69 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
*.key
|
*.key
|
||||||
simpleserve
|
|
||||||
*.crt
|
*.crt
|
||||||
*.pem
|
*.pem
|
||||||
*.swp
|
*.swp
|
||||||
|
|||||||
1
deploy_erazuno.sh
Normal file
1
deploy_erazuno.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=0 go build -a -installsuffix cgo -o exec-simpleserve && scp -i $HOME/.ssh/id_rsa ./exec-simpleserve zach@192.168.1.123:/var/services/homes/zach/erazuno/exec-simpleserve.new; rm ./exec-simpleserve
|
||||||
14
main.go
14
main.go
@@ -57,24 +57,33 @@ func main() {
|
|||||||
.%s {
|
.%s {
|
||||||
width: auto !important;
|
width: auto !important;
|
||||||
/*height: auto !important;*/
|
/*height: auto !important;*/
|
||||||
height: 100%% !important;
|
/*height: 100%% !important;
|
||||||
column-count: auto !important;
|
column-count: auto !important;
|
||||||
-webkit-column-count: auto !important;
|
-webkit-column-count: auto !important;*/
|
||||||
overflow: auto !important;
|
overflow: auto !important;
|
||||||
background-repeat: repeat-x;
|
background-repeat: repeat-x;
|
||||||
}
|
}
|
||||||
.%s h1 {
|
.%s h1 {
|
||||||
|
/*
|
||||||
column-span: none !important;
|
column-span: none !important;
|
||||||
-webkit-column-span: none !important;
|
-webkit-column-span: none !important;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
.%s hr+table {
|
||||||
|
margin-top: 40px !important;
|
||||||
}
|
}
|
||||||
.%s nav {
|
.%s nav {
|
||||||
|
/*
|
||||||
background: none !important;
|
background: none !important;
|
||||||
|
*/
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
%s
|
%s
|
||||||
</style>`,
|
</style>`,
|
||||||
mdClass,
|
mdClass,
|
||||||
mdClass,
|
mdClass,
|
||||||
mdClass,
|
mdClass,
|
||||||
|
mdClass,
|
||||||
b,
|
b,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -180,6 +189,7 @@ func withMD(dir string, enabled bool, mdCss, mdClass string, foo http.HandlerFun
|
|||||||
}
|
}
|
||||||
fmt.Fprintln(w, mdCss)
|
fmt.Fprintln(w, mdCss)
|
||||||
fmt.Fprintf(w, "<div class=%q>", mdClass)
|
fmt.Fprintf(w, "<div class=%q>", mdClass)
|
||||||
|
s = strings.ReplaceAll(s, "<nav>", `<nav class="toc">`)
|
||||||
fmt.Fprintln(w, s)
|
fmt.Fprintln(w, s)
|
||||||
fmt.Fprintf(w, "</div>")
|
fmt.Fprintf(w, "</div>")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
70
simpleserve/simpleserve.go
Executable file
70
simpleserve/simpleserve.go
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
package simpleserve
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetContentTypeIfMedia(w http.ResponseWriter, r *http.Request) {
|
||||||
|
ext := strings.ToLower(path.Ext(r.URL.Path))
|
||||||
|
if i := strings.LastIndex(ext, "."); i != -1 {
|
||||||
|
ext = ext[i:]
|
||||||
|
}
|
||||||
|
k := "Content-Type"
|
||||||
|
v := ""
|
||||||
|
switch ext {
|
||||||
|
case ".mp4":
|
||||||
|
v = "video/mp4"
|
||||||
|
case ".mkv":
|
||||||
|
v = "video/x-matroska"
|
||||||
|
case ".mp3":
|
||||||
|
v = "audio/mpeg3"
|
||||||
|
case ".epub", ".mobi":
|
||||||
|
k = "Content-Disposition"
|
||||||
|
v = "attachment"
|
||||||
|
case ".jpg", ".jpeg":
|
||||||
|
v = "image/jpeg"
|
||||||
|
case ".md":
|
||||||
|
v = "text/markdown"
|
||||||
|
case ".gif":
|
||||||
|
v = "image/gif"
|
||||||
|
case ".png":
|
||||||
|
v = "image/png"
|
||||||
|
case ".ico":
|
||||||
|
v = "image/x-icon"
|
||||||
|
case ".svg":
|
||||||
|
v = "image/svg+xml"
|
||||||
|
case ".css":
|
||||||
|
v = "text/css"
|
||||||
|
case ".js":
|
||||||
|
v = "text/javascript"
|
||||||
|
case ".json":
|
||||||
|
v = "application/json"
|
||||||
|
case ".html", ".htm":
|
||||||
|
v = "text/html"
|
||||||
|
case ".pdf":
|
||||||
|
w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename=%q", path.Base(r.URL.Path)))
|
||||||
|
v = "application/pdf"
|
||||||
|
case ".webm":
|
||||||
|
v = "video/webm"
|
||||||
|
case ".weba":
|
||||||
|
v = "audio/webm"
|
||||||
|
case ".webp":
|
||||||
|
v = "image/webp"
|
||||||
|
case ".zip":
|
||||||
|
v = "application/zip"
|
||||||
|
case ".7z":
|
||||||
|
v = "application/x-7z-compressed"
|
||||||
|
case ".tar":
|
||||||
|
v = "application/x-tar"
|
||||||
|
case ".m4b":
|
||||||
|
v = "application/octet-stream"
|
||||||
|
case ".xml", ".rss", ".feed", ".rdf":
|
||||||
|
v = "application/rss+xml"
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set(k, v)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user