mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-17 16:58:50 +00:00
bring static files into regular build process
This commit is contained in:
@ -263,6 +263,17 @@ HTTPResponse WebServer::generateReadResponse(lmdb::txn &txn, Decompressor &decom
|
||||
}
|
||||
} else if (u.path[0] == "post") {
|
||||
body = tmpl::newPost(nullptr);
|
||||
} else if (u.path[0] == "static" && u.path.size() >= 2) {
|
||||
if (u.path[1] == "oddbean.js") {
|
||||
rawBody = std::string(oddbeanStatic__oddbean_js());
|
||||
contentType = "application/javascript";
|
||||
} else if (u.path[1] == "oddbean.css") {
|
||||
rawBody = std::string(oddbeanStatic__oddbean_css());
|
||||
contentType = "text/css";
|
||||
} else if (u.path[1] == "oddbean.svg") {
|
||||
rawBody = std::string(oddbeanStatic__oddbean_svg());
|
||||
contentType = "image/svg+xml";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -282,7 +293,7 @@ HTTPResponse WebServer::generateReadResponse(lmdb::txn &txn, Decompressor &decom
|
||||
*body,
|
||||
communitySpec,
|
||||
title,
|
||||
"http://127.0.0.1:8081",
|
||||
cfg().web__staticFilesPrefix.size() ? cfg().web__staticFilesPrefix : "/static",
|
||||
};
|
||||
|
||||
responseData = std::move(tmpl::main(ctx).str);
|
||||
|
@ -10,3 +10,6 @@ config:
|
||||
- name: web__homepageCommunity
|
||||
desc: "Community descriptor for homepage"
|
||||
default: ""
|
||||
- name: web__staticFilesPrefix
|
||||
desc: "URL or relative path prefix to use for static files (empty string to use versions embedded in binary)"
|
||||
default: ""
|
||||
|
@ -1,6 +1,26 @@
|
||||
build/WebTemplates.h: $(shell find src/apps/web/tmpls/ -type f -name '*.tmpl')
|
||||
perl golpe/external/templar/templar.pl src/apps/web/tmpls/ tmpl $@
|
||||
|
||||
src/apps/web/WebReader.o: build/WebTemplates.h
|
||||
src/apps/web/WebReader.o: build/WebTemplates.h build/WebStaticFiles.h
|
||||
|
||||
LDLIBS += -lre2
|
||||
|
||||
|
||||
|
||||
|
||||
build/web-static/oddbean.css: src/apps/web/static/reset.css src/apps/web/static/oddbean.css
|
||||
mkdir -p build/web-static/
|
||||
cat $^ | sassc -s -t compressed > $@
|
||||
gzip -k9f $@
|
||||
|
||||
build/web-static/oddbean.js: src/apps/web/static/base.ts src/apps/web/static/turbo.js src/apps/web/static/oddbean.js src/apps/web/static/alpine.js
|
||||
mkdir -p build/web-static/
|
||||
cat $^ | esbuild --loader=ts --minify > $@
|
||||
gzip -k9f $@
|
||||
|
||||
build/web-static/oddbean.svg: src/apps/web/static/oddbean.svg
|
||||
cp $^ $@
|
||||
gzip -k9f $@
|
||||
|
||||
build/WebStaticFiles.h: build/web-static/oddbean.css build/web-static/oddbean.js build/web-static/oddbean.svg
|
||||
perl golpe/external/hoytech-cpp/dirToCppHeader.pl build/web-static/ oddbeanStatic > $@
|
||||
|
1
src/apps/web/static/.gitignore
vendored
1
src/apps/web/static/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/build/
|
@ -1,19 +0,0 @@
|
||||
CSS := reset.css oddbean.css
|
||||
JS := base.ts turbo.js oddbean.js alpine.js
|
||||
|
||||
.PHONY: all css js logo
|
||||
|
||||
all: css js logo
|
||||
|
||||
css: $(CSS)
|
||||
mkdir -p build/
|
||||
cat $(CSS) | sassc -s -t compressed > build/oddbean.css
|
||||
gzip -k9f build/oddbean.css
|
||||
|
||||
js: $(JS)
|
||||
mkdir -p build/
|
||||
cat $(JS) | esbuild --loader=ts --minify > build/oddbean.js
|
||||
gzip -k9f build/oddbean.js
|
||||
|
||||
logo:
|
||||
cp oddbean.svg build/
|
Reference in New Issue
Block a user