jorvick

Tue, 14 Jul 2009 02:07:18 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 14 Jul 2009 02:07:18 +0100
changeset 13
39add8e7fa99
child 14
7e9c3f32ec0a
permissions
-rwxr-xr-x

Add initial jorvick utility to manage posts and build the site

#!/usr/bin/env lua

require "jorvick.util"

local commands = {};

function commands.build()
	require "jorvick.build";
end

function commands.create(...)
	local title = table.concat({...}, " ");
	if #title == 0 then
		title = os.date("New Post %Y-%m-%d");
	end
	
	local filename = make_short_title(title);
	print(posts_dir..filename)
	local f = io.open(posts_dir..filename..".markdown", "r");
	if f then print("File already exists or is unreable"); return; end
	f = io.open(posts_dir..filename..".markdown", "w+");
	if not f then
		print("File not writeable");
	end
	
	-- YAML
	--f:write("
end

function commands.help()
	print "Jorvick - Blog Generator"
	print ""
	print "Commands:"
	print "   create - Create a new blank post with a title"
	print "  publish - Mark a post as published and stamp it with a date"
	print "    build - Generate the HTML files and feed for all posts"
	print ""
end

local command = arg[1] or "help";
table.remove(arg, 1);
(commands[command] or commands.help)(unpack(arg));

mercurial