6 Commits
v1.7 ... v1.11

Author SHA1 Message Date
bel
9785ef5e1e Add serach bar to search page 2020-03-09 03:09:45 +00:00
bel
3b7aa70e44 fix table and toc colors 2020-03-09 03:06:54 +00:00
Bel LaPointe
c067b426a9 Fix colors breaking floating css because fuck 2020-03-08 20:37:48 -06:00
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
10 changed files with 171 additions and 118 deletions

File diff suppressed because one or more lines are too long

129
config/rotate.py Executable file
View File

@@ -0,0 +1,129 @@
#! /usr/local/bin/python3
def main(args) :
print("args", args)
for i in args :
rotate(i)
def rotate(x) :
print("input: {}", x)
rgb = hex_to_rgb(x)
print("rgb: {}", rgb)
hsl = rgb_to_hsl(rgb)
print("hsl: {}", hsl)
import os
env = os.environ
if "DEG" in env :
deg = int(env["DEG"])
else :
deg = 110
hsl = rotate_hsl(hsl, deg)
print("hsl': {}", hsl)
rgb = hsl_to_rgb(hsl)
print("rgb': {}", rgb)
print(rgb_to_hex(rgb))
def hex_to_rgb(x) :
if x.startswith("#") :
x = x[1:]
r = x[0:2]
g = x[2:4]
b = x[4:6]
return (
hex_to_dec(r),
hex_to_dec(g),
hex_to_dec(b),
)
def hex_to_dec(x) :
s = 0
mul = 1
for i in range(len(x)):
c = x[len(x)-i-1]
c = c.upper()
digit = ord(c) - ord('0')
if not c.isdigit() :
digit = ord(c) - ord('A') + 10
s += mul * digit
mul *= 16
return s
def rgb_to_hsl(rgb) :
return (
compute_h(rgb),
compute_s(rgb),
compute_l(rgb),
)
def compute_h(rgb) :
r, g, b, cmax, cmin, delta = compute_hsl_const(rgb)
if delta == 0 :
return 0
if r == cmax :
return 60 * ( ( (g - b)/delta ) % 6)
if g == cmax :
return 60 * ( ( (b - r)/delta ) + 2)
if b == cmax :
return 60 * ( ( (r - g)/delta ) + 4)
def compute_s(rgb) :
r, g, b, cmax, cmin, delta = compute_hsl_const(rgb)
if delta == 0 :
return 0
return delta / ( 1 - (abs(2*compute_l(rgb)-1)) )
def compute_l(rgb) :
r, g, b, cmax, cmin, delta = compute_hsl_const(rgb)
return (cmax + cmin) / 2
def compute_hsl_const(rgb) :
rgb = [ i/255.0 for i in rgb ]
return rgb[:] + [max(rgb), min(rgb), max(rgb)-min(rgb)]
def rotate_hsl(hsl, deg) :
return (
(hsl[0] + deg) % 360,
hsl[1],
hsl[2],
)
def hsl_to_rgb(hsl) :
h = hsl[0]
s = hsl[1]
l = hsl[2]
c = s * (1 - abs(2 * l))
x = c * (1 - abs((h / 60) % 2 - 1))
m = l - (c / 2)
rgbp = ()
if h < 60 :
rgbp = (c, x, 0)
if h < 120 :
rgbp = (x, c, 0)
if h < 180 :
rgbp = (0, c, x)
if h < 240 :
rgbp = (0, x, c)
if h < 300 :
rgbp = (x, 0, c)
else:
rgbp = (c, 0, x)
r = rgbp[0]
g = rgbp[1]
b = rgbp[2]
return (
(r+m)*255,
(g+m)*255,
(b+m)*255,
)
def rgb_to_hex(rgb) :
r = min(max(int(rgb[0]), 0), 255)
g = min(max(int(rgb[1]), 0), 255)
b = min(max(int(rgb[2]), 0), 255)
return "#{:02x}{:02x}{:02x}".format(r, g, b)
from sys import argv
main(argv[1:])

1
config/water.css Submodule

Submodule config/water.css added at 7e86e4f67c

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

@@ -1,49 +0,0 @@
package server
import (
"compress/gzip"
"fmt"
"net/http"
"strings"
)
type GZipResponseWriter struct {
w http.ResponseWriter
gz *gzip.Writer
}
func NewGZipResponseWriter(w http.ResponseWriter) *GZipResponseWriter {
w.Header().Add("Content-Type", "text/html")
w.Header().Add("Content-Encoding", "gzip")
return &GZipResponseWriter{
w: w,
gz: gzip.NewWriter(w),
}
}
func (gz *GZipResponseWriter) Header() http.Header {
return gz.w.Header()
}
func (gz *GZipResponseWriter) WriteHeader(statusCode int) {
gz.w.WriteHeader(statusCode)
}
func (gz *GZipResponseWriter) Write(b []byte) (int, error) {
return gz.gz.Write(b)
}
func (gz *GZipResponseWriter) Close() error {
return gz.gz.Close()
}
func (s *Server) gzip(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if encoding, _ := r.Header["Accept-Encoding"]; strings.Contains(fmt.Sprint(encoding), "gzip") {
gz := NewGZipResponseWriter(w)
defer gz.Close()
w = gz
}
h(w, r)
}
}

View File

@@ -1,34 +0,0 @@
package server
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)
func TestGZipResponseWriter(t *testing.T) {
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gz := NewGZipResponseWriter(w)
defer gz.Close()
fmt.Fprintln(gz, "Hello world")
}))
defer s.Close()
req := httptest.NewRequest("GET", s.URL, nil)
req.RequestURI = ""
resp, err := http.DefaultClient.Do(req)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatal(resp.StatusCode)
}
if b, err := ioutil.ReadAll(resp.Body); err != nil {
t.Fatal(err)
} else if s := string(b); s != "Hello world\n" {
t.Fatalf("%q", s)
}
}

View File

@@ -22,7 +22,7 @@ func (s *Server) notes(w http.ResponseWriter, r *http.Request) {
}
func notesHead(w http.ResponseWriter, p filetree.Path) {
fmt.Fprintln(w, h2(p.MultiLink(), "margin: 0; position: fixed; padding: .25em; background-color: #202b38; width: 100%; top: 0;"))
fmt.Fprintln(w, h2(p.MultiLink()))
htmlSearch(w)
}

View File

@@ -2,8 +2,10 @@ package server
import (
"fmt"
"local/gziphttp"
"local/router"
"net/http"
"path/filepath"
)
func (s *Server) Routes() error {
@@ -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

@@ -21,6 +21,7 @@ func (s *Server) search(w http.ResponseWriter, r *http.Request) {
}
head(w, r)
fmt.Fprintln(w, h2(filetree.NewPathFromURL("/notes").MultiLink()))
htmlSearch(w)
fmt.Fprintln(w, h1(keywords), results)
foot(w, r)
}

View File

@@ -1,31 +0,0 @@
<html>
<header>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/dark.min.css -->
<style>
@charset "UTF-8";body{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;line-height:1.4;max-width:800px;margin:20px auto;padding:0 10px;color:#dbdbdb;background:#202b38;text-rendering:optimizeLegibility}button,input,textarea{transition:background-color .1s linear,border-color .1s linear,color .1s linear,box-shadow .1s linear,transform .1s ease}h1{font-size:2.2em;margin-top:0}h1,h2,h3,h4,h5,h6{margin-bottom:12px}h1,h2,h3,h4,h5,h6,strong{color:#fff}b,h1,h2,h3,h4,h5,h6,strong,th{font-weight:600}blockquote{border-left:4px solid rgba(0,150,191,.67);margin:1.5em 0;padding:.5em 1em;font-style:italic}blockquote>footer{margin-top:10px;font-style:normal}address,blockquote cite{font-style:normal}a[href^=mailto]:before{content:"📧 "}a[href^=tel]:before{content:"📞 "}a[href^=sms]:before{content:"💬 "}button,input[type=button],input[type=checkbox],input[type=submit]{cursor:pointer}input:not([type=checkbox]):not([type=radio]),select{display:block}button,input,select,textarea{color:#fff;background-color:#161f27;font-family:inherit;font-size:inherit;margin-right:6px;margin-bottom:6px;padding:10px;border:none;border-radius:6px;outline:none}button,input:not([type=checkbox]):not([type=radio]),select,textarea{-webkit-appearance:none}textarea{margin-right:0;width:100%;box-sizing:border-box;resize:vertical}button,input[type=button],input[type=submit]{padding-right:30px;padding-left:30px}button:hover,input[type=button]:hover,input[type=submit]:hover{background:#324759}button:focus,input:focus,select:focus,textarea:focus{box-shadow:0 0 0 2px rgba(0,150,191,.67)}button:active,input[type=button]:active,input[type=checkbox]:active,input[type=radio]:active,input[type=submit]:active{transform:translateY(2px)}button:disabled,input:disabled,select:disabled,textarea:disabled{cursor:not-allowed;opacity:.5}::-webkit-input-placeholder{color:#a9a9a9}:-ms-input-placeholder{color:#a9a9a9}::-ms-input-placeholder{color:#a9a9a9}::placeholder{color:#a9a9a9}a{text-decoration:none;color:#41adff}a:hover{text-decoration:underline}code,kbd{background:#161f27;color:#ffbe85;padding:5px;border-radius:6px}pre>code{padding:10px;display:block;overflow-x:auto}img{max-width:100%}hr{border:none;border-top:1px solid #dbdbdb}table{border-collapse:collapse;margin-bottom:10px;width:100%}td,th{padding:6px;text-align:left}th{border-bottom:1px solid #dbdbdb}tbody tr:nth-child(2n){background-color:#161f27}::-webkit-scrollbar{height:10px;width:10px}::-webkit-scrollbar-track{background:#161f27;border-radius:6px}::-webkit-scrollbar-thumb{background:#324759;border-radius:6px}::-webkit-scrollbar-thumb:hover{background:#415c73}
</style>
<style>
nav {
display: block;
background: #161f27;
padding: .5pt;
border-radius: 6px;
}
nav li li li li {
display: none;
}
img {
max-height: 400px;
}
body {
font-size: 125%;
}
</style>
</header>
<body height="100%">
{{{}}}
</body>
<footer>
</footer>
</html>