Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mfilej committed Feb 11, 2010
0 parents commit 2a920fa
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 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
Empty file added data/.gitkeep
Empty file.
11 changes: 11 additions & 0 deletions 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
37 changes: 37 additions & 0 deletions 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

0 comments on commit 2a920fa

Please sign in to comment.