blob: b80c009be1eb4f8d06f2d41569b2a64beceb276c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#!/bin/sh
TITLE="19 PDH Puszcza"
URL="https://nojs--api-puszcza.netlify.app"
DESCRIPTION=""
rm -r dest || true
mkdir dest
# This is useful when deploying on netlify. Thanks to storing compiled binaries
# in this folder they will be cached and restored.
export PATH="$PWD/.jekyll-cache:$PWD/tools:$PATH"
./tools/compile
post_rss() {
path="$URL$1"
title=$2
photo=$3
description=$4
file=$5
date=`git log -n 1 --date="format:%Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad' -- $file`
cat << EOF
<item>
<guid>$path</guid>
<link>$path</link>
<pubDate>$date</pubDate>
<title>$title</title>
<description><![CDATA[
$(lowdown-f $file)
]]></description>
</item>
EOF
}
post_link() {
path=$1
title=$2
photo=$3
description=$4
cat << EOF
<div class="post-link">
<a href="$path">
<div>
<div class="image" style="background-image: url('$photo')"></div>
<div class="post-container">
<h4 class="post-title">$title</h4>
<p class="post-description">$description</p>
</div>
</div>
</a>
</div>
EOF
}
cat > wpisy/kronika.html << EOF
<link href="/kronika.css" rel="stylesheet">
<h2>Ostatnie wpisy</h2>
<a href="/kronika/rss.xml"><img alt="" src="/assets/rss.svg" style="height:1em">RSS</a>
<div class="content post-list">
EOF
mkdir -p dest/kronika
cat > dest/kronika/rss.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="$URL/kronika/rss.xml" rel="self" type="application/rss+xml" />
<title>$TITLE</title>
<description>$DESCRIPTION</description>
<link>$URL</link>
<lastBuildDate>$(date -R)</lastBuildDate>
EOF
i=0
for f in `find wpisy/kronika/20* -name '*.md' | sort -r`; do
path=`echo $f | sed 's/wpisy//;s/.md//'`
title=`grep "^# " $f | head -n 1 | cut -c 2-`
photo=`grep "!\[.*\]\(.*\)" $f | head -n 1 | cut -d "(" -f2 | cut -d ")" -f1`
[ -z $photo ] && photo="/assets/default_tree.jpg"
description=`grep -E "^[A-Z]" $f | grep -v "|" | head -n 1 | cut -d" " -f1-30`
categories=`sed -n '/---/,/---/p' $f | grep " - " | sed 's/[^a-zA-Z0-9]//g'`
post_link "$path" "$title" "$photo" "$description" >> wpisy/kronika.html
[ $i -lt 20 ] && \
post_rss "$path" "$title" "$photo" "$description" "$f" >> dest/kronika/rss.xml
# [ $i -lt 4 ] && \
# post_link "$path" "$title" "$photo" "$description" >> wpisy/index.md && \
i=$(($i+1))
done
echo "</div>" >> wpisy/kronika.html
echo "</channel></rss>" >> dest/kronika/rss.xml
./ssg5 wpisy dest "$TITLE" "$URL"
cp -r static/* dest
|