about summary refs log tree commit diff
path: root/gen
blob: 04ac0cc3ced1f178f4b9a80b35109a2e57ddd192 (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
#!/bin/sh

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:$PATH"
./tools/compile


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="rss.xml"><img alt="" src="/assets/rss.svg" style="height:1em">RSS</a>
<div class="content post-list">
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`
  post_link "$path" "$title" "$photo" "$description" >> wpisy/kronika.html
  [ $i -lt 4 ] && \
    # post_link "$path" "$title" "$photo" "$description" >> wpisy/index.md && \
    i=$(($i+1))
done
echo "</div>" >> wpisy/kronika.html

./ssg5 wpisy dest "19 PDH Puszcza" "https://19.niedzwiedzinski.cyou"
cp -r static/* dest
./tools/rssg dest/kronika/index.html "19 PDH Puszcza" > dest/rss.xml