3 Commits
v0.11 ... v0.12

Author SHA1 Message Date
Bel LaPointe
0002243ffd whoops 2021-08-17 12:56:02 -06:00
Bel LaPointe
d90ef4c1a5 del 2020-11-07 09:48:01 -07:00
Bel LaPointe
1c45c4d7a2 More overload 2020-09-28 14:45:19 -06:00
4 changed files with 82 additions and 3 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,4 @@
*.key *.key
simpleserve
*.crt *.crt
*.pem *.pem
*.swp *.swp

1
deploy_erazuno.sh Normal file
View 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

13
main.go
View File

@@ -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,
) )
} }

70
simpleserve/simpleserve.go Executable file
View 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)
}