~ryanford/git-blog-tup

b6258a9f6e3940e0dbafd23a805a21db1619e486 — Ryan Ford 3 years ago ea8d77c
use tup builtin varsed
3 files changed, 3 insertions(+), 34 deletions(-)

M .gitignore
D plugins/varsed
M src/posts/Tupfile
M .gitignore => .gitignore +1 -0
@@ 1,4 1,5 @@
.tup
tup-generate.vardict
.build_files
tmp
dist

D plugins/varsed => plugins/varsed +0 -32
@@ 1,32 0,0 @@
#!/usr/bin/env lua

local config_input = io.open(arg[1])
local file_input = io.input(arg[2])
local output = io.output(arg[3])

local config = {}
do
   local config_file = config_input:read("*a")
   for entry in config_file:gmatch[[(CONFIG_%w+=(['"]).-%2)]] do
      local key, value = entry:match[[CONFIG_(%w+)=(.*)]]
      if value:match[[((['"]).*%2)]] then
         value = value:sub(2, -2)
      end
      config[key] = value
   end
end
config_input:close()

local replaced do
   replaced = file_input:read("*a")
   local at_rule = "@%s@"
   for key, value in pairs(config) do
      replaced = replaced:gsub(at_rule:format(key), value)
   end
   file_input:close()
end

output:write(replaced)
if arg[2] then output:close() end

os.exit(0, true)

M src/posts/Tupfile => src/posts/Tupfile +2 -2
@@ 2,7 2,7 @@ include_rules
include $(SCRIPTS)/create_posts.lua

: foreach *.md |> ^b generating %f^ echo "%f" | $(NEW_PIPELINE) > %o |> $(TMP)/posts/%B.html {posts}
: foreach {posts} |> ^ substitution on %b^ $(PLUGINS)/varsed "$(ROOT)/tup.config" "%f" >  %o |> $(DIST)/posts/%b
: foreach {posts} |> ^ substitution on %b^ tup varsed "$(ROOT)/tup.config" "%f" >  %o |> $(DIST)/posts/%b

: *.md |> ^b generating index.html^ $(PLUGINS)/create_index "%f" > "%o" |> $(TMP)/index.html {index}
: {index} |> ^ substitution on %b^ $(PLUGINS)/varsed "$(ROOT)/tup.config" "%f" > %o |> $(DIST)/%b
: {index} |> ^ substitution on %b^ tup varsed "$(ROOT)/tup.config" "%f" > %o |> $(DIST)/%b