summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/blog/index.md2
-rw-r--r--metadata/categories.json4
-rw-r--r--metadata/metadata.yaml5
-rwxr-xr-xscripts/build_content.sh171
-rwxr-xr-xscripts/metadata_tpl.json3
-rw-r--r--templates/base.html57
-rw-r--r--templates/categoryRef.html12
-rw-r--r--templates/feed.xml22
-rw-r--r--templates/pageHeaderSm.html2
-rw-r--r--templates/pagelistByYear.html18
10 files changed, 187 insertions, 109 deletions
diff --git a/content/blog/index.md b/content/blog/index.md
index 576a8c3..1053dc2 100644
--- a/content/blog/index.md
+++ b/content/blog/index.md
@@ -1,5 +1,7 @@
1--- 1---
2title: Blog 2title: Blog
3
4create_feed: true
3--- 5---
4 6
5# Blog 7# Blog
diff --git a/metadata/categories.json b/metadata/categories.json
deleted file mode 100644
index b0c5f84..0000000
--- a/metadata/categories.json
+++ /dev/null
@@ -1,4 +0,0 @@
1{
2 "tes": "Testing",
3 "per": "Personal"
4}
diff --git a/metadata/metadata.yaml b/metadata/metadata.yaml
index d2d4b1f..00a8571 100644
--- a/metadata/metadata.yaml
+++ b/metadata/metadata.yaml
@@ -10,3 +10,8 @@ menus:
10 - id: blog 10 - id: blog
11 label: Blog 11 label: Blog
12 url: /blog/ 12 url: /blog/
13
14categories:
15 blog:
16 tes: Testing
17 per: Personal
diff --git a/scripts/build_content.sh b/scripts/build_content.sh
index b258449..e2b3bb3 100755
--- a/scripts/build_content.sh
+++ b/scripts/build_content.sh
@@ -1,13 +1,13 @@
1#!/bin/bash 1#!/bin/bash
2 2
3SITE="https://volpeon.ink/"
4
3CONTENT_DIR="content/" 5CONTENT_DIR="content/"
4FILTERS_DIR="filters/" 6FILTERS_DIR="filters/"
5METADATA_DIR="metadata/" 7METADATA_DIR="metadata/"
6TEMPLATES_DIR="templates/" 8TEMPLATES_DIR="templates/"
7OUTPUT_DIR="output/" 9OUTPUT_DIR="output/"
8 10
9CATEGORY_MAP=$(cat "$METADATA_DIR/categories.json")
10
11get_filters() { 11get_filters() {
12 filters_args="" 12 filters_args=""
13 13
@@ -37,16 +37,22 @@ target_filename() {
37target_url_rel() { 37target_url_rel() {
38 basedir=$1 38 basedir=$1
39 filename=$2 39 filename=$2
40 ext=$3
40 filename=$(realpath --relative-to="$basedir" "$filename") 41 filename=$(realpath --relative-to="$basedir" "$filename")
41 filename="${filename%.md}.html" 42 filename="${filename%.md}.$ext"
42 if [ "${filename##*/}" = "index.html" ]; then 43 filename=${filename%index.html}
43 filename=${filename%index.html}
44 fi
45 echo "$filename" 44 echo "$filename"
46} 45}
47 46
48target_url_abs() { 47target_url_abs() {
49 echo "/$(target_url_rel "$CONTENT_DIR" "$1")" 48 echo "/$(target_url_rel "$CONTENT_DIR" "$1" "$2")"
49}
50
51metadata() {
52 pandoc "$1" \
53 -f markdown \
54 -t plain \
55 --template scripts/metadata_tpl.json
50} 56}
51 57
52get_section() { 58get_section() {
@@ -65,7 +71,7 @@ get_subpages_basedir() {
65 echo "$filename" 71 echo "$filename"
66} 72}
67 73
68get_metadata() { 74get_subpages_meta() {
69 basedir=$(get_subpages_basedir "$1") 75 basedir=$(get_subpages_basedir "$1")
70 child_pages=() 76 child_pages=()
71 77
@@ -86,42 +92,44 @@ get_metadata() {
86 child_pages=("${child_pages_1[@]}" "${child_pages_2[@]}") 92 child_pages=("${child_pages_1[@]}" "${child_pages_2[@]}")
87 fi 93 fi
88 94
95 pages=$(echo "{}" | jq ". + { \
96 all: [], \
97 by_year: {} \
98 }")
99
89 if [ ${#child_pages[@]} -ne 0 ]; then 100 if [ ${#child_pages[@]} -ne 0 ]; then
90 #echo -e "\033[0;90m[////////]\033[0m Child pages:" 101 #echo -e "\033[0;90m[////////]\033[0m Child pages:"
91 102
92 pages=$(echo "{}" | jq ". + { \
93 all: [], \
94 by_year: {} \
95 }")
96
97 categories="{}"
98
99 for file in "${child_pages[@]}"; do 103 for file in "${child_pages[@]}"; do
100 #echo -e "\033[0;90m[////////]\033[0m - $file" 104 #echo -e "\033[0;90m[////////]\033[0m - $file"
101 105
102 url_rel=$(target_url_rel "$basedir" "$file") 106 metadata=$(metadata "$file")
103 url_abs=$(target_url_abs "$file")
104 107
105 metadata=$(pandoc "$file" \ 108 url_rel=$(target_url_rel "$basedir" "$file" "html")
106 -f markdown \ 109 url_abs=$(target_url_abs "$file" "html")
107 -t plain \ 110 url_full="${SITE%/}$url_abs"
108 --template scripts/metadata_tpl.json)
109 111
110 date=$(echo "$metadata" | jq -r .date) 112 date=$(echo "$metadata" | jq -r .date)
111 category=$(echo "$metadata" | jq -r .category) 113 date_rfc3339=""
112 category_name=$(echo "$CATEGORY_MAP" | jq -r .$category)
113 114
114 metadata=$(echo "$metadata" | jq ". + { \ 115 if [ "$date" != "" ]; then
115 url_rel: \"$url_rel\", \ 116 date_rfc3339=$(date -d "$date" --rfc-3339=seconds | sed 's/ /T/')
116 url_abs: \"$url_abs\" \ 117 fi
118
119 metadata=$(echo "$metadata" | jq ". * { \
120 date: { \
121 yyyy_mm_dd: \"$date\", \
122 rfc3339: \"$date_rfc3339\" \
123 }, \
124 url: { \
125 rel: \"$url_rel\", \
126 abs: \"$url_abs\", \
127 full: \"$url_full\" \
128 } \
117 }") 129 }")
118 130
119 pages=$(echo "$pages" | jq ".all += [ $metadata ]") 131 pages=$(echo "$pages" | jq ".all += [ $metadata ]")
120 132
121 if [ "$category" != "" ]; then
122 categories=$(echo "$categories" | jq ". + { $category: \"$category_name\" }")
123 fi
124
125 if [ "$date" != "" ]; then 133 if [ "$date" != "" ]; then
126 date_year=$(date -d "$date" +%Y) 134 date_year=$(date -d "$date" +%Y)
127 #date_month=$(date -d "$date" +%m) 135 #date_month=$(date -d "$date" +%m)
@@ -135,58 +143,101 @@ get_metadata() {
135 | jq ".all |= (sort_by(.date) | reverse) \ 143 | jq ".all |= (sort_by(.date) | reverse) \
136 | .by_year |= (to_entries | sort_by(.key) | reverse \ 144 | .by_year |= (to_entries | sort_by(.key) | reverse \
137 | .[].value |= (sort_by(.date) | reverse))") 145 | .[].value |= (sort_by(.date) | reverse))")
138
139 categories=$(echo "$categories" | jq ". | to_entries | sort_by(.key)")
140
141 echo "{}" | jq ". + { \
142 pages: $pages, \
143 categories: $categories \
144 }"
145 fi 146 fi
147
148 echo "{}" | jq ". + { \
149 pages: $pages \
150 }"
146} 151}
147 152
148handle () { 153handle () {
149 target=$(target_filename "$1") 154 target_file=$(target_filename "$1")
150 155
151 mkdir -p $(dirname "$target") 156 mkdir -p $(dirname "$target_file")
152 157
153 if [ "${1#*.}" = "md" ]; then 158 if [ "${1#*.}" = "md" ]; then
154 echo -e "\033[0;32m[COMPILE ]\033[0m $1 -> $target" 159 echo -e "\033[0;32m[COMPILE ]\033[0m $1 -> $target_file"
160
161 meta_file=$(mktemp)
162
163 metadata=$(metadata "$file")
164 metadata=$(echo "[ \
165 $metadata, \
166 $(get_subpages_meta "$1") \
167 ]" | jq ".[0] * .[1]")
168
169 url_abs=$(target_url_abs "$1" "html")
170 url_full="${SITE%/}$url_abs"
155 171
156 is_home=false
157 section=$(get_section "$1") 172 section=$(get_section "$1")
158 173
159 if [ "$target" = "${OUTPUT_DIR}index.html" ]; then 174 is_home=false
175 if [ "$target_file" = "${OUTPUT_DIR}index.html" ]; then
160 is_home=true 176 is_home=true
161 fi 177 fi
162 178
163 subpages_meta_file=$(mktemp) 179 metadata=$(echo "$metadata" | jq ". * { \
180 url: { \
181 abs: \"$url_abs\", \
182 full: \"$url_full\" \
183 }, \
184 section: { \
185 id: \"$section\", \
186 is_$section: true \
187 }, \
188 is_home: $is_home \
189 }")
164 190
165 # echo "$(get_metadata "$1")" 191 create_feed=$(echo "$metadata" | jq -r ".create_feed")
166 echo "$(get_metadata "$1")" > "$subpages_meta_file" 192
193 if [ "$create_feed" = "true" ]; then
194 feed_target_file="${target_file%.html}.xml"
195 feed_url_abs="$(target_url_abs "$1" "xml")"
196 feed_url_full="${SITE%/}$feed_url_abs"
197 last_update=$(echo "$metadata" | jq -r ".pages.all[0].date")
198
199 metadata=$(echo "$metadata" | jq ". * { \
200 feed: { \
201 last_update: $last_update, \
202 url: { \
203 abs: \"$feed_url_abs\", \
204 full: \"$feed_url_full\" \
205 } \
206 } \
207 }")
167 208
168 # echo $(pandoc "$1" \ 209 echo "$metadata" > "$meta_file"
169 # -f markdown \ 210
170 # -t json) 211 pandoc "$1" \
212 -f markdown \
213 -t html5 \
214 --template "${TEMPLATES_DIR}feed.xml" \
215 -o "$feed_target_file" \
216 --metadata-file metadata/metadata.yaml \
217 --metadata-file "$meta_file" \
218 $FILTERS
219 fi
220
221 echo "$metadata" > "$meta_file"
171 222
172 pandoc "$1" \ 223 pandoc "$1" \
173 -f markdown \ 224 -f markdown \
174 -t html5 \ 225 -t html5 \
175 --template "${TEMPLATES_DIR}base.html" \ 226 --template "${TEMPLATES_DIR}base.html" \
176 -o "$target" \ 227 -o "$target_file" \
177 --metadata "ishome"=$is_home \
178 --metadata section=$section \
179 --metadata "is$section" \
180 --metadata-file metadata/metadata.yaml \ 228 --metadata-file metadata/metadata.yaml \
181 --metadata-file "$subpages_meta_file" \ 229 --metadata-file "$meta_file" \
182 $FILTERS 230 $FILTERS
183 # --lua-filter "filters/add_refs.lua"
184 231
185 rm "$subpages_meta_file" 232 rm "$meta_file"
233
234 # echo $(pandoc "$1" \
235 # -f markdown \
236 # -t json)
186 else 237 else
187 echo -e "\033[0;32m[COPY ]\033[0m $1 -> $target" 238 echo -e "\033[0;32m[COPY ]\033[0m $1 -> $target_file"
188 239
189 cp "$1" "$target" 240 cp "$1" "$target_file"
190 fi 241 fi
191} 242}
192 243
@@ -215,9 +266,9 @@ elif [ "$1" = "delete" ]; then
215 if [ -z "$2" ]; then 266 if [ -z "$2" ]; then
216 echo -e "\033[0;31m[ERROR ]\033[0m \"delete\" operation requires file argument" 267 echo -e "\033[0;31m[ERROR ]\033[0m \"delete\" operation requires file argument"
217 else 268 else
218 TARGET=$(target_filename "$2") 269 target_file=$(target_filename "$2")
219 echo -e "\033[0;32m[DELETE ]\033[0m $2 -> $TARGET" 270 echo -e "\033[0;32m[DELETE ]\033[0m $2 -> $target_file"
220 rm -rf $TARGET 271 rm -rf $target_file
221 fi 272 fi
222else 273else
223 echo -e "\033[0;31m[ERROR ]\033[0m Unknown operation: \"$1\"" 274 echo -e "\033[0;31m[ERROR ]\033[0m Unknown operation: \"$1\""
diff --git a/scripts/metadata_tpl.json b/scripts/metadata_tpl.json
index 76e4439..79eabe1 100755
--- a/scripts/metadata_tpl.json
+++ b/scripts/metadata_tpl.json
@@ -1,5 +1,6 @@
1{ 1{
2 "title": "$title$", 2 "title": "$title$",
3 "date": "$date$", 3 "date": "$date$",
4 "category": "$category$" 4 "category": "$category$",
5 "create_feed": "$create_feed$"
5} 6}
diff --git a/templates/base.html b/templates/base.html
index 3fca9f1..0704388 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -7,24 +7,27 @@
7 <meta name="robots" content="noindex" /> 7 <meta name="robots" content="noindex" />
8 <link rel="shortcut icon" href="/favicon.ico" /> 8 <link rel="shortcut icon" href="/favicon.ico" />
9 $for(author-meta)$ 9 $for(author-meta)$
10 <meta name="author" content="$author-meta$" /> 10 <meta name="author" content="$author-meta$" />
11 $endfor$ 11 $endfor$
12 $if(date-meta)$ 12 $if(date-meta)$
13 <meta name="dcterms.date" content="$date-meta$" /> 13 <meta name="dcterms.date" content="$date-meta$" />
14 $endif$ 14 $endif$
15 $if(keywords)$ 15 $if(keywords)$
16 <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" /> 16 <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
17 $endif$ 17 $endif$
18 <title>$if(ishome)$$else$$title$ – $endif$$site.title$</title> 18 $if(feed.url.abs)$
19 <link href="$feed.url.abs$" type="application/atom+xml" rel="alternate" title="$if(is_home)$$else$$title$ – $endif$$site.title$" />
20 $endif$
21 <title>$if(is_home)$$else$$title$ – $endif$$site.title$</title>
19 <link rel="stylesheet" href="/style.css" /> 22 <link rel="stylesheet" href="/style.css" />
20 $if(section)$ 23 $if(section.id)$
21 <style> 24 <style>
22 .c-nav__item--$section$ { 25 .c-nav__item--$section.id$ {
23 border-color: var(--nav--item--active--fg); 26 border-color: var(--nav--item--active--fg);
24 color: var(--nav--item--active--fg); 27 color: var(--nav--item--active--fg);
25 font-weight: bold; 28 font-weight: bold;
26 } 29 }
27 </style> 30 </style>
28 $endif$ 31 $endif$
29</head> 32</head>
30 33
@@ -33,14 +36,14 @@
33 <div class="c-nav__items l-container"> 36 <div class="c-nav__items l-container">
34 <a class="c-nav__logo" href="/" title="$site.title$">$site.logo$</a> 37 <a class="c-nav__logo" href="/" title="$site.title$">$site.logo$</a>
35 $for(menus.main)$ 38 $for(menus.main)$
36 <a class="c-nav__item c-nav__item--$it.id$" href="$it.url$">$it.label$</a> 39 <a class="c-nav__item c-nav__item--$it.id$" href="$it.url$">$it.label$</a>
37 $endfor$ 40 $endfor$
38 </div> 41 </div>
39 </nav> 42 </nav>
40 43
41 <main class="c-page s-page l-container l-container--content l-container--pad-v"> 44 <main class="c-page s-page l-container l-container--content l-container--pad-v">
42 <div class="c-page__content"> 45 <div class="c-page__content">
43 $if(ishome)$ 46 $if(is_home)$
44 <header class="c-page-header u-hidden@sm-down" role="presentation"> 47 <header class="c-page-header u-hidden@sm-down" role="presentation">
45${pageHeader()} 48${pageHeader()}
46 </header> 49 </header>
@@ -48,26 +51,26 @@ ${pageHeader()}
48 51
49$body$ 52$body$
50 53
51 $if(isblog)$ 54 $if(section.is_blog)$
52 ${categoryRef()} 55 ${categories.blog:categoryRef()}
53 ${pagelistByYear()} 56 ${pagelistByYear()}
54 $endif$ 57 $endif$
55 </div> 58 </div>
56 </main> 59 </main>
57 60
58 $if(ishome)$ 61 $if(is_home)$
59 <template id="header-sm"> 62 <template id="header-sm">
60${pageHeaderSm()} 63${pageHeaderSm()}
61 </template> 64 </template>
62 65
63 <script> 66 <script>
64 var headerEl = document.querySelector(".c-page-header"); 67 var headerEl = document.querySelector(".c-page-header");
65 var headerTemplateEl = document.getElementById("header-sm"); 68 var headerTemplateEl = document.getElementById("header-sm");
66 var headerSmEl = headerTemplateEl.content.cloneNode("true"); 69 var headerSmEl = headerTemplateEl.content.cloneNode("true");
67 70
68 headerEl.classList.remove("u-hidden@sm-down"); 71 headerEl.classList.remove("u-hidden@sm-down");
69 headerEl.appendChild(headerSmEl); 72 headerEl.appendChild(headerSmEl);
70 </script> 73 </script>
71 $endif$ 74 $endif$
72</body> 75</body>
73 76
diff --git a/templates/categoryRef.html b/templates/categoryRef.html
index 9a363cf..5715fa8 100644
--- a/templates/categoryRef.html
+++ b/templates/categoryRef.html
@@ -1,7 +1,7 @@
1$if(categories)$ 1$if(it)$
2<ul class="c-hlist"> 2 <ul class="c-hlist">
3 $for(categories)$ 3 $for(it/pairs)$
4 <li class="c-hlist__item"><strong>$it.key/uppercase$</strong>: $it.value$</li> 4 <li class="c-hlist__item"><strong>$it.key/uppercase$</strong>: $it.value$</li>
5 $endfor$ 5 $endfor$
6</ul> 6 </ul>
7$endif$ 7$endif$
diff --git a/templates/feed.xml b/templates/feed.xml
new file mode 100644
index 0000000..68d2fc4
--- /dev/null
+++ b/templates/feed.xml
@@ -0,0 +1,22 @@
1<?xml version="1.0" encoding="utf-8"?>
2<feed xmlns="http://www.w3.org/2005/Atom">
3 <title>$if(is_home)$$else$$title$ – $endif$$site.title$</title>
4 <link href="$feed.url.full$" rel="self"/>
5 <link href="$url.full$"/>
6 <updated>$feed.last_update.rfc3339$</updated>
7 <id>$url.full$</id>
8
9 $for(pages)$
10 $for(it.all)$
11 $if(it.date.rfc3339)$
12 <entry>
13 <id>$it.url.full$</id>
14 <title type="html"><![CDATA[$it.title$]]></title>
15 <link href="$it.url.full$"/>
16 <published>$it.date.rfc3339$</published>
17 <updated>$it.date.rfc3339$</updated>
18 </entry>
19 $endif$
20 $endfor$
21 $endfor$
22</feed>
diff --git a/templates/pageHeaderSm.html b/templates/pageHeaderSm.html
index 232b5b2..4db186c 100644
--- a/templates/pageHeaderSm.html
+++ b/templates/pageHeaderSm.html
@@ -3,7 +3,7 @@ $-- | _.~-"""-----~`` ,-´ ' ' |' | ' '
3$-- '| .´ ,~'\ ).,__,)/,," ' . ' | | | ' .' 3$-- '| .´ ,~'\ ).,__,)/,," ' . ' | | | ' .'
4$-- |_ `~´ (/\\, (/\\, _' '_ _| ' |_ _' '_ 4$-- |_ `~´ (/\\, (/\\, _' '_ _| ' |_ _' '_
5 5
6<pre class="c-page__prefixed c-page__prefixed--pre u-mt0 $if(ishome)$u-hidden@sm-up$endif$"> 6<pre class="c-page__prefixed c-page__prefixed--pre u-mt0 $if(is_home)$u-hidden@sm-up$endif$">
7.| <strong> //\__</strong> ' .' | . | ' . ' 7.| <strong> //\__</strong> ' .' | . | ' . '
8 | <strong> _.~-"""-----~`` ,-´</strong> ' ' |' | ' ' 8 | <strong> _.~-"""-----~`` ,-´</strong> ' ' |' | ' '
9'| <strong>.´ ,~'\ ).,__,)/,," </strong> ' . ' | | | ' .' 9'| <strong>.´ ,~'\ ).,__,)/,," </strong> ' . ' | | | ' .'
diff --git a/templates/pagelistByYear.html b/templates/pagelistByYear.html
index b884d89..ff55f0f 100644
--- a/templates/pagelistByYear.html
+++ b/templates/pagelistByYear.html
@@ -1,13 +1,11 @@
1$for(pages)$ 1$for(pages)$
2$for(it.by_year)$ 2 $for(it.by_year)$
3$-- <hr class="c-spacer" /> 3 <ul>
4$-- <h2>$it.key$</h2> 4 $for(it.value)$
5<ul> 5 <li class="c-page__prefixed c-page__prefixed--ref">
6 $for(it.value)$ 6 <a href="$it.url.rel$">$it.category/uppercase$ $it.date.yyyy_mm_dd$ - $it.title$</a>
7 <li class="c-page__prefixed c-page__prefixed--ref"> 7 </li>
8 <a href="$it.url_rel$">$it.category/uppercase$ $it.date$ - $it.title$</a> 8 $endfor$
9 </li> 9 </ul>
10 $endfor$ 10 $endfor$
11</ul>
12$endfor$
13$endfor$ 11$endfor$