Indexes!
authorelliottcable <[email protected]>
Sun, 18 May 2008 10:23:09 +0000 (18 02:23 -0800)
committerelliottcable <[email protected]>
Sun, 18 May 2008 10:23:09 +0000 (18 02:23 -0800)
lib/git-blog.rb
prepped/design/index.haml
prepped/design/main.css

index beee516..bfea59e 100644 (file)
@@ -136,8 +136,32 @@ task :clobber do
   end
 end
 
+# desc 'Invisible task, generates index.xhtml'
+task :index do
+  path = File.expand_path('.')
+  repo = should_be_initialized path
+  
+  commits = repo.log.select {|c| c.message =~ /New post: /}
+  posts = []
+  commits.map do |commit|
+    title = commit.message.match(/New post: (.*)$/)[1]
+    posts << {:title => title, :slug => title.slugize}
+  end
+  
+  template = IO.read :design / :index.haml
+  
+  completed = Haml::Engine.new(template, :filename => :design / :index.haml).
+    to_html Object.new, :posts => posts
+  
+  destination = :index.xhtml
+  file = File.open destination, File::RDWR|File::TRUNC|File::CREAT, 0664
+  file.puts completed
+  file.close
+  puts "index.xhtml compiled"
+end
+
 desc 'Generate xhtml files from posts and design'
-task :deploy => :clobber do
+task :deploy => [:clobber, :index] do
   should_be_initialized File.expand_path('.')
   
   Dir['posts/*.*'].each do |path|
@@ -155,7 +179,7 @@ task :deploy => :clobber do
     template = IO.read :design / :post.haml
     
     completed = Haml::Engine.new(template, :filename => :design / :post.haml).
-      to_html(Object.new, {:content => parsed, :title => post_title})
+      to_html Object.new, {:content => parsed, :title => post_title}
     
     destination = path.gsub /.#{markup}$/, '.xhtml'
     file = File.open destination, File::RDWR|File::TRUNC|File::CREAT, 0664
@@ -179,4 +203,5 @@ def should_be_initialized path
   raise "** You haven't used `rake initialize` yet." unless
     File.directory? File.join(path, 'posts') and
     (blog = Git.open path rescue false)
+  blog
 end
\ No newline at end of file
index e69de29..1373eae 100644 (file)
@@ -0,0 +1,18 @@
+!!! xml
+!!! 1.1
+%html{:xmlns => 'http://www.w3.org/1999/xhtml', :'xml:lang' => 'en'}
+  %head
+    %meta{:'http-equiv' => 'Content-Type', :content => 'application/xhtml+xml;charset=utf-8'}
+    %title yet another git-blog
+    %link{:rel => 'stylesheet', :href => 'design/main.css', :type => 'text/css;charset=utf-8'}
+    / %link{:rel => 'alternate', :href => '/posts/feed.rss', :type => 'application/rss+xml', :title => 'Feed (RSS 2.0)'}
+    / %link{:rel => 'alternate', :href => '/posts/feed.atom', :type => 'application/atom+xml', :title => 'Feed (Atom)'}
+  %body
+    %h1 yet another git-blog
+    %ol#posts
+      - for post in posts
+        %li
+          %a{:href => "posts/#{post[:slug]}", :title => post[:title]}= post[:title]
+    #footer
+      :markdown
+        powered by [git-blog](http://github.com/elliottcable/git-blog "elliottcable's git-blog on GitHub"), by [elliottcable](http://elliottcable.name "elliottcable")
\ No newline at end of file
index 3e3a2cb..9ebb096 100644 (file)
@@ -10,4 +10,21 @@ h1 {
   text-align: center;
   font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
   text-transform: uppercase;
+}
+
+#posts {
+  
+}
+
+#posts li {
+  list-style-type: none;
+  text-align: center;
+  font-size: 150%;
+}
+
+#footer {
+  position: absolute;
+  bottom: 10px;
+  right: 15px;
+  font-size: 85%;
 }
\ No newline at end of file