From 657fb5d357fbcb885631cf0d81e4e55400955351 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Sun, 25 Oct 2020 23:02:52 +0500 Subject: [PATCH] Add default css --- main.go | 11 ++++++ metarrhiza | 2 +- templates/css.qtpl | 35 ++++++++++++++++++ templates/css.qtpl.go | 85 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 templates/css.qtpl create mode 100644 templates/css.qtpl.go diff --git a/main.go b/main.go index 140a926..422bc8b 100644 --- a/main.go +++ b/main.go @@ -99,6 +99,16 @@ func handlerRecentChanges(w http.ResponseWriter, rq *http.Request) { } } +func handlerStyle(w http.ResponseWriter, rq *http.Request) { + log.Println(rq.URL) + if _, err := os.Stat(WikiDir + "/static/common.css"); err == nil { + http.ServeFile(w, rq, WikiDir+"/static/common.css") + } else { + w.Header().Set("Content-Type", "text/css;charset=utf-8") + w.Write([]byte(templates.DefaultCSS())) + } +} + func main() { log.Println("Running MycorrhizaWiki β") parseCliArgs() @@ -122,6 +132,7 @@ func main() { http.HandleFunc("/favicon.ico", func(w http.ResponseWriter, rq *http.Request) { http.ServeFile(w, rq, WikiDir+"/static/favicon.ico") }) + http.HandleFunc("/static/common.css", handlerStyle) http.HandleFunc("/", func(w http.ResponseWriter, rq *http.Request) { http.Redirect(w, rq, "/page/"+util.HomePage, http.StatusSeeOther) }) diff --git a/metarrhiza b/metarrhiza index abb535c..46cc59e 160000 --- a/metarrhiza +++ b/metarrhiza @@ -1 +1 @@ -Subproject commit abb535c0a90e78b92f31f4bf25764dc1fa0e3122 +Subproject commit 46cc59eeca16e873b47fdda84009adabb4e82d2b diff --git a/templates/css.qtpl b/templates/css.qtpl new file mode 100644 index 0000000..981c47c --- /dev/null +++ b/templates/css.qtpl @@ -0,0 +1,35 @@ +{% func DefaultCSS() %} +@media screen and (min-width: 700px) { + main {margin: 0 auto; width: 700px;} +} +@media screen and (max-width: 700px) { + main {margin: 0; width: 100%;} +} +*, *::before, *::after {box-sizing: border-box;} +html {height:100%; padding:0; background-color:#ddd; +background-image: url("data:image/svg+xml,%3Csvg width='42' height='44' viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23bbbbbb' fill-opacity='0.4'%3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");} /* heropatterns.com */ +body {height:100%; margin:0; font-size:16px; font-family:sans-serif;} +main {padding:1rem; background-color: white; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2);} +main > form {margin-bottom:1rem;} +textarea {font-size:15px;} +.upload-text-form {height:90%;} +.upload-text-form textarea {width:100%;height:90%;} + +.wikilink_new {color:#a55858;} +.wikilink_new:visited {color:#a55858;} +.wikilink_external::after {content:"🌐"; margin-left: .5rem; font-size: small; text-decoration: none; align: bottom;} +.codeblock {background-color:#eee; padding:.5rem; font-size:16px; white-space: pre-wrap;} +.transclusion .codeblock {background-color:#ddd;} +.transclusion {background-color:#eee; padding:0 0 0 1.5rem;} +.transclusion__link {display: block; position: absolute; transform-origin: 0 0; transform: rotate(90deg); margin-top: 0.5rem; color: black; text-decoration: none;} + +.binary-container_with-img img, +.binary-container_with-video video, +.binary-container_with-audio audio {width: 100%} +.navi-title a {text-decoration:none;} + +nav ul {display:flex; padding-left:0; flex-wrap:wrap; margin-top:0;} +nav ul li {list-style-type:none;margin-right:1rem;} + +#new-name {width:100%;} +{% endfunc %} diff --git a/templates/css.qtpl.go b/templates/css.qtpl.go new file mode 100644 index 0000000..90e4c85 --- /dev/null +++ b/templates/css.qtpl.go @@ -0,0 +1,85 @@ +// Code generated by qtc from "css.qtpl". DO NOT EDIT. +// See https://github.com/valyala/quicktemplate for details. + +//line templates/css.qtpl:1 +package templates + +//line templates/css.qtpl:1 +import ( + qtio422016 "io" + + qt422016 "github.com/valyala/quicktemplate" +) + +//line templates/css.qtpl:1 +var ( + _ = qtio422016.Copy + _ = qt422016.AcquireByteBuffer +) + +//line templates/css.qtpl:1 +func StreamDefaultCSS(qw422016 *qt422016.Writer) { +//line templates/css.qtpl:1 + qw422016.N().S(` +@media screen and (min-width: 700px) { + main {margin: 0 auto; width: 700px;} +} +@media screen and (max-width: 700px) { + main {margin: 0; width: 100%;} +} +*, *::before, *::after {box-sizing: border-box;} +html {height:100%; padding:0; background-color:#ddd; +background-image: url("data:image/svg+xml,%3Csvg width='42' height='44' viewBox='0 0 42 44' xmlns='http://www.w3.org/2000/svg'%3E%3Cg id='Page-1' fill='none' fill-rule='evenodd'%3E%3Cg id='brick-wall' fill='%23bbbbbb' fill-opacity='0.4'%3E%3Cpath d='M0 0h42v44H0V0zm1 1h40v20H1V1zM0 23h20v20H0V23zm22 0h20v20H22V23z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");} /* heropatterns.com */ +body {height:100%; margin:0; font-size:16px; font-family:sans-serif;} +main {padding:1rem; background-color: white; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2);} +main > form {margin-bottom:1rem;} +textarea {font-size:15px;} +.upload-text-form {height:90%;} +.upload-text-form textarea {width:100%;height:90%;} + +.wikilink_new {color:#a55858;} +.wikilink_new:visited {color:#a55858;} +.wikilink_external::after {content:"🌐"; margin-left: .5rem; font-size: small; text-decoration: none; align: bottom;} +.codeblock {background-color:#eee; padding:.5rem; font-size:16px; white-space: pre-wrap;} +.transclusion .codeblock {background-color:#ddd;} +.transclusion {background-color:#eee; padding:0 0 0 1.5rem;} +.transclusion__link {display: block; position: absolute; transform-origin: 0 0; transform: rotate(90deg); margin-top: 0.5rem; color: black; text-decoration: none;} + +.binary-container_with-img img, +.binary-container_with-video video, +.binary-container_with-audio audio {width: 100%} +.navi-title a {text-decoration:none;} + +nav ul {display:flex; padding-left:0; flex-wrap:wrap; margin-top:0;} +nav ul li {list-style-type:none;margin-right:1rem;} + +#new-name {width:100%;} +`) +//line templates/css.qtpl:35 +} + +//line templates/css.qtpl:35 +func WriteDefaultCSS(qq422016 qtio422016.Writer) { +//line templates/css.qtpl:35 + qw422016 := qt422016.AcquireWriter(qq422016) +//line templates/css.qtpl:35 + StreamDefaultCSS(qw422016) +//line templates/css.qtpl:35 + qt422016.ReleaseWriter(qw422016) +//line templates/css.qtpl:35 +} + +//line templates/css.qtpl:35 +func DefaultCSS() string { +//line templates/css.qtpl:35 + qb422016 := qt422016.AcquireByteBuffer() +//line templates/css.qtpl:35 + WriteDefaultCSS(qb422016) +//line templates/css.qtpl:35 + qs422016 := string(qb422016.B) +//line templates/css.qtpl:35 + qt422016.ReleaseByteBuffer(qb422016) +//line templates/css.qtpl:35 + return qs422016 +//line templates/css.qtpl:35 +}