summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/metadata.lua4
-rw-r--r--scripts/page.lua29
2 files changed, 29 insertions, 4 deletions
diff --git a/scripts/metadata.lua b/scripts/metadata.lua
index 42bf71c..5d372fc 100644
--- a/scripts/metadata.lua
+++ b/scripts/metadata.lua
@@ -84,12 +84,12 @@ function process_pages(meta)
84 84
85 pages_all:sort(sort.page_sort(meta.list_order, meta.pages)) 85 pages_all:sort(sort.page_sort(meta.list_order, meta.pages))
86 pages_date_desc:sort(sort.page_sort("date_desc", meta.pages)) 86 pages_date_desc:sort(sort.page_sort("date_desc", meta.pages))
87 --local pages_random = pages_all:clone():shuffle() 87 local pages_random = pages_all:clone():shuffle()
88 88
89 meta.pages = { 89 meta.pages = {
90 all = pages_all, 90 all = pages_all,
91 date_desc = pages_date_desc, 91 date_desc = pages_date_desc,
92 --random = pages_random, 92 random = pages_random,
93 by_id = meta.pages 93 by_id = meta.pages
94 } 94 }
95end 95end
diff --git a/scripts/page.lua b/scripts/page.lua
index e18f392..4eeebb2 100644
--- a/scripts/page.lua
+++ b/scripts/page.lua
@@ -138,7 +138,7 @@ end
138function process_pages(meta) 138function process_pages(meta)
139 meta.pages.all = meta.pages.all:filterMap(deref_page(meta.pages.by_id)) 139 meta.pages.all = meta.pages.all:filterMap(deref_page(meta.pages.by_id))
140 meta.pages.date_desc = meta.pages.date_desc:filterMap(deref_page(meta.pages.by_id)) 140 meta.pages.date_desc = meta.pages.date_desc:filterMap(deref_page(meta.pages.by_id))
141 --meta.pages.random = meta.pages.random:filterMap(deref_page(meta.pages.by_id)) 141 meta.pages.random = meta.pages.random:filterMap(deref_page(meta.pages.by_id))
142end 142end
143 143
144function resolve_urls(global, build, meta) 144function resolve_urls(global, build, meta)
@@ -191,6 +191,31 @@ function process(global, build, meta, dir)
191 end 191 end
192end 192end
193 193
194function prune_pages(meta, n)
195 if n == 0 then
196 meta.pages = {
197 all = pandoc.List(),
198 date_desc = pandoc.List(),
199 random = pandoc.List(),
200 by_id = {}
201 }
202 else
203 for _, p in pairs(meta.pages.by_id) do
204 prune_pages(p, n - 1)
205 end
206 end
207end
208
209function prune(meta, up, down)
210 prune_pages(meta, down)
211
212 if up == 0 then
213 meta.parent = nil
214 elseif meta.parent then
215 prune(meta.parent, up - 1, down)
216 end
217end
218
194function Meta(meta) 219function Meta(meta)
195 local build = {} 220 local build = {}
196 221
@@ -230,7 +255,7 @@ function Meta(meta)
230 global.menus.main = prep_menu(meta.namespace.full, global.menus.main) 255 global.menus.main = prep_menu(meta.namespace.full, global.menus.main)
231 end 256 end
232 257
233 meta.parent = nil 258 prune(meta, 0, 2)
234 259
235 for key, value in pairs(global) do 260 for key, value in pairs(global) do
236 meta[key] = value 261 meta[key] = value