diff options
author | Volpeon <git@volpeon.ink> | 2020-12-30 09:06:31 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2020-12-30 09:06:31 +0100 |
commit | 3ab8981195dbbdc553fbe1a14178b6793a81fa3b (patch) | |
tree | eee7ce7de75903d0140245dd1d39686c73113bd3 | |
parent | Fixed regression: Category showed up in child pages as well (diff) | |
download | volpeon.ink-3ab8981195dbbdc553fbe1a14178b6793a81fa3b.tar.gz volpeon.ink-3ab8981195dbbdc553fbe1a14178b6793a81fa3b.tar.bz2 volpeon.ink-3ab8981195dbbdc553fbe1a14178b6793a81fa3b.zip |
Revert to old category metadata collection, add support for authors
-rw-r--r-- | metadata/categories.json | 6 | ||||
-rw-r--r-- | metadata/metadata.yaml | 8 | ||||
-rwxr-xr-x | scripts/build_content.sh | 34 | ||||
-rw-r--r-- | templates/base.html | 6 | ||||
-rw-r--r-- | templates/categoryRef.html | 6 | ||||
-rw-r--r-- | templates/feed.xml | 27 |
6 files changed, 69 insertions, 18 deletions
diff --git a/metadata/categories.json b/metadata/categories.json new file mode 100644 index 0000000..9ce0815 --- /dev/null +++ b/metadata/categories.json | |||
@@ -0,0 +1,6 @@ | |||
1 | { | ||
2 | "blog": { | ||
3 | "tes": "Testing", | ||
4 | "per": "Personal" | ||
5 | } | ||
6 | } | ||
diff --git a/metadata/metadata.yaml b/metadata/metadata.yaml index 00a8571..7d30a2a 100644 --- a/metadata/metadata.yaml +++ b/metadata/metadata.yaml | |||
@@ -2,6 +2,9 @@ site: | |||
2 | title: Volpeon's Den | 2 | title: Volpeon's Den |
3 | logo: \\\\/ | 3 | logo: \\\\/ |
4 | 4 | ||
5 | author: | ||
6 | - name: Volpeon | ||
7 | |||
5 | menus: | 8 | menus: |
6 | main: | 9 | main: |
7 | - id: index | 10 | - id: index |
@@ -10,8 +13,3 @@ menus: | |||
10 | - id: blog | 13 | - id: blog |
11 | label: Blog | 14 | label: Blog |
12 | url: /blog/ | 15 | url: /blog/ |
13 | |||
14 | categories: | ||
15 | blog: | ||
16 | tes: Testing | ||
17 | per: Personal | ||
diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 12de8c8..fc5ddea 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh | |||
@@ -25,6 +25,8 @@ get_filters() { | |||
25 | 25 | ||
26 | FILTERS=$(get_filters) | 26 | FILTERS=$(get_filters) |
27 | 27 | ||
28 | CATEGORIES=$(cat "$METADATA_DIR/categories.json") | ||
29 | |||
28 | target_filename() { | 30 | target_filename() { |
29 | filename=$1 | 31 | filename=$1 |
30 | filename=${filename#"$CONTENT_DIR"} | 32 | filename=${filename#"$CONTENT_DIR"} |
@@ -98,6 +100,8 @@ get_subpages_meta() { | |||
98 | not_empty: false \ | 100 | not_empty: false \ |
99 | }") | 101 | }") |
100 | 102 | ||
103 | categories="{}" | ||
104 | |||
101 | if [ ${#child_pages[@]} -ne 0 ]; then | 105 | if [ ${#child_pages[@]} -ne 0 ]; then |
102 | #echo -e "\033[0;90m[////////]\033[0m Child pages:" | 106 | #echo -e "\033[0;90m[////////]\033[0m Child pages:" |
103 | 107 | ||
@@ -108,6 +112,8 @@ get_subpages_meta() { | |||
108 | 112 | ||
109 | metadata=$(metadata "$file") | 113 | metadata=$(metadata "$file") |
110 | 114 | ||
115 | section=$(get_section "$file") | ||
116 | |||
111 | url_rel=$(target_url_rel "$basedir" "$file" "html") | 117 | url_rel=$(target_url_rel "$basedir" "$file" "html") |
112 | url_abs=$(target_url_abs "$file" "html") | 118 | url_abs=$(target_url_abs "$file" "html") |
113 | url_full="${SITE%/}$url_abs" | 119 | url_full="${SITE%/}$url_abs" |
@@ -119,6 +125,13 @@ get_subpages_meta() { | |||
119 | date_rfc3339=$(date -d "$date" --rfc-3339=seconds | sed 's/ /T/') | 125 | date_rfc3339=$(date -d "$date" --rfc-3339=seconds | sed 's/ /T/') |
120 | fi | 126 | fi |
121 | 127 | ||
128 | category=$(echo "$metadata" | jq -r .category) | ||
129 | category_name="" | ||
130 | |||
131 | if [ "$section" != "" ] && [ "$category" != "" ]; then | ||
132 | category_name=$(echo "$CATEGORIES" | jq -r .$section.$category) | ||
133 | fi | ||
134 | |||
122 | metadata=$(echo "$metadata" | jq ". * { \ | 135 | metadata=$(echo "$metadata" | jq ". * { \ |
123 | date: { \ | 136 | date: { \ |
124 | yyyy_mm_dd: \"$date\", \ | 137 | yyyy_mm_dd: \"$date\", \ |
@@ -140,16 +153,23 @@ get_subpages_meta() { | |||
140 | 153 | ||
141 | pages=$(echo "$pages" | jq ".by_year.\"$date_year\" += [ $metadata ]") | 154 | pages=$(echo "$pages" | jq ".by_year.\"$date_year\" += [ $metadata ]") |
142 | fi | 155 | fi |
143 | done | ||
144 | 156 | ||
145 | pages=$(echo "$pages" \ | 157 | if [ "$category" != "" ]; then |
146 | | jq ".all |= (sort_by(.date) | reverse) \ | 158 | categories=$(echo "$categories" | jq ".$category = { name: \"$category_name\", count: (.$category.count + 1) } ") |
147 | | .by_year |= (to_entries | sort_by(.key) | reverse \ | 159 | fi |
148 | | .[].value |= (sort_by(.date) | reverse))") | 160 | done |
149 | fi | 161 | fi |
150 | 162 | ||
163 | pages=$(echo "$pages" \ | ||
164 | | jq ".all |= (sort_by(.date) | reverse) \ | ||
165 | | .by_year |= (to_entries | sort_by(.key) | reverse \ | ||
166 | | .[].value |= (sort_by(.date) | reverse))") | ||
167 | |||
168 | categories=$(echo "$categories" | jq ". | to_entries | sort_by(.key)") | ||
169 | |||
151 | echo "{}" | jq ". + { \ | 170 | echo "{}" | jq ". + { \ |
152 | pages: $pages \ | 171 | pages: $pages, \ |
172 | categories: $categories | ||
153 | }" | 173 | }" |
154 | } | 174 | } |
155 | 175 | ||
@@ -163,7 +183,7 @@ handle () { | |||
163 | 183 | ||
164 | meta_file=$(mktemp) | 184 | meta_file=$(mktemp) |
165 | 185 | ||
166 | metadata=$(metadata "$file") | 186 | metadata=$(metadata "$1") |
167 | metadata=$(echo "[ \ | 187 | metadata=$(echo "[ \ |
168 | $metadata, \ | 188 | $metadata, \ |
169 | $(get_subpages_meta "$1") \ | 189 | $(get_subpages_meta "$1") \ |
diff --git a/templates/base.html b/templates/base.html index 9574d08..4b8ea1e 100644 --- a/templates/base.html +++ b/templates/base.html | |||
@@ -6,8 +6,8 @@ | |||
6 | <meta name="viewport" content="width=device-width, initial-scale=1" /> | 6 | <meta name="viewport" content="width=device-width, initial-scale=1" /> |
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)$ |
10 | <meta name="author" content="$author-meta$" /> | 10 | <meta name="author" content="$it.name$$if(it.email)$ <$it.email$>$endif$" /> |
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$" /> |
@@ -53,7 +53,7 @@ $body$ | |||
53 | 53 | ||
54 | $if(section.is_blog)$ | 54 | $if(section.is_blog)$ |
55 | $if(pages.not_empty)$ | 55 | $if(pages.not_empty)$ |
56 | ${categories.blog:categoryRef()} | 56 | ${categoryRef()} |
57 | ${pagelistByYear()} | 57 | ${pagelistByYear()} |
58 | $endif$ | 58 | $endif$ |
59 | $endif$ | 59 | $endif$ |
diff --git a/templates/categoryRef.html b/templates/categoryRef.html index 5715fa8..58dc5fe 100644 --- a/templates/categoryRef.html +++ b/templates/categoryRef.html | |||
@@ -1,7 +1,7 @@ | |||
1 | $if(it)$ | 1 | $if(categories)$ |
2 | <ul class="c-hlist"> | 2 | <ul class="c-hlist"> |
3 | $for(it/pairs)$ | 3 | $for(categories)$ |
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.name$ ($it.value.count$)</li> |
5 | $endfor$ | 5 | $endfor$ |
6 | </ul> | 6 | </ul> |
7 | $endif$ | 7 | $endif$ |
diff --git a/templates/feed.xml b/templates/feed.xml index 68d2fc4..f1439eb 100644 --- a/templates/feed.xml +++ b/templates/feed.xml | |||
@@ -5,6 +5,14 @@ | |||
5 | <link href="$url.full$"/> | 5 | <link href="$url.full$"/> |
6 | <updated>$feed.last_update.rfc3339$</updated> | 6 | <updated>$feed.last_update.rfc3339$</updated> |
7 | <id>$url.full$</id> | 7 | <id>$url.full$</id> |
8 | $for(author)$ | ||
9 | <author> | ||
10 | <name>$it.name$</name> | ||
11 | $if(it.email)$ | ||
12 | <email>$it.email$</email> | ||
13 | $endif$ | ||
14 | </author> | ||
15 | $endfor$ | ||
8 | 16 | ||
9 | $for(pages)$ | 17 | $for(pages)$ |
10 | $for(it.all)$ | 18 | $for(it.all)$ |
@@ -12,6 +20,25 @@ | |||
12 | <entry> | 20 | <entry> |
13 | <id>$it.url.full$</id> | 21 | <id>$it.url.full$</id> |
14 | <title type="html"><![CDATA[$it.title$]]></title> | 22 | <title type="html"><![CDATA[$it.title$]]></title> |
23 | $if(it.author)$ | ||
24 | $for(it.author)$ | ||
25 | <author> | ||
26 | <name>$it.name$</name> | ||
27 | $if(it.email)$ | ||
28 | <email>$it.email$</email> | ||
29 | $endif$ | ||
30 | </author> | ||
31 | $endfor$ | ||
32 | $else$ | ||
33 | $for(author)$ | ||
34 | <author> | ||
35 | <name>$author.name$</name> | ||
36 | $if(author.email)$ | ||
37 | <email>$author.email$</email> | ||
38 | $endif$ | ||
39 | </author> | ||
40 | $endfor$ | ||
41 | $endif$ | ||
15 | <link href="$it.url.full$"/> | 42 | <link href="$it.url.full$"/> |
16 | <published>$it.date.rfc3339$</published> | 43 | <published>$it.date.rfc3339$</published> |
17 | <updated>$it.date.rfc3339$</updated> | 44 | <updated>$it.date.rfc3339$</updated> |