internal/static: Bundle resources automatically

This commit is contained in:
Tom Wiesing 2022-10-06 16:38:17 +02:00
parent 9ada07ce70
commit 464b1bf5dd
No known key found for this signature in database
27 changed files with 1503 additions and 28 deletions

6
.gitignore vendored
View file

@ -5,4 +5,8 @@ authorized_keys
*.zip
*.nq
go.work
go.work.sum
go.work.sum
node_modules
.parcel-cache
yarn-error.log

View file

@ -1,9 +1,16 @@
.PHONY: clean all
.PHONY: clean all deps
all: wdcli
all: wdcli frontend
wdcli:
wdcli: internal/component/static/dist
go build -o ./wdcli ./cmd/wdcli
internal/component/static/dist: internal/component/static/src
rm -rf internal/component/static/dist
cd internal/component/static/ && yarn dist
deps:
cd internal/component/static/ && yarn install
clean:
rm wdcli

View file

@ -1,6 +1,6 @@
<!DOCTYPE html>
<link rel="stylesheet" href="/static/control/dis.css">
<link rel="stylesheet" href="/static/control/autolink.css">
<link rel="stylesheet" href="/static/control/control.css">
<link rel="stylesheet" href="/static/autolink/autolink.css">
<title>Distillery Status Page</title>
<h1 id="top">Distillery Status Page</h1>
@ -77,4 +77,5 @@
Generated at <code>{{ .Time }}</code>
</footer>
<script src="/static/control/autolink.js"></script>
<script src="/static/autolink/autolink.js"></script>
<script src="/static/control/control.js"></script>

View file

@ -1,6 +1,6 @@
<!DOCTYPE html>
<link rel="stylesheet" href="/static/control/dis.css">
<link rel="stylesheet" href="/static/control/autolink.css">
<link rel="stylesheet" href="/static/control/control.css">
<link rel="stylesheet" href="/static/autolink/autolink.css">
<title>Distillery Status Page - {{ .Info.Slug }}</title>
<h1 id="top">Distillery Status Page - {{ .Info.Slug }}</h1>
@ -70,5 +70,5 @@
Generated at <code>{{ .Time }}</code>
</footer>
<script src="/static/control/autolink.js"></script>
<script src="/static/control/instance.js"></script>
<script src="/static/autolink/autolink.js"></script>
<script src="/static/control/control.js"></script>

View file

@ -1,5 +1,8 @@
<!DOCTYPE html>
<link rel="stylesheet" href="/static/home/home.css">
<link rel="stylesheet" href="/static/autolink/autolink.css">
<title>WissKI Distillery</title>
<h1>WissKI Distillery</h1>
@ -19,7 +22,9 @@
{{ end }}
</div>
<hr />
<footer>
Generated at <code>{{ .Time }}</code>
</footer>
<script src="/static/autolink/autolink.js"></script>
<script src="/static/home/home.js"></script>

View file

@ -0,0 +1,2 @@
.header-link{opacity:0;font-size:.8em;text-decoration:none;transition:opacity .2s ease-in-out .1s;position:relative;left:.5em}h2:hover .header-link,h3:hover .header-link,h4:hover .header-link,h5:hover .header-link,h6:hover .header-link{opacity:1}
/*# sourceMappingURL=autolink.css.map */

View file

@ -0,0 +1 @@
{"mappings":"ACAA,8HAcA","sources":["autolink/autolink.css","src/autolink/autolink.css"],"sourcesContent":[".header-link {\n opacity: 0;\n font-size: .8em;\n text-decoration: none;\n transition: opacity .2s ease-in-out .1s;\n position: relative;\n left: .5em;\n}\n\nh2:hover .header-link, h3:hover .header-link, h4:hover .header-link, h5:hover .header-link, h6:hover .header-link {\n opacity: 1;\n}\n\n/*# sourceMappingURL=autolink.css.map */\n",".header-link {\n position: relative;\n left: 0.5em;\n opacity: 0;\n font-size: 0.8em;\n\n transition: opacity 0.2s ease-in-out 0.1s;\n -webkit-transition: opacity 0.2s ease-in-out 0.1s;\n -moz-transition: opacity 0.2s ease-in-out 0.1s;\n -ms-transition: opacity 0.2s ease-in-out 0.1s;\n\n text-decoration: none;\n}\n\nh2:hover .header-link,\nh3:hover .header-link,\nh4:hover .header-link,\nh5:hover .header-link,\nh6:hover .header-link {\n opacity: 1;\n}"],"names":[],"version":3,"file":"autolink.css.map"}

View file

