~prokop/rdck.dev

c2aa30691ad46f6f94e2dbb761b6c59fd74db1fe — Prokop Randacek 8 months ago 92cf837
add rss feed
3 files changed, 72 insertions(+), 30 deletions(-)

M build
A deploy
M template.html
M build => build +61 -29
@@ 7,34 7,74 @@ mkdir $OUT_DIR

cp -r assets $OUT_DIR/

# build posts list html
echo "<ul>" > ./postlist.html
for f in `find posts -name \*.md | sort -r`
do
	TITLE=`cat $f | grep "^# " | head -1 | sed 's/^# //'`
	DATE=`basename -s .md $f | cut -d '-' -f 0-3`
	URL=/`basename -s .md $f`
	echo "<li>($DATE) <a href=\"$URL\">$TITLE</a></li>" >> postlist.html
done
echo "</ul>" >> postlist.html
TITLE=rdck.dev
LINK_PREFIX=https://rdck.dev

# build fun stuff list html
echo "<ul>" > ./funlist.html
for f in `find fun -name \*.md | sort -r`
do
	TITLE=`cat $f | grep "^# " | head -1 | sed 's/^# //'`
	DATE=`basename -s .md $f | cut -d '-' -f 0-3`
	URL=/`basename -s .md $f`
	echo "<li>($DATE) <a href=\"$URL\">$TITLE</a></li>" >> funlist.html
done
echo "</ul>" >> funlist.html
RSSFEED=$OUT_DIR/rss.xml

function get_title() {
	cat $1 | grep "^# " | head -1 | sed 's/^# //'
}

function get_date() {
	basename -s .md $1 | cut -d '-' -f 0-3
}

function get_date2() {
	date -D "%Y-%m-%d" -d "`get_date $1`" "+%a, %d %b %Y %T %z"
}

function get_url() {
	basename -s .md $1
}

function generate_rss() {
	#!/bin/sh

	echo "<rss version=\"2.0\">
<channel>
<title>$TITLE</title>
<link>$LINK_PREFIX</link>
<language>en-us</language>
<pubDate>`date -R`</pubDate>
<lastBuildDate>`date -R`</lastBuildDate>" > $RSSFEED

	for f in $@
	do
		echo "<item>
<title>`get_title $f`</title>
<link>$LINK_PREFIX/`get_url $f`</link>
<pubDate>`get_date2 $f`</pubDate>
</item>" >> $RSSFEED
	done

	echo "</channel></rss>" >> $RSSFEED

}

function generate_list() {
	echo "<ul>" > ./$2
	for f in `find $1 -name \*.md | sort -r`
	do
		TITLE=`get_title $f`
		DATE=`get_date $f`
		URL=/`get_url $f`
		echo "<li>($DATE) <a href=\"$URL\">$TITLE</a></li>" >> $2
	done
	echo "</ul>" >> $2
}

generate_list ./fun ./funlist.html
generate_list ./posts ./postlist.html

generate_rss `find posts fun -name \*.md -type f`

# build navbar html
echo "<nav>" > ./navbar.html
for f in `find content -type f -name '*.md' ! -name '404.md' ! -name 'index.md'`
do
	NAME=`basename -s .md $f | awk '{ print toupper(substr($0,1,1)) substr($0,2) }'`
	URL=/`basename -s .md $f`
	URL=/`get_url $f`
	echo "<a href=\"$URL\">$NAME</a>" >> navbar.html
done
echo "</nav>" >> navbar.html


@@ 47,11 87,3 @@ for f in `find content posts fun -name \*.md`; do
	TITLE=rdck.dev CONTENT_HTML=$PART NAVBAR_HTML=./navbar.html mmtt < template.html > $HTML
done

cd assets/fun/jpeg/
./gen
cd ../../../

rsync -avhc $OUT_DIR/ prokop@rdck.dev:www --delete

ssh -t prokop@rdck.dev 'ln -sf ~/public ~/www/dl'


A deploy => deploy +10 -0
@@ 0,0 1,10 @@
#!/bin/sh

cd assets/fun/jpeg/
./gen
cd ../../../

rsync -avhc www/ prokop@rdck.dev:www --delete

ssh -t prokop@rdck.dev 'ln -sf ~/public ~/www/dl'


M template.html => template.html +1 -1
@@ 23,7 23,7 @@
			{:: cat $CONTENT_HTML ::}
		</main>
		<footer>
			Made by me. <a href="https://git.sr.ht/~prokop/rdck.dev">source</a>
			Made by me. <a href="https://git.sr.ht/~prokop/rdck.dev">source</a>. <a href="/rss.xml">rss feed</a>.
		</footer>
	</body>
</html>