diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..a4be47f --- /dev/null +++ b/Rakefile @@ -0,0 +1,21 @@ +task :default => :build + +task :build => :clean do + system "context haiku.tex" +end + +task :clean do + rm_if_exist %w(haiku.pdf haiku.tuc haiku.log) +end + +task :fetch do + rm_if_exist "data/haiku.atom" + system "curl -o data/haiku.atom http://search.twitter.com/search.atom?q=%23haiku" +end + + +def rm_if_exist(paths) + Array(paths).each do |path| + rm path if File.file? path + end +end \ No newline at end of file diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/haiku.lua b/haiku.lua new file mode 100644 index 0000000..1c95c3e --- /dev/null +++ b/haiku.lua @@ -0,0 +1,11 @@ +haiku = haiku or {} +local p = tex.sprint + +function haiku.parse(tweet) + p("MWA* " .. tweet .. " *MWA") +end + +function haiku.author(str) + _, _, name = string.find(str, "^(%a+)") + p(name) +end \ No newline at end of file diff --git a/haiku.tex b/haiku.tex new file mode 100644 index 0000000..eb71622 --- /dev/null +++ b/haiku.tex @@ -0,0 +1,37 @@ + +\setuplayout + [footer=0cm, + header=0cm, + width=middle, + height=middle] + +\setuppagenumbering[location=] + +\starttext + +\registerctxluafile{haiku}{0.1} +\def\parsehaiku #1{\ctxlua{haiku.parse("#1")}} +\def\authorname #1{\ctxlua{haiku.author("#1")}} + +\startxmlsetups xml:atom:base + \xmlsetsetup{atom}{feed}{xml:atom:feed} +\stopxmlsetups + +\startxmlsetups xml:atom:feed + \xmlcommand{#1}{/entry}{xml:atom:entry} +\stopxmlsetups + +\startxmlsetups xml:atom:entry + \def\AUTHOR{\xmlfirst{#1}{/author/name}} + \def\HAIKU{\xmlfirst{#1}{/title}} + \startframedtext[corner=round,align=middle,frame=none,background=screen,backgroundscreen=.9,width=\textwidth] + From: \authorname{\AUTHOR}\par + \parsehaiku{ /MAA } + \stopframedtext +\stopxmlsetups + +\xmlregisterdocumentsetup{atom}{xml:atom:base} + +\xmlprocessfile{atom}{data/haiku.atom}{} + +\stoptext \ No newline at end of file