@ -0,0 +1,2 @@
(()=>{const e=e=>{const r=document.getElementsByTagName("h"+e);Array.from(r).forEach((e=>{void 0!==e.id&&""!==e.id&&e.appendChild((e=>{const r=document.createElement("a");return r.className="header-link",r.href="#"+e,r.innerHTML="#",r})(e.id))}))};Array(6).forEach(((r,a)=>e(a+1)))})();
//# sourceMappingURL=autolink.js.map

View file

@ -0,0 +1 @@
{"mappings":"MAGA,MAQMA,EAAkBC,IACpB,MAAMC,EAAUC,SAASC,qBAAqB,IAAMH,GACpDI,MAAMC,KAAKJ,GAASK,SAASC,SACA,IAAdA,EAAOC,IAAoC,KAAdD,EAAOC,IAC/CD,EAAOE,YAZK,CAACD,IACjB,MAAME,EAASR,SAASS,cAAc,KAItC,OAHAD,EAAOE,UAAY,cACnBF,EAAOG,KAAO,IAAML,EACpBE,EAAOI,UAAY,IACZJ,CAAM,EAOUK,CAAYR,EAAOC,IAAI,GAC5C,EAINJ,MAAM,GAAGE,SAAQ,CAACU,EAAGC,IAAMlB,EAAekB,EAAI,I","sources":["src/autolink/autolink.js"],"sourcesContent":["import \"./autolink.css\";\n\n/** Adapted from http://blog.parkermoore.de/2014/08/01/header-anchor-links-in-vanilla-javascript-for-github-pages-and-jekyll/ */\nconst anchorForId = (id) => {\n const anchor = document.createElement(\"a\")\n anchor.className = \"header-link\"\n anchor.href = \"#\" + id\n anchor.innerHTML = \"#\"\n return anchor\n}\n\nconst linkifyAnchors = (level) => {\n const headers = document.getElementsByTagName(\"h\" + level);\n Array.from(headers).forEach((header) => {\n if (typeof header.id === \"undefined\" || header.id === \"\") return\n header.appendChild(anchorForId(header.id))\n })\n}\n\n// linkify all the anchors from 1 ... 6\nArray(6).forEach((_, i) => linkifyAnchors(i + 1))"],"names":["$f0312a5caa2d901c$var$linkifyAnchors","level","headers","document","getElementsByTagName","Array","from","forEach","header","id","appendChild","anchor","createElement","className","href","innerHTML","$f0312a5caa2d901c$var$anchorForId","_","i"],"version":3,"file":"autolink.js.map"}

View file

