mirror of
https://github.com/alex-s168/website.git
synced 2025-09-10 09:05:08 +02:00
use ninja for building
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,3 +2,6 @@ build
|
|||||||
*.html
|
*.html
|
||||||
*.pdf
|
*.pdf
|
||||||
res/badges
|
res/badges
|
||||||
|
build.ninja
|
||||||
|
.ninja_log
|
||||||
|
.ninja_deps
|
||||||
|
88
config.py
Normal file
88
config.py
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
import os.path
|
||||||
|
|
||||||
|
gen = """
|
||||||
|
rule regen
|
||||||
|
command = python config.py
|
||||||
|
generator = 1
|
||||||
|
|
||||||
|
rule typst
|
||||||
|
depfile = $out.d
|
||||||
|
command = eval "typst compile --root . --features html -j 6 $flags $in $out --make-deps $out.d"
|
||||||
|
|
||||||
|
rule git_inp
|
||||||
|
command = git log -1 --format="--input git_rev=%H --input git_commit_date=\\\"%ad\\\"" --date="format:%d. %B %Y %H:%M" -- $in > $out
|
||||||
|
|
||||||
|
rule badges_list
|
||||||
|
command = typst query $in "<meta-people>" --root . --input query=true --field value --one | jq -r . | jq -r 'to_entries[] | [.key,.value.badge] | @tsv' > $out
|
||||||
|
|
||||||
|
rule curl
|
||||||
|
command = curl $url > $out
|
||||||
|
|
||||||
|
rule cp
|
||||||
|
command = cp $in $out
|
||||||
|
|
||||||
|
build build/badges.txt: badges_list common.typ
|
||||||
|
|
||||||
|
build build.ninja: regen config.py build/badges.txt
|
||||||
|
"""
|
||||||
|
|
||||||
|
pages = [
|
||||||
|
"article-make-regex-engine-1.typ",
|
||||||
|
"project-etc-nand.typ",
|
||||||
|
"index.typ",
|
||||||
|
"compiler-pattern-matching.typ",
|
||||||
|
"article-favicon.typ",
|
||||||
|
]
|
||||||
|
|
||||||
|
variants = [
|
||||||
|
{
|
||||||
|
"suffix": ".min.pdf",
|
||||||
|
"args": "--format pdf --input web=false",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"suffix": ".min.html",
|
||||||
|
"args": "--format html --input web=false",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"suffix": ".desktop.html",
|
||||||
|
"args": "--format html --input web=true",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"suffix": ".nano.html",
|
||||||
|
"args": "--format html --input web=false --input nano=true",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
for page in pages:
|
||||||
|
gr = "build/" + page + ".git_rev.txt"
|
||||||
|
gen += "\n"
|
||||||
|
gen += "build "+gr+" : git_inp pages/" + page
|
||||||
|
for var in variants:
|
||||||
|
gen += "\n"
|
||||||
|
gen += "build build/" + page + var["suffix"] + " : typst " + "pages/" + page + " | "+gr+"\n"
|
||||||
|
gen += " flags = " + var["args"] + " $$(cat "+gr+")\n"
|
||||||
|
|
||||||
|
if os.path.isfile("build/badges.txt"):
|
||||||
|
badges = None
|
||||||
|
with open("build/badges.txt", "r") as f:
|
||||||
|
badges = f.read().split("\n")
|
||||||
|
for badge in badges:
|
||||||
|
badge = badge.strip()
|
||||||
|
if len(badge) == 0:
|
||||||
|
continue
|
||||||
|
badge = badge.split("\t")
|
||||||
|
user = badge[0]
|
||||||
|
url = badge[1]
|
||||||
|
gen += "\n"
|
||||||
|
gen += "build res/badges/" + user + ": "
|
||||||
|
if user == "alex":
|
||||||
|
gen += "cp res/badge.png\n"
|
||||||
|
else:
|
||||||
|
gen += "curl\n"
|
||||||
|
gen += " url = "+url+"\n"
|
||||||
|
|
||||||
|
gen += "\n"
|
||||||
|
gen += "build build/index.html : cp build/index.typ.desktop.html\n"
|
||||||
|
|
||||||
|
with open("build.ninja", "w") as f:
|
||||||
|
f.write(gen)
|
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
#show underline: it => {
|
#show underline: it => {
|
||||||
context if is-html() {
|
context if is-html() {
|
||||||
html.elem("u", it.body)
|
html.elem("span", attrs: (style: "text-decoration: underline;"), it.body)
|
||||||
} else {
|
} else {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
3
pub.sh
3
pub.sh
@@ -1,4 +1,5 @@
|
|||||||
set -e
|
set -e
|
||||||
./build.sh
|
./build.sh
|
||||||
scp -r build/* root@195.26.251.204:/srv/http/alex
|
#scp -r build/* root@195.26.251.204:/srv/http/alex
|
||||||
|
rsync -avz build root@195.26.251.204:/srv/http/alex
|
||||||
#scp -r res/* root@195.26.251.204:/srv/http/alex/res
|
#scp -r res/* root@195.26.251.204:/srv/http/alex/res
|
||||||
|
Reference in New Issue
Block a user