gamelog/justfile

158 lines
3.9 KiB
Plaintext
Raw Normal View History

2022-02-11 22:08:17 +00:00
database := "db/games.rec"
2021-12-23 21:52:43 +00:00
# show all commands
default:
just -l --unsorted
# how many games played
2024-02-01 18:41:38 +00:00
@played:
recsel -t Game -e "Role = 'Player'" -P Module -C {{database}}
2021-12-23 21:52:43 +00:00
# how many games ran
2024-02-01 18:41:38 +00:00
@ran:
recsel -t Game -e "Role = 'DM'" -P Module -C {{database}}
2021-12-23 21:52:43 +00:00
# ongoing
2024-02-01 18:41:38 +00:00
@ongoing:
recsel -t Game -e 'Status = "Ongoing"' -p System,Module {{database}}
2021-12-23 21:52:43 +00:00
2022-08-30 13:17:56 +00:00
# show all in year
year x:
2024-02-01 18:41:38 +00:00
recsel -t Game -e 'Updated >> "{{x}}-01-01"' -P "Module,System,Updated" {{database}}
2021-12-23 21:52:43 +00:00
2024-02-01 22:57:46 +00:00
alias n := new
# create a new game
new: cli
alias u := update
# create a new game update
update: cli
# start cli
cli:
sh bin/cli.sh
2022-01-06 23:43:11 +00:00
2024-02-02 17:10:01 +00:00
# build da html
2022-02-11 04:26:27 +00:00
html:
2024-02-01 18:41:38 +00:00
#!/usr/bin/env sh
## BEGIN: TEMPLATES ##
gameheadertmpl='<article>
2024-02-02 17:10:01 +00:00
<h2 id={{{{Id}}>{{{{Module}} ({{{{System}}) <small><a href="#{{{{Id}}">#</a></small></h2>
2024-02-01 18:41:38 +00:00
<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>
'
2024-02-02 17:10:01 +00:00
updatetmpl='<h3 id="u{{{{Id}}">{{{{Created}} <small><a href="#u{{{{Id}}">#</a></small></h3>
2024-02-01 18:41:38 +00:00
{{{{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;
2024-02-03 17:04:05 +00:00
padding: 3rem 1rem;
2024-02-01 18:41:38 +00:00
}
h2 {
border-bottom: solid 1px black;
margin-top: 3rem;
}
2024-02-03 21:45:14 +00:00
h2, h3 {
position: relative;
}
h2 a, h3 a {
position: absolute;
left: -1.2rem;
text-decoration: none;
opacity: 0.2;
}
h2 a {
line-height: 1.4;
}
h3 a {
line-height: 1.2;
}
h2:hover a, h3:hover a {
opacity: 1;
}
2024-02-01 18:41:38 +00:00
</style>
EOF
## END: STYLE ##
## BEGIN: INTRO ##
cat<<EOF
2024-02-03 17:04:05 +00:00
<h1>Gamelogs</h1>
<p>All the roleplaying games I've played.</p>
2024-02-01 18:41:38 +00:00
<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 ##
2022-02-11 04:26:27 +00:00
# rss feed
feed:
2024-02-01 18:41:38 +00:00
#!/usr/bin/env sh
feedtmpl='<item>
<title>{{{{Game_System}} - {{{{Game_Module}}</title>
<link>http://tilde.town/~dozens/gamelog/index.html</link>
<pubDate>{{{{Created}}</pubDate>
<description>
<![CDATA[
{{{{Text}}
]]>
</description>
</item>
'
exec > dist/feed.xml
cat<<EOF
<rss version="2.0">
<channel>
<title>gamelog</title>
<link>http://tilde.town/~dozens/gamelog/index.html</link>
<description>all the games i play</description>
<atom:link rel="self" type="application/rss+xml" href="http://tilde.town/~dozens/gamelog/feed.xml"/>
EOF
recsel -t Update -j Game {{database}} | recfmt "$feedtmpl"
echo '</channel></rss>'
2022-03-04 23:01:03 +00:00
sed -i '' 's/&/and/g' dist/feed.xml
2022-02-11 22:08:17 +00:00
2022-02-17 00:45:28 +00:00
# copy to blog
export:
just html && cp dist/index.html ../dozens-and-dragons/out/gamelog/
2022-02-11 22:08:17 +00:00
# DO THE THANG
build: html feed
# upload
2022-02-17 00:45:28 +00:00
up: build export
2022-02-11 22:08:17 +00:00
rsync -azP --exclude=.git dist/* tilde:public_html/gamelog
2022-08-30 13:17:56 +00:00
# do everything
all: build up