gamelog/justfile

131 lines
3.4 KiB
Plaintext

database := "db/games.rec"
# show all commands
default:
just -l --unsorted
# how many games played
@played:
recsel -t Game -e "Role = 'Player'" -P Module -C {{database}}
# how many games ran
@ran:
recsel -t Game -e "Role = 'DM'" -P Module -C {{database}}
# ongoing
@ongoing:
recsel -t Game -e 'Status = "Ongoing"' -p System,Module {{database}}
# show all in year
year x:
recsel -t Game -e 'Updated >> "{{x}}-01-01"' -P "Module,System,Updated" {{database}}
# create a new entry
new:
node bin/cli.js
html:
#!/usr/bin/env sh
## BEGIN: TEMPLATES ##
gameheadertmpl='<article>
<h2 id={{{{Id}}>{{{{Module}} ({{{{System}})</h2>
<p>{{{{Module}} is a game of {{{{System}} that I started playing on {{{{Started}} as a {{{{Role}}. It is a {{{{Format}} {{{{Length}} and is currently {{{{Status}}.</p>
<p>Here is how it went!</p>
'
updatetmpl='<h3>{{{{Created}}</h3>
{{{{Text}}
'
gamefootertmpl='<center>🎲🎲</center>
</article>'
toctmpl='<li><a href="#{{{{Id}}">{{{{Module}} ({{{{System}})</a></li>'
## END: TEMPLATES ##
exec > dist/index.html
## BEGIN: STYLE ##
cat<<EOF
<link rel="alternate" type="application/rss+xml" href="feed.xml" title="dozens gamelog">
<style>
body {
max-width: 80ch;
margin: 0 auto;
}
h2 {
border-bottom: solid 1px black;
margin-top: 3rem;
}
</style>
EOF
## END: STYLE ##
## BEGIN: INTRO ##
cat<<EOF
<h1>Games!</h1>
<li>src: <a href='https://git.tilde.town/dozens/gamelog'>https://git.tilde.town/dozens/gamelog</a></li>
<li>dozens webring: <a href='https://tilde.town/%7Edozens/webring/dozens/index.html?name=gamelog&amp;dir=prev'>previous</a> <a href='https://tilde.town/%7Edozens/webring/dozens/index.html'>index</a> <a href='https://tilde.town/%7Edozens/webring/dozens/index.html?name=gamelog&amp;dir=next'>next</a></li>
<li><a href="feed.xml">rss</a></li>
EOF
## END: INTRO ##
## BEGIN: TOC ##
echo '<h2>Contents</h2>'
recsel {{database}} -t Game | recfmt "$toctmpl"
## END: TOC ##
## BEGIN: BODY ##
allgames=(`recsel {{database}} -t Game -P Id -C | tr '\n' ' '`)
for idx in "${allgames[@]}"
do
recsel {{database}} -t Game -e "Id = $idx" | recfmt "$gameheadertmpl"
recsel {{database}} -t Update -e "Game = $idx" | recfmt "$updatetmpl" | markdown
echo $gamefootertmpl
done
## END: BODY ##
# rss feed
feed:
#!/usr/bin/env sh
feedtmpl='<item>
<title>{{{{Game_Module}} ({{{{Game_System}})</title>
<link>http://tilde.town/~dozens/gamelog/index.html</link>
<pubDate>{{{{Created}}</pubDate>
<description>
<![CDATA[
{{{{Text}}
]]>
</description>
</item>
'
exec > dist/feed.xml
cat<<EOF
<?xml version="1.0" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link rel="self" type="application/rss+xml" href="http://tilde.town/~dozens/gamelog/feed.xml"/>
<title>gamelog</title>
<link>http://tilde.town/~dozens/gamelog/index.html</link>
<description>all the games i play</description>
EOF
recsel -t Update -j Game {{database}} | recfmt "$feedtmpl"
echo '</channel></rss>'
sed -i '' 's/&/and/g' dist/feed.xml
# copy to blog
export:
just html && cp dist/index.html ../dozens-and-dragons/out/gamelog/
# DO THE THANG
build: html feed
# upload
up: build export
rsync -azP --exclude=.git dist/* tilde:public_html/gamelog
# do everything
all: build up