Support for output_dir config option

Wed, 20 May 2009 14:40:24 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 20 May 2009 14:40:24 +0100
changeset 2
80eb1f7784c4
parent 1
74deddff1202
child 3
f22a275a3a33

Support for output_dir config option

build.lua file | annotate | diff | comparison | revisions
--- a/build.lua	Mon May 18 15:20:52 2009 +0100
+++ b/build.lua	Wed May 20 14:40:24 2009 +0100
@@ -8,6 +8,7 @@
 
 posts_dir = posts_dir or "_posts/"
 layouts_dir = layouts_dir or "_layouts/"
+output_dir = output_dir or "./"
 -- - -- - -- 
 
 -- Logging --
@@ -18,6 +19,9 @@
 -- Append '/' to end of posts_dir if necessary
 posts_dir = posts_dir:gsub("([^/])$", "%1/")
 
+-- Append '/' to end of output_dir if necessary
+output_dir = output_dir:gsub("([^/])$", "%1/")
+
 -- Append '/' to end of base_url if necessary
 base_url = base_url:gsub("([^/])$", "%1/")
 
@@ -116,8 +120,8 @@
 local unpublished = 0;
 for n, post in ipairs(posts) do
 	if post.content and (not post.layout or layouts[post.layout]) then
-		lfs.mkdir(post.shorttitle);
-		local outfile, err = io.open(post.shorttitle.."/index.html", "w+");
+		lfs.mkdir(output_dir..post.shorttitle);
+		local outfile, err = io.open(output_dir..post.shorttitle.."/index.html", "w+");
 		if outfile then
 			local layout = layouts[post.layout or "default"];
 			
@@ -163,7 +167,7 @@
 msg_info(" - - - ");
 
 -- Do feed
-local atom = io.open("feed/atom.xml.new", "w+");
+local atom = io.open(output_dir.."feed/atom.xml.new", "w+");
 atom:write[[<?xml version="1.0" encoding="UTF-8"?>
 	<feed xmlns="http://www.w3.org/2005/Atom">
 ]]

mercurial