Add initial jorvick utility to manage posts and build the site

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
parent 12
4c759312950b
child 14
7e9c3f32ec0a

Add initial jorvick utility to manage posts and build the site

jorvick file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jorvick	Tue Jul 14 02:07:18 2009 +0100
@@ -0,0 +1,42 @@
+#!/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