@ -0,0 +1,2 @@
html{color:#1a1a1a;background-color:#fdfdfd;font-family:Roboto;font-size:20px;line-height:1.5}body{max-width:36em;-webkit-hyphens:auto;hyphens:auto;overflow-wrap:break-word;text-rendering:optimizelegibility;font-kerning:normal;margin:0 auto;padding:50px}@media (max-width:600px){body{padding:1em;font-size:.9em}}h1{margin-top:1.4em}h2,h3{margin-top:1em}code{color:#00f;font-family:Roboto Mono}p{text-align:justify;margin:1em 0}a,a:visited{color:#1a1a1a}footer{text-align:center;border-top:1px solid #1a1a1a;font-size:small}.wisski{padding-left:5px}.wisski.running{background-color:#9ada07}.wisski.stopped{background-color:#ff7a7a}
/*# sourceMappingURL=control.css.map */

View file

@ -0,0 +1 @@
{"mappings":"ACAA,8FAOA,gKAaA,yBACI,iCAMJ,oBAIA,qBAIA,wCAKA,kCAKA,0BAIA,sEC/CA,yBAIA,yCAIA","sources":["control/control.css","src/distillery.css","src/control/control.css"],"sourcesContent":["html {\n color: #1a1a1a;\n background-color: #fdfdfd;\n font-family: Roboto;\n font-size: 20px;\n line-height: 1.5;\n}\n\nbody {\n max-width: 36em;\n -webkit-hyphens: auto;\n hyphens: auto;\n overflow-wrap: break-word;\n text-rendering: optimizelegibility;\n font-kerning: normal;\n margin: 0 auto;\n padding: 50px;\n}\n\n@media (max-width: 600px) {\n body {\n padding: 1em;\n font-size: .9em;\n }\n}\n\nh1 {\n margin-top: 1.4em;\n}\n\nh2, h3 {\n margin-top: 1em;\n}\n\ncode {\n color: #00f;\n font-family: Roboto Mono;\n}\n\np {\n text-align: justify;\n margin: 1em 0;\n}\n\na, a:visited {\n color: #1a1a1a;\n}\n\nfooter {\n text-align: center;\n border-top: 1px solid #1a1a1a;\n font-size: small;\n}\n\n.wisski {\n padding-left: 5px;\n}\n\n.wisski.running {\n background-color: #9ada07;\n}\n\n.wisski.stopped {\n background-color: #ff7a7a;\n}\n\n/*# sourceMappingURL=control.css.map */\n","html {\n line-height: 1.5;\n font-family: Roboto;\n font-size: 20px;\n color: #1a1a1a;\n background-color: #fdfdfd;\n}\nbody {\n margin: 0 auto;\n max-width: 36em;\n padding-left: 50px;\n padding-right: 50px;\n padding-top: 50px;\n padding-bottom: 50px;\n hyphens: auto;\n overflow-wrap: break-word;\n text-rendering: optimizeLegibility;\n font-kerning: normal;\n}\n\n@media (max-width: 600px) {\n body {\n font-size: 0.9em;\n padding: 1em;\n }\n}\n\nh1 {\n margin-top: 1.4em;\n}\n\nh2,h3 {\n margin-top: 1em; \n}\n\ncode {\n font-family: Roboto Mono;\n color: blue;\n}\n\np {\n margin: 1em 0;\n text-align: justify;\n}\n\na, a:visited {\n color: #1a1a1a;\n}\n\nfooter {\n border-top: 1px solid #1a1a1a;\n font-size: small;\n text-align: center;\n}\n","@import '../distillery.css';\n\n.wisski {\n padding-left: 5px;\n}\n\n.wisski.running {\n background-color: #9ADA07;\n}\n\n.wisski.stopped {\n background-color: #ff7a7a;\n}\n"],"names":[],"version":3,"file":"control.css.map"}

View file

@ -0,0 +1,2 @@
(()=>{const e={date:e=>new Date(e.innerText).toISOString(),path:e=>{const t=e.innerText.split("/");return t[t.length-1]},pathbuilders:e=>{const n=window.pathbuilders,o=document.createElement("span");let c=!1;if(Object.keys(n).forEach((e=>{c=!0;const a=e+".xml",r=n[e];o.append(t(a,e,r,"application/xml")),o.append(document.createTextNode(" "))})),!c)return"(none)";const a=document.createElement("small");return a.append(document.createTextNode("(click to download)")),o.append(a),o}},t=(e,t,n,o)=>{const c=new Blob([n],{type:o??"text/plain"}),a=document.createElement("a");return a.target="_blank",a.download=e,a.href=URL.createObjectURL(c),a.append(document.createTextNode(t)),a};Object.keys(e).forEach((t=>{const n=e[t];document.querySelectorAll("code."+t).forEach((e=>{const t=n(e);if("string"==typeof t)return e.innerHTML="",void e.appendChild(document.createTextNode(t));e.parentNode.replaceChild(t,e)}))}))})();
//# sourceMappingURL=control.js.map

View file

@ -0,0 +1 @@
{"mappings":"MAAA,MAAMA,EAAQ,CACVC,KAASC,GACE,IAAKC,KAAKD,EAAQE,WAAYC,cAEzCC,KAASJ,IACL,MAAMK,EAAOL,EAAQE,UAAUI,MAAM,KACrC,OAAOD,EAAKA,EAAKE,OAAS,EAAE,EAEhCC,aAAiBR,IACb,MAAMQ,EAAeC,OAAOD,aACtBE,EAAUC,SAASC,cAAc,QAEvC,IAAIC,GAAY,EAWhB,GAVAC,OAAOC,KAAKP,GAAcQ,SAAQC,IAC9BJ,GAAY,EAEZ,MAAMK,EAAWD,EAAO,OAClBE,EAAOX,EAAaS,GAE1BP,EAAQU,OAAOC,EAAmBH,EAAUD,EAAME,EADrC,oBAEbT,EAAQU,OAAOT,SAASW,eAAe,KAAK,KAG3CT,EAAW,MAAO,SAEvB,MAAMU,EAAQZ,SAASC,cAAc,SAIrC,OAHAW,EAAMH,OAAOT,SAASW,eAAe,wBACrCZ,EAAQU,OAAOG,GAERb,CAAO,GAIhBW,EAAqB,CAACH,EAAUM,EAAOC,EAASC,KAClD,MAAMC,EAAO,IAAIC,KACb,CAACH,GACD,CACIC,KAAMA,GAAQ,eAIhBG,EAAOlB,SAASC,cAAc,KAMpC,OALAiB,EAAKC,OAAS,SACdD,EAAKE,SAAWb,EAChBW,EAAKG,KAAOC,IAAIC,gBAAgBP,GAChCE,EAAKT,OAAOT,SAASW,eAAeE,IAE7BK,CAAI,EAGff,OAAOC,KAAKjB,GAAOkB,SAAQmB,IACvB,MAAMC,EAAItC,EAAMqC,GACCxB,SAAS0B,iBAAiB,QAAUF,GAC5CnB,SAAQhB,IACb,MAAMsC,EAAaF,EAAEpC,GACrB,GAA0B,iBAAfsC,EAGP,OAFAtC,EAAQuC,UAAY,QACpBvC,EAAQwC,YAAY7B,SAASW,eAAegB,IAIhDtC,EAAQyC,WAAWC,aAAaJ,EAAYtC,EAAQ,GACtD,G","sources":["src/control/control.js"],"sourcesContent":["const types = {\n \"date\": (element) => {\n return (new Date(element.innerText)).toISOString()\n },\n \"path\": (element) => {\n const text = element.innerText.split(\"/\");\n return text[text.length - 1];\n },\n \"pathbuilders\": (element) => {\n const pathbuilders = window.pathbuilders; // read from context!\n const wrapper = document.createElement(\"span\");\n\n let found_one = false\n Object.keys(pathbuilders).forEach(name => {\n found_one = true\n\n const filename = name + \".xml\"\n const data = pathbuilders[name]\n const mime = \"application/xml\"\n wrapper.append(make_download_link(filename, name, data, mime))\n wrapper.append(document.createTextNode(\" \"))\n })\n\n if (!found_one) return '(none)';\n\n const small = document.createElement('small')\n small.append(document.createTextNode(\"(click to download)\"))\n wrapper.append(small)\n \n return wrapper\n }\n}\n\nconst make_download_link = (filename, title, content, type) => {\n const blob = new Blob(\n [content],\n {\n type: type ?? \"text/plain\"\n }\n );\n\n const link = document.createElement(\"a\")\n link.target = \"_blank\"\n link.download = filename\n link.href = URL.createObjectURL(blob)\n link.append(document.createTextNode(title))\n\n return link\n}\n\nObject.keys(types).forEach(key => {\n const f = types[key];\n const elements = document.querySelectorAll(\"code.\" + key)\n elements.forEach(element => {\n const newElement = f(element)\n if (typeof newElement === 'string') {\n element.innerHTML = \"\"\n element.appendChild(document.createTextNode(newElement))\n return\n }\n\n element.parentNode.replaceChild(newElement, element)\n })\n})"],"names":["$377ad6cb6486743d$var$types","date","element","Date","innerText","toISOString","path","text","split","length","pathbuilders","window","wrapper","document","createElement","found_one","Object","keys","forEach","name","filename","data","append","$377ad6cb6486743d$var$make_download_link","createTextNode","small","title","content","type","blob","Blob","link","target","download","href","URL","createObjectURL","key","f","querySelectorAll","newElement","innerHTML","appendChild","parentNode","replaceChild"],"version":3,"file":"control.js.map"}

View file

@ -0,0 +1,2 @@
html{color:#1a1a1a;background-color:#fdfdfd;font-family:Roboto;font-size:20px;line-height:1.5}body{max-width:36em;-webkit-hyphens:auto;hyphens:auto;overflow-wrap:break-word;text-rendering:optimizelegibility;font-kerning:normal;margin:0 auto;padding:50px}@media (max-width:600px){body{padding:1em;font-size:.9em}}h1{margin-top:1.4em}h2,h3{margin-top:1em}code{color:#00f;font-family:Roboto Mono}p{text-align:justify;margin:1em 0}a,a:visited{color:#1a1a1a}footer{text-align:center;border-top:1px solid #1a1a1a;font-size:small}
/*# sourceMappingURL=home.css.map */

View file

@ -0,0 +1 @@
{"mappings":"ACAA,8FAOA,gKAaA,yBACI,iCAMJ,oBAIA,qBAIA,wCAKA,kCAKA,0BAIA","sources":["home/home.css","src/distillery.css","src/home/home.css"],"sourcesContent":["html {\n color: #1a1a1a;\n background-color: #fdfdfd;\n font-family: Roboto;\n font-size: 20px;\n line-height: 1.5;\n}\n\nbody {\n max-width: 36em;\n -webkit-hyphens: auto;\n hyphens: auto;\n overflow-wrap: break-word;\n text-rendering: optimizelegibility;\n font-kerning: normal;\n margin: 0 auto;\n padding: 50px;\n}\n\n@media (max-width: 600px) {\n body {\n padding: 1em;\n font-size: .9em;\n }\n}\n\nh1 {\n margin-top: 1.4em;\n}\n\nh2, h3 {\n margin-top: 1em;\n}\n\ncode {\n color: #00f;\n font-family: Roboto Mono;\n}\n\np {\n text-align: justify;\n margin: 1em 0;\n}\n\na, a:visited {\n color: #1a1a1a;\n}\n\nfooter {\n text-align: center;\n border-top: 1px solid #1a1a1a;\n font-size: small;\n}\n\n\n\n/*# sourceMappingURL=home.css.map */\n","html {\n line-height: 1.5;\n font-family: Roboto;\n font-size: 20px;\n color: #1a1a1a;\n background-color: #fdfdfd;\n}\nbody {\n margin: 0 auto;\n max-width: 36em;\n padding-left: 50px;\n padding-right: 50px;\n padding-top: 50px;\n padding-bottom: 50px;\n hyphens: auto;\n overflow-wrap: break-word;\n text-rendering: optimizeLegibility;\n font-kerning: normal;\n}\n\n@media (max-width: 600px) {\n body {\n font-size: 0.9em;\n padding: 1em;\n }\n}\n\nh1 {\n margin-top: 1.4em;\n}\n\nh2,h3 {\n margin-top: 1em; \n}\n\ncode {\n font-family: Roboto Mono;\n color: blue;\n}\n\np {\n margin: 1em 0;\n text-align: justify;\n}\n\na, a:visited {\n color: #1a1a1a;\n}\n\nfooter {\n border-top: 1px solid #1a1a1a;\n font-size: small;\n text-align: center;\n}\n","@import '../distillery.css';"],"names":[],"version":3,"file":"home.css.map"}

View file

@ -0,0 +1,2 @@
//# sourceMappingURL=home.js.map

View file

@ -0,0 +1 @@
{"mappings":"","sources":[],"sourcesContent":[],"names":[],"version":3,"file":"home.js.map"}

View file

@ -0,0 +1,26 @@
{
"name": "wisski-distillery-frontend",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"dependencies": {
"parcel": "^2.7.0"
},
"scripts": {
"dist": "parcel build --dist-dir dist --target default"
},
"targets": {
"default": {
"source": [
"src/control/control.js",
"src/control/control.css",
"src/home/home.js",
"src/home/home.css",
"src/autolink/autolink.js"
]
}
}
}

View file

@ -4,6 +4,7 @@
opacity: 0;
font-size: 0.8em;
transition: opacity 0.2s ease-in-out 0.1s;
-webkit-transition: opacity 0.2s ease-in-out 0.1s;
-moz-transition: opacity 0.2s ease-in-out 0.1s;
-ms-transition: opacity 0.2s ease-in-out 0.1s;

View file

@ -1,3 +1,5 @@
import "./autolink.css";
/** Adapted from http://blog.parkermoore.de/2014/08/01/header-anchor-links-in-vanilla-javascript-for-github-pages-and-jekyll/ */
const anchorForId = (id) => {
const anchor = document.createElement("a")

View file

@ -0,0 +1,13 @@
@import '../distillery.css';
.wisski {
padding-left: 5px;
}
.wisski.running {
background-color: #9ADA07;
}
.wisski.stopped {
background-color: #ff7a7a;
}

View file

@ -52,16 +52,3 @@ footer {
font-size: small;
text-align: center;
}
.wisski {
padding-left: 5px;
}
.wisski.running {
background-color: #9ADA07;
}
.wisski.stopped {
background-color: #ff7a7a;
}

View file

@ -0,0 +1 @@
@import '../distillery.css';

View file

@ -0,0 +1 @@
/* nothing for now */

View file

@ -20,7 +20,7 @@ func (*Static) Name() string { return "static" }
func (*Static) Routes() []string { return []string{"/static/"} }
func (static *Static) Handler(route string, context context.Context, io stream.IOStream) (http.Handler, error) {
fs, err := fs.Sub(htmlStaticFS, "out")
fs, err := fs.Sub(distStaticFS, "dist")
if err != nil {
return nil, err
}
@ -28,5 +28,5 @@ func (static *Static) Handler(route string, context context.Context, io stream.I
return http.StripPrefix(route, http.FileServer(http.FS(fs))), nil
}
//go:embed out
var htmlStaticFS embed.FS
//go:embed dist
var distStaticFS embed.FS

File diff suppressed because it is too large Load diff