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
WORKDIR /main
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY . .
@@ -10,3 +13,4 @@ ENV GOPATH=""
ENV MNT="/mnt/"
ENTRYPOINT ["/main/exec-notes-server"]
CMD []

View File

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

View File

@@ -28,7 +28,7 @@ func editFile(p filetree.Path) string {
return fmt.Sprintf(`
<form action="/submit/%s" method="post" 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>
<button type="submit">Submit</button>
</form>

View File

@@ -2,8 +2,10 @@ package server
import (
"fmt"
"local/gziphttp"
"local/router"
"net/http"
"path/filepath"
)
func (s *Server) Routes() error {
@@ -18,27 +20,27 @@ func (s *Server) Routes() error {
},
{
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),
handler: s.authenticate(s.edit),
handler: s.gzip(s.authenticate(s.edit)),
},
{
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),
handler: s.authenticate(s.submit),
handler: s.gzip(s.authenticate(s.submit)),
},
{
path: fmt.Sprintf("create/%s%s", wildcard, wildcard),
handler: s.authenticate(s.create),
handler: s.gzip(s.authenticate(s.create)),
},
{
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"
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 {
font-size: 125%;
filter: hue-rotate(120deg);
background: #3b242b;
}
</style>
</header>