summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-01-12 17:29:28 -0600
committersanine <sanine.not@pm.me>2023-01-12 17:29:28 -0600
commitf9f8a3206298363059601f6c389584426962e5e4 (patch)
treeb0ed2fd393a1064c01aabdce548e9f84215a8c57 /plugins
parent655cd79991ec9204afb9f5acf52495c13af14d25 (diff)
wrong branch :c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/navigation.lua0
-rw-r--r--plugins/toolkit.lua42
2 files changed, 42 insertions, 0 deletions
diff --git a/plugins/navigation.lua b/plugins/navigation.lua
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/plugins/navigation.lua
diff --git a/plugins/toolkit.lua b/plugins/toolkit.lua
new file mode 100644
index 0000000..e5f162a
--- /dev/null
+++ b/plugins/toolkit.lua
@@ -0,0 +1,42 @@
+local toolkit = {}
+
+toolkit.file_iterator = function(directory)
+ local _, files = argent.scanDirectory(directory)
+ local i = 0
+ local n = table.getn(files)
+ return function()
+ i = i+1
+ if i<=n then return files[i] end
+ end
+end
+
+
+toolkit.basename = function(filename)
+ return string.gsub(filename, '%.lua$', '')
+end
+
+
+local function extract_page(file)
+ if not string.match(file, '%.lua$') then return nil end
+
+ local success, result = pcall(loadfile(file), 0, 1)
+ if not success then return nil end
+ return result
+end
+
+toolkit.pages = function(directory)
+ page_array = {}
+ local path = argent.config.site_directory..directory
+ for file in toolkit.file_iterator(path) do
+ local page = extract_page(path..file)
+ if page then
+ page.href = '/'..directory..toolkit.basename(file)..'.html'
+ table.insert(page_array, page)
+ end
+ end
+
+ return page_array
+end
+
+
+return toolkit