summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2022-07-27 19:10:15 +0200
committerVolpeon <git@volpeon.ink>2022-07-27 19:10:15 +0200
commitfd8aa54a4ce623d55219b1865e23b93b3b26e265 (patch)
treedc9ae2a4bcbfebe35defaede22e21b9cc1bd08d3
parentUpdated emojis (diff)
downloadvolpeon.ink-fd8aa54a4ce623d55219b1865e23b93b3b26e265.tar.gz
volpeon.ink-fd8aa54a4ce623d55219b1865e23b93b3b26e265.tar.bz2
volpeon.ink-fd8aa54a4ce623d55219b1865e23b93b3b26e265.zip
Added draft feature
-rw-r--r--Makefile7
-rw-r--r--content/notebook/pages/i-want-to-be-a-fox.md6
-rw-r--r--content/notebook/pages/index.md1
-rw-r--r--scripts/metadata.lua57
-rw-r--r--templates/layouts/page.html6
-rw-r--r--templates/partials/gallery_card.html7
-rw-r--r--templates/partials/grid_card.html7
-rw-r--r--templates/partials/list_card.html16
8 files changed, 68 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index 6801970..cfc583f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
1export DEPLOY_TARGET = vulpes@94.130.78.123:/srv/http/volpeon.ink/ 1export DEPLOY_TARGET = vulpes@94.130.78.123:/srv/http/volpeon.ink/
2export MODE = prod
2 3
3-include Env.mk 4-include Env.mk
4 5
@@ -61,10 +62,11 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \
61 -t html5 \ 62 -t html5 \
62 --wrap preserve \ 63 --wrap preserve \
63 --no-highlight \ 64 --no-highlight \
65 --metadata-file "$@.pages" \
64 --template scripts/metadata.json \ 66 --template scripts/metadata.json \
67 --metadata mode="$(MODE)" \
65 --metadata namespace="$(NAMESPACE)" \ 68 --metadata namespace="$(NAMESPACE)" \
66 --metadata file_out="$(patsubst .cache/meta/%.json,out/%.html,$@)" \ 69 --metadata file_out="$(patsubst .cache/meta/%.json,out/%.html,$@)" \
67 --metadata-file "$@.pages" \
68 $(PANDOC_FILTERS) \ 70 $(PANDOC_FILTERS) \
69 -o "$@.meta" "$<" 71 -o "$@.meta" "$<"
70 rm "$@.pages" 72 rm "$@.pages"
@@ -76,6 +78,7 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \
76 --lua-filter scripts/subpages.lua \ 78 --lua-filter scripts/subpages.lua \
77 $(GLOBAL_METADATA) \ 79 $(GLOBAL_METADATA) \
78 --metadata-file "$@.meta" \ 80 --metadata-file "$@.meta" \
81 --metadata mode="$(MODE)" \
79 --metadata file_out="$@" \ 82 --metadata file_out="$@" \
80 $(PANDOC_FILTERS) \ 83 $(PANDOC_FILTERS) \
81 -o "$@.content" "$<" 84 -o "$@.content" "$<"
@@ -99,6 +102,7 @@ out/%.html: content/%.md .cache/meta/%.json .cache/assets.json $(CONTENT_TEMPLAT
99 --lua-filter scripts/metadata.lua \ 102 --lua-filter scripts/metadata.lua \
100 $(GLOBAL_METADATA) \ 103 $(GLOBAL_METADATA) \
101 --metadata-file .cache/assets.json \ 104 --metadata-file .cache/assets.json \
105 --metadata mode="$(MODE)" \
102 --metadata-file "$(filter .cache/meta/%.json,$^)" \ 106 --metadata-file "$(filter .cache/meta/%.json,$^)" \
103 --metadata file_out="$@" \ 107 --metadata file_out="$@" \
104 $(PANDOC_FILTERS) \ 108 $(PANDOC_FILTERS) \
@@ -117,6 +121,7 @@ out/%.xml: content/%.md .cache/meta/%.json $(FEED_TEMPLATES_SRC) metadata/*.yaml
117 --lua-filter scripts/metadata.lua \ 121 --lua-filter scripts/metadata.lua \
118 $(GLOBAL_METADATA) \ 122 $(GLOBAL_METADATA) \
119 --metadata-file "$(filter .cache/meta/%.json,$^)" \ 123 --metadata-file "$(filter .cache/meta/%.json,$^)" \
124 --metadata mode="$(MODE)" \
120 --metadata file_out="$@" \ 125 --metadata file_out="$@" \
121 $(PANDOC_FILTERS) \ 126 $(PANDOC_FILTERS) \
122 -o "$@" "$<" 127 -o "$@" "$<"
diff --git a/content/notebook/pages/i-want-to-be-a-fox.md b/content/notebook/pages/i-want-to-be-a-fox.md
new file mode 100644
index 0000000..f43cac3
--- /dev/null
+++ b/content/notebook/pages/i-want-to-be-a-fox.md
@@ -0,0 +1,6 @@
1---
2schema_type: DigitalDocument
3title: I Want To Be a Fox
4date: 2022-08-27
5draft: true
6---
diff --git a/content/notebook/pages/index.md b/content/notebook/pages/index.md
index 510b20b..b32e28a 100644
--- a/content/notebook/pages/index.md
+++ b/content/notebook/pages/index.md
@@ -3,5 +3,4 @@ title: Pages
3position: 1 3position: 1
4list_read_indicators: true 4list_read_indicators: true
5feed: true 5feed: true
6unlisted: true
7--- 6---
diff --git a/scripts/metadata.lua b/scripts/metadata.lua
index 872034c..98ad9e5 100644
--- a/scripts/metadata.lua
+++ b/scripts/metadata.lua
@@ -170,14 +170,10 @@ end
170function find_depth(pages) 170function find_depth(pages)
171 local depth = 0 171 local depth = 0
172 172
173 if #pages.all ~= 0 then 173 for i = 1, #pages.all do
174 for i = 1, #pages.all do 174 local p = pages.all[i]
175 local p = pages.all[i] 175 local d = tonumber(p.depth) + 1
176 local d = tonumber(p.depth) 176 if d > depth then depth = d end
177 if d > depth then depth = d end
178 end
179
180 depth = depth + 1
181 end 177 end
182 178
183 return depth 179 return depth
@@ -187,9 +183,11 @@ function d1_page_to_list_item(meta, p)
187 return { 183 return {
188 title = p.title, 184 title = p.title,
189 subtitle = p.subtitle, 185 subtitle = p.subtitle,
190 date = meta.list_order == "date_desc" and p.date, 186 date = p.date,
191 last_update = meta.list_order == "date_desc" and p.last_update, 187 last_update = p.last_update,
188 show_date = meta.list_order == "date_desc",
192 schema_type = p.schema_type, 189 schema_type = p.schema_type,
190 draft = p.draft,
193 position = p.position, 191 position = p.position,
194 url = p.url, 192 url = p.url,
195 rel = p.rel, 193 rel = p.rel,
@@ -206,9 +204,11 @@ function d2_page_to_list_item(meta, cat, p, set_cat_title)
206 title = p.title, 204 title = p.title,
207 subtitle = p.subtitle, 205 subtitle = p.subtitle,
208 category = set_cat_title and cat.title, 206 category = set_cat_title and cat.title,
209 date = cat.list_order == "date_desc" and p.date, 207 date = p.date,
210 last_update = cat.list_order == "date_desc" and p.last_update, 208 last_update = p.last_update,
209 show_date = cat.list_order == "date_desc",
211 schema_type = p.schema_type, 210 schema_type = p.schema_type,
211 draft = p.draft,
212 position = p.position, 212 position = p.position,
213 url = p.url, 213 url = p.url,
214 rel = p.rel, 214 rel = p.rel,
@@ -240,17 +240,21 @@ function cat_to_list_cat(cat, allItems)
240 } 240 }
241end 241end
242 242
243function generate_list(meta) 243function generate_list(global, meta)
244 if meta.depth < 1 then return nil end 244 if meta.depth < 1 then return nil end
245 245
246 if meta.depth == 1 then 246 if meta.depth == 1 then
247 return meta.pages.all:map(function(p) return d1_page_to_list_item(meta, p) end) 247 return meta.pages.all
248 :map(function(p) return d1_page_to_list_item(meta, p) end)
249 :filter(function(p) return not p.draft or global.mode == "dev" end)
248 end 250 end
249 251
250 if meta.depth == 2 then 252 if meta.depth == 2 then
251 return meta.pages.all 253 return meta.pages.all
252 :map(function(cat) 254 :map(function(cat)
253 local allItems = cat.pages.all:map(function(p) return d2_page_to_list_item(meta, cat, p, false) end) 255 local allItems = cat.pages.all
256 :map(function(p) return d2_page_to_list_item(meta, cat, p, false) end)
257 :filter(function(p) return not p.draft or global.mode == "dev" end)
254 258
255 return cat_to_list_cat(cat, allItems) 259 return cat_to_list_cat(cat, allItems)
256 end) 260 end)
@@ -258,20 +262,25 @@ function generate_list(meta)
258 end 262 end
259 263
260 if meta.depth == 3 then 264 if meta.depth == 3 then
261 return meta.pages.all 265 local list = meta.pages.all
262 :map(function(cat) 266 :map(function(cat)
263 local allItems = cat.pages.all:flatMap(function(c) 267 local allItems = cat.pages.all
264 if #c.pages.all ~= 0 and cat.list_flatten then 268 :flatMap(function(c)
265 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end) 269 if #c.pages.all ~= 0 and cat.list_flatten then
266 else 270 return c.pages.all:map(function(p) return d2_page_to_list_item(cat, c, p, true) end)
267 return pandoc.List({ d1_page_to_list_item(cat, c) }) 271 else
268 end 272 return pandoc.List({ d1_page_to_list_item(cat, c) })
269 end) 273 end
274 end)
275 :filter(function(p) return not p.draft or global.mode == "dev" end)
276
270 allItems:sort(page_sort(cat.list_order)) 277 allItems:sort(page_sort(cat.list_order))
271 278
272 return cat_to_list_cat(cat, allItems) 279 return cat_to_list_cat(cat, allItems)
273 end) 280 end)
274 :filter(function(cat) return #cat.items ~= 0 end) 281 :filter(function(cat) return #cat.items ~= 0 end)
282
283 return list
275 end 284 end
276end 285end
277 286
@@ -329,7 +338,7 @@ function process(global, meta)
329 meta.date = meta.last_update 338 meta.date = meta.last_update
330 end 339 end
331 340
332 meta.list = generate_list(meta) 341 meta.list = generate_list(global, meta)
333 342
334 return meta 343 return meta
335end 344end
diff --git a/templates/layouts/page.html b/templates/layouts/page.html
index c1bd051..b93f45f 100644
--- a/templates/layouts/page.html
+++ b/templates/layouts/page.html
@@ -12,6 +12,12 @@
12 </time> 12 </time>
13 $endif$ 13 $endif$
14 14
15 $if(draft)$
16 <span class="o-badge u-mb-125">
17 Draft
18 </span>
19 $endif$
20
15 <h1 class="o-heading o-heading--xxl u-mt-0 p-name" itemprop="name headline"> 21 <h1 class="o-heading o-heading--xxl u-mt-0 p-name" itemprop="name headline">
16 <span class="s-headings__primary">$title$</span> 22 <span class="s-headings__primary">$title$</span>
17 </h1> 23 </h1>
diff --git a/templates/partials/gallery_card.html b/templates/partials/gallery_card.html
index 3020c2d..e319fa4 100644
--- a/templates/partials/gallery_card.html
+++ b/templates/partials/gallery_card.html
@@ -30,13 +30,16 @@ $if(it.thumbnail)$
30 </svg> 30 </svg>
31 $endif$ 31 $endif$
32 <div class="l-media__block l-media__block--main"> 32 <div class="l-media__block l-media__block--main">
33 $if(it.subtitle)$ 33 $if(it.draft)$
34 <strong class="u-d-block">$it.title$</strong>
35 <div><span class="o-badge">Draft</span></div>
36 $elseif(it.subtitle)$
34 <strong class="u-d-block">$it.title$</strong> 37 <strong class="u-d-block">$it.title$</strong>
35 <small class="u-d-block">$it.subtitle$</small> 38 <small class="u-d-block">$it.subtitle$</small>
36 $elseif(it.category)$ 39 $elseif(it.category)$
37 <small class="u-d-block">$it.category$</small> 40 <small class="u-d-block">$it.category$</small>
38 <strong class="u-d-block">$it.title$</strong> 41 <strong class="u-d-block">$it.title$</strong>
39 $elseif(it.last_update)$ 42 $elseif(it.show_date)$
40 <small class="u-d-block"> 43 <small class="u-d-block">
41 <time datetime="$it.last_update.yyyy_mm_dd$" itemprop="dateCreated"> 44 <time datetime="$it.last_update.yyyy_mm_dd$" itemprop="dateCreated">
42 $it.last_update.long$ 45 $it.last_update.long$
diff --git a/templates/partials/grid_card.html b/templates/partials/grid_card.html
index abcd923..8b65320 100644
--- a/templates/partials/grid_card.html
+++ b/templates/partials/grid_card.html
@@ -17,13 +17,16 @@ $if(it.url)$
17 </svg> 17 </svg>
18 $endif$ 18 $endif$
19 <div class="l-media__block l-media__block--main"> 19 <div class="l-media__block l-media__block--main">
20 $if(it.subtitle)$ 20 $if(it.draft)$
21 <strong class="u-d-block">$it.title$</strong>
22 <div><span class="o-badge">Draft</span></div>
23 $elseif(it.subtitle)$
21 <strong class="u-d-block">$it.title$</strong> 24 <strong class="u-d-block">$it.title$</strong>
22 <small class="u-d-block">$it.subtitle$</small> 25 <small class="u-d-block">$it.subtitle$</small>
23 $elseif(it.category)$ 26 $elseif(it.category)$
24 <small class="u-d-block">$it.category$</small> 27 <small class="u-d-block">$it.category$</small>
25 <strong class="u-d-block">$it.title$</strong> 28 <strong class="u-d-block">$it.title$</strong>
26 $elseif(it.last_update)$ 29 $elseif(it.show_date)$
27 <small class="u-d-block"> 30 <small class="u-d-block">
28 <time datetime="$it.last_update.yyyy_mm_dd$" itemprop="dateCreated"> 31 <time datetime="$it.last_update.yyyy_mm_dd$" itemprop="dateCreated">
29 $it.last_update.long$ 32 $it.last_update.long$
diff --git a/templates/partials/list_card.html b/templates/partials/list_card.html
index 755686f..0695eed 100644
--- a/templates/partials/list_card.html
+++ b/templates/partials/list_card.html
@@ -36,16 +36,14 @@ $if(it.url)$
36 </div> 36 </div>
37 <div class="l-media__block l-media__block--main u-d-none@sm-lo"> 37 <div class="l-media__block l-media__block--main u-d-none@sm-lo">
38 $it.title$ 38 $it.title$
39 </div> 39 </div>
40 $if(it.subtitle)$ 40 $if(it.draft)$
41 <small class="l-media__block u-d-none@sm-lo"> 41 <div class="l-media__block u-d-none@sm-lo"><span class="o-badge">Draft</span></div>
42 $it.subtitle$ 42 $elseif(it.subtitle)$
43 </small> 43 <small class="l-media__block u-d-none@sm-lo">$it.subtitle$</small>
44 $elseif(it.category)$ 44 $elseif(it.category)$
45 <small class="l-media__block u-d-none@sm-lo"> 45 <small class="l-media__block u-d-none@sm-lo">$it.category$</small>
46 $it.category$ 46 $elseif(it.show_date)$
47 </small>
48 $elseif(it.last_update)$
49 <small class="l-media__block u-d-none@sm-lo"> 47 <small class="l-media__block u-d-none@sm-lo">
50 <time datetime="$it.last_update.yyyy_mm_dd$" itemprop="dateCreated"> 48 <time datetime="$it.last_update.yyyy_mm_dd$" itemprop="dateCreated">
51 $it.last_update.short$ 49 $it.last_update.short$