4 Commits
v1.6 ... v1.9

Author SHA1 Message Date
bel
da968c2fd4 update color scheme 2020-02-01 23:01:37 +00:00
bel
563eb7bb61 change textarea cursor 2020-01-26 18:41:12 +00:00
bel
b7f13bf33d extract gzip to own package 2020-01-26 18:08:20 +00:00
bel
d73cbe9e0c Add gzip 2020-01-26 17:48:43 +00:00
5 changed files with 33 additions and 9 deletions

View File

@@ -1,8 +1,11 @@
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29
RUN apk update && apk add --no-cache ca-certificates git
FROM golang:1.13-alpine as certs
RUN apk update && apk add --no-cache ca-certificates
FROM busybox:glibc
RUN mkdir -p /var/log RUN mkdir -p /var/log
WORKDIR /main WORKDIR /main
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY . . COPY . .
@@ -10,3 +13,4 @@ ENV GOPATH=""
ENV MNT="/mnt/" ENV MNT="/mnt/"
ENTRYPOINT ["/main/exec-notes-server"] ENTRYPOINT ["/main/exec-notes-server"]
CMD [] CMD []

View File

@@ -89,6 +89,8 @@ const defaultWrapper = `
} }
body { body {
font-size: 125%; font-size: 125%;
filter: hue-rotate(120deg);
background: #3b242b;
} }
</style> </style>
</header> </header>

View File

@@ -28,7 +28,7 @@ func editFile(p filetree.Path) string {
return fmt.Sprintf(` return fmt.Sprintf(`
<form action="/submit/%s" method="post" style="width:100%%; height: 90%%"> <form action="/submit/%s" method="post" style="width:100%%; height: 90%%">
<table style="width:100%%; height: 90%%"> <table style="width:100%%; height: 90%%">
<textarea name="content" style="width:100%%; min-height:90%%">%s</textarea> <textarea name="content" style="width:100%%; min-height:90%%; cursor:crosshair;">%s</textarea>
</table> </table>
<button type="submit">Submit</button> <button type="submit">Submit</button>
</form> </form>

View File

@@ -2,8 +2,10 @@ package server
import ( import (
"fmt" "fmt"
"local/gziphttp"
"local/router" "local/router"
"net/http" "net/http"
"path/filepath"
) )
func (s *Server) Routes() error { func (s *Server) Routes() error {
@@ -18,27 +20,27 @@ func (s *Server) Routes() error {
}, },
{ {
path: fmt.Sprintf("notes/%s%s", wildcard, wildcard), path: fmt.Sprintf("notes/%s%s", wildcard, wildcard),
handler: s.authenticate(s.notes), handler: s.gzip(s.authenticate(s.notes)),
}, },
{ {
path: fmt.Sprintf("edit/%s%s", wildcard, wildcard), path: fmt.Sprintf("edit/%s%s", wildcard, wildcard),
handler: s.authenticate(s.edit), handler: s.gzip(s.authenticate(s.edit)),
}, },
{ {
path: fmt.Sprintf("delete/%s%s", wildcard, wildcard), path: fmt.Sprintf("delete/%s%s", wildcard, wildcard),
handler: s.authenticate(s.delete), handler: s.gzip(s.authenticate(s.delete)),
}, },
{ {
path: fmt.Sprintf("submit/%s%s", wildcard, wildcard), path: fmt.Sprintf("submit/%s%s", wildcard, wildcard),
handler: s.authenticate(s.submit), handler: s.gzip(s.authenticate(s.submit)),
}, },
{ {
path: fmt.Sprintf("create/%s%s", wildcard, wildcard), path: fmt.Sprintf("create/%s%s", wildcard, wildcard),
handler: s.authenticate(s.create), handler: s.gzip(s.authenticate(s.create)),
}, },
{ {
path: fmt.Sprintf("search"), path: fmt.Sprintf("search"),
handler: s.authenticate(s.search), handler: s.gzip(s.authenticate(s.search)),
}, },
} }
@@ -54,3 +56,17 @@ func (s *Server) root(w http.ResponseWriter, r *http.Request) {
r.URL.Path = "/notes" r.URL.Path = "/notes"
http.Redirect(w, r, r.URL.String(), http.StatusPermanentRedirect) http.Redirect(w, r, r.URL.String(), http.StatusPermanentRedirect)
} }
func (s *Server) gzip(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if gziphttp.Can(r) {
gz := gziphttp.New(w)
defer gz.Close()
w = gz
}
if filepath.Ext(r.URL.Path) == ".css" {
w.Header().Set("Content-Type", "text/css; charset=utf-8")
}
h(w, r)
}
}

View File

@@ -20,6 +20,8 @@
} }
body { body {
font-size: 125%; font-size: 125%;
filter: hue-rotate(120deg);
background: #3b242b;
} }
</style> </style>
</header> </header>