diff options
author | Aki <please@ignore.pl> | 2024-09-02 23:46:25 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-09-02 23:46:25 +0200 |
commit | ed586b4fe54c9a3125cd7050f79a1b0d441644be (patch) | |
tree | 48062c862168ba2383b54219c8ddb9464b685688 | |
parent | 2c6dc408d399197f44d5047072a6f2afcd140c17 (diff) | |
download | huh-ed586b4fe54c9a3125cd7050f79a1b0d441644be.zip huh-ed586b4fe54c9a3125cd7050f79a1b0d441644be.tar.gz huh-ed586b4fe54c9a3125cd7050f79a1b0d441644be.tar.bz2 |
Script can now be configured to filter by pattern and/or direct excludes list
-rwxr-xr-x | generate-index.lua | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/generate-index.lua b/generate-index.lua index b079434..1ab4db4 100755 --- a/generate-index.lua +++ b/generate-index.lua @@ -1,7 +1,8 @@ #!/usr/bin/env lua -local pretty = require"pl.pretty" +local config = require"pl.config" local dir = require"pl.dir" local gumbo = require"gumbo" +local tablex = require"pl.tablex" local function parse (stamp) @@ -23,16 +24,23 @@ local function describe (date) end +config = config.read(arg[1] or "huh.conf") or {} +config.excludes = tablex.makeset(config.excludes or {}) + + +local function matches (str) + if config.pattern then + return str:match(config.pattern) + end + return str +end + + local pages = dir.getfiles(".", "*.html") local takeaways = { ["published-on"] = "published", ["last-modified-on"] = "modified", } -local excludes = { - ["index.html"] = true, - ["graveyard_of_the_drawings.html"] = true, - ["plop.html"] = true, -} local posts = {} for _, filename in pairs(pages) do local document = gumbo.parseFile(filename) @@ -49,7 +57,7 @@ for _, filename in pairs(pages) do end end end - if properties.filename:match"^[^_]" and not excludes[properties.filename] then + if matches(properties.filename) and not config.excludes[properties.filename] then table.insert(posts, properties) end end |