aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeuerfuchs <git@feuerfuchs.dev>2019-06-07 09:09:47 +0200
committerFeuerfuchs <git@feuerfuchs.dev>2019-06-07 09:09:47 +0200
commit49889fe083ce8cab6e340f6fb999cc8ebe42ad69 (patch)
tree3bf3c30732a30fe6f5c42a68ae82cc5f469c3f5b
parentImproved template readability (diff)
downloadgopherproxy-49889fe083ce8cab6e340f6fb999cc8ebe42ad69.tar.gz
gopherproxy-49889fe083ce8cab6e340f6fb999cc8ebe42ad69.tar.bz2
gopherproxy-49889fe083ce8cab6e340f6fb999cc8ebe42ad69.zip
Embed CSS in executable the same way as fonts
-rw-r--r--Makefile3
-rw-r--r--assets/style.css1
-rw-r--r--gopherproxy.go18
-rw-r--r--style.go3
4 files changed, 15 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 247b88c..f25707c 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,7 @@ dev: build
6 ./gopherproxy -bind 127.0.0.1:8000 6 ./gopherproxy -bind 127.0.0.1:8000
7 7
8build: clean 8build: clean
9 sassc -t compressed css/main.scss style.go 9 sassc -t compressed css/main.scss assets/style.css
10 sed -i "s/.*/package gopherproxy\n\nvar styletext = \`&\`/" style.go
11 pyftsubset fonts/iosevka-term-ss03-regular.ttf --name-IDs+=0,4,6 --text-file=glyphs.txt --flavor='woff' --output-file='assets/iosevka-term-ss03-regular.woff' 10 pyftsubset fonts/iosevka-term-ss03-regular.ttf --name-IDs+=0,4,6 --text-file=glyphs.txt --flavor='woff' --output-file='assets/iosevka-term-ss03-regular.woff'
12 pyftsubset fonts/iosevka-term-ss03-regular.ttf --name-IDs+=0,4,6 --text-file=glyphs.txt --flavor='woff2' --output-file='assets/iosevka-term-ss03-regular.woff2' 11 pyftsubset fonts/iosevka-term-ss03-regular.ttf --name-IDs+=0,4,6 --text-file=glyphs.txt --flavor='woff2' --output-file='assets/iosevka-term-ss03-regular.woff2'
13 go build -o ./gopherproxy ./cmd/gopherproxy/main.go 12 go build -o ./gopherproxy ./cmd/gopherproxy/main.go
diff --git a/assets/style.css b/assets/style.css
new file mode 100644
index 0000000..938e25e
--- /dev/null
+++ b/assets/style.css
@@ -0,0 +1 @@
@font-face{font-family:'Iosevka Term SS03';font-style:normal;font-weight:normal;src:url("/iosevka-term-ss03-regular.woff2") format("woff2"),url("/iosevka-term-ss03-regular.woff") format("woff")}body{margin:0;padding:0;background-color:#14171a;color:#cad1d8}.wrap{text-align:center}.content{display:inline-block;min-width:50em;min-width:85ch;margin:0;padding:2em 1em;text-align:left;font-family:'Iosevka Term SS03', 'IBM Plex Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Droid Sans Mono', Monaco, Consolas, Courier, monospace;font-size:1em;line-height:1.5}::selection{color:#000;background-color:rgba(239,198,138,0.996)}:link{color:#fff}:visited{color:#cad1d8}.link-type{color:#929ba3}
diff --git a/gopherproxy.go b/gopherproxy.go
index e41af3d..b65418d 100644
--- a/gopherproxy.go
+++ b/gopherproxy.go
@@ -208,14 +208,22 @@ func ListenAndServe(bind, robotsfile, uri string) error {
208 } 208 }
209 } 209 }
210 210
211 styledata, err := ioutil.ReadFile(".style")
212 if err == nil {
213 styletext = string(styledata)
214 }
215
216 box := packr.NewBox("./assets") 211 box := packr.NewBox("./assets")
212
217 fontdataw, err := box.Find("iosevka-term-ss03-regular.woff") 213 fontdataw, err := box.Find("iosevka-term-ss03-regular.woff")
214 if err != nil {
215 fontdataw = []byte{}
216 }
217
218 fontdataw2, err := box.Find("iosevka-term-ss03-regular.woff2") 218 fontdataw2, err := box.Find("iosevka-term-ss03-regular.woff2")
219 if err != nil {
220 fontdataw2 = []byte{}
221 }
222
223 styletext, err := box.FindString("style.css")
224 if err != nil {
225 styletext = ""
226 }
219 227
220 tpldata, err := ioutil.ReadFile(".template") 228 tpldata, err := ioutil.ReadFile(".template")
221 if err == nil { 229 if err == nil {
diff --git a/style.go b/style.go
deleted file mode 100644
index 7e1bdb9..0000000
--- a/style.go
+++ /dev/null
@@ -1,3 +0,0 @@
1package gopherproxy
2
3var styletext = `@font-face{font-family:'Iosevka Term SS03';font-style:normal;font-weight:normal;src:url("/iosevka-term-ss03-regular.woff2") format("woff2"),url("/iosevka-term-ss03-regular.woff") format("woff")}body{margin:0;padding:0;background-color:#14171a;color:#cad1d8}.wrap{text-align:center}.content{display:inline-block;min-width:50em;min-width:85ch;margin:0;padding:2em 1em;text-align:left;font-family:'Iosevka Term SS03', 'IBM Plex Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Droid Sans Mono', Monaco, Consolas, Courier, monospace;font-size:1em;line-height:1.5}::selection{color:#000;background-color:rgba(239,198,138,0.996)}:link{color:#fff}:visited{color:#cad1d8}.link-type{color:#929ba3}`