Permalink
Browse files

The main index can be a normal mustache template

  • Loading branch information...
tomafro committed Jul 2, 2012
1 parent 5fddc13 commit b19e66b1944239fec8e4f0a4fe6046e69a68bb5f
View
@@ -8,7 +8,6 @@ def initialize(source, destination)
Mustache.template_path = source + "/_templates"
Mustache.raise_on_context_miss = true
require 'post'
- require 'main_index'
require 'tag_index'
require 'month_index'
require 'stylesheet'
@@ -30,15 +29,15 @@ def posts
end
def recent_posts
- posts.compact.reverse.take(10)
+ posts.take(10)
end
def stylesheets
pages_with_path {|path| path.starts_with?('stylesheets')}
end
def pages_with_path(&block)
- pages.select(&block).values
+ Collection.new(pages.select(&block).values.compact.reverse)
end
def updated_date_xml
@@ -77,7 +76,6 @@ def template_for(path, include_layouts = false)
when '.page' then ::Page
when '.post' then ::Post
when '.scss' then ::Stylesheet
- when '.main_index' then ::MainIndex
when '.tag_index' then ::TagIndex
when '.month_index' then ::MonthIndex
when '.txt' then ::Static
@@ -111,6 +109,16 @@ def in_source_folder(&block)
end
end
+ class Collection < Array
+ define_method "take-6" do
+ take(6)
+ end
+
+ define_method "leave-6" do
+ from(6)
+ end
+ end
+
class Destination
def initialize(directory)
@directory = directory
View
@@ -1,26 +0,0 @@
-require 'lanyon'
-
-class MainIndex < Lanyon::Template
- def url
- "/"
- end
-
- def title
- "Tom Ward's blog"
- end
-
- def description
- "Personal blog of Tom Ward, in which he writes about ruby, rails and web development, as well as other random ephemera"
- end
-
- def layout
- "_layouts/default.mustache"
- end
-
- def write_to(destination)
- posts = site.posts.reverse.take(6)
- push_context posts: posts do
- destination.write('index.html', render_page(context))
- end
- end
-end
View
@@ -16,7 +16,7 @@ def write_to(destination)
m = (month < 10) ? "0#{month}" : month.to_s
raise "#{month}" if m.blank?
- push_context posts: posts.reverse, title: "Posts from #{m}/#{year}", url: "/#{year}/#{m}" do
+ push_context posts: posts, title: "Posts from #{m}/#{year}", url: "/#{year}/#{m}" do
destination.write "/#{year}/#{m}.html", render_page(context)
end
end
View
@@ -8,7 +8,7 @@ def layout
def write_to(destination)
tags = site.posts.compact.collect(&:tags).flatten.uniq
tags.each do |tag|
- posts = site.posts.reverse.select {|p| p && p.tags.include?(tag) }
+ posts = site.posts.select {|p| p && p.tags.include?(tag) }
#context = self.context.dup
push_context(
posts: posts,
View
@@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Tom Ward</title>
<link href="http://tomafro.net/atom.xml" rel="self"/>
- <updated>2012-06-24T10:13:20+01:00</updated>
+ <updated>2012-07-02T11:29:56+01:00</updated>
<id>http://tomafro.net/</id>
<author>
<name>Tom Ward</name>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -10,98 +10,98 @@
<changefreq>weekly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/05/adam-sandersons-open-gem</loc>
- <lastmod>2009-05-06</lastmod>
+ <loc>http://tomafro.net/2012/06/tip-bundler-with-binstubs</loc>
+ <lastmod>2012-06-21</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/05/automatching-rails-paths-in-cucumber</loc>
- <lastmod>2009-05-13</lastmod>
+ <loc>http://tomafro.net/2012/02/working-inside-government</loc>
+ <lastmod>2012-02-29</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/05/imitation-is-the-sincerest-form-of-flattery</loc>
- <lastmod>2009-05-14</lastmod>
+ <loc>http://tomafro.net/2011/09/geohash-toy-code-released</loc>
+ <lastmod>2011-09-24</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/05/using-rack-middleware-for-good-and-evil</loc>
- <lastmod>2009-05-22</lastmod>
+ <loc>http://tomafro.net/2011/09/a-small-toy-to-explore-geohashes</loc>
+ <lastmod>2011-09-15</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/05/i-thought-we-were-going-to-kew-gardens</loc>
- <lastmod>2009-05-23</lastmod>
+ <loc>http://tomafro.net/2011/09/tip-automatic-bundle-exec-for-rake-and-more</loc>
+ <lastmod>2011-09-01</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/05/an-objective-c-implementation-of-active-supports-inflector</loc>
- <lastmod>2009-05-28</lastmod>
+ <loc>http://tomafro.net/2011/08/presenting-the-hashblue-api</loc>
+ <lastmod>2011-08-02</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/05/read-active-record-columns-directly-from-the-class</loc>
- <lastmod>2009-05-29</lastmod>
+ <loc>http://tomafro.net/2011/03/hashblue-opens-for-business</loc>
+ <lastmod>2011-03-03</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/06/pimp-my-script-console</loc>
- <lastmod>2009-06-22</lastmod>
+ <loc>http://tomafro.net/2011/02/rails-mongo-instrumentation-gem</loc>
+ <lastmod>2011-02-19</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/07/dscl-the-easy-way-to-add-hosts-on-osx</loc>
- <lastmod>2009-07-08</lastmod>
+ <loc>http://tomafro.net/2011/02/experimental-mongo-instrumentation</loc>
+ <lastmod>2011-02-18</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/07/salvador-dali-on-whats-my-line</loc>
- <lastmod>2009-07-10</lastmod>
+ <loc>http://tomafro.net/2011/02/rails-3-column-reader-tweak</loc>
+ <lastmod>2011-02-08</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/kernel-specific-zsh-dotfiles</loc>
- <lastmod>2009-08-03</lastmod>
+ <loc>http://tomafro.net/2010/02/updated-rails-template-for-bundler</loc>
+ <lastmod>2010-02-28</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/the-cost-of-explicit-returns-in-ruby</loc>
- <lastmod>2009-08-04</lastmod>
+ <loc>http://tomafro.net/2010/02/rails-3-direct-column-reader</loc>
+ <lastmod>2010-02-11</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/tip-move-to-directory-and-open-in-textmate</loc>
- <lastmod>2009-08-07</lastmod>
+ <loc>http://tomafro.net/2010/01/how-to-use-rails3-gems-now</loc>
+ <lastmod>2010-01-24</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/using-indexes-in-rails-index-your-associations</loc>
- <lastmod>2009-08-11</lastmod>
+ <loc>http://tomafro.net/2010/01/tip-relative-paths-with-file-expand-path</loc>
+ <lastmod>2010-01-23</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/tip-create-and-move-to-directory</loc>
- <lastmod>2009-08-12</lastmod>
+ <loc>http://tomafro.net/2009/11/taking-screenshots-of-web-pages-with-macruby</loc>
+ <lastmod>2009-11-30</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/zsh-completion-for-gem-and-gem-open</loc>
- <lastmod>2009-08-14</lastmod>
+ <loc>http://tomafro.net/2009/11/zoom-keyboard-shortcut-for-os-x</loc>
+ <lastmod>2009-11-06</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/using-indexes-in-rails-choosing-additional-indexes</loc>
- <lastmod>2009-08-18</lastmod>
+ <loc>http://tomafro.net/2009/11/building-gems-from-a-rails-branch</loc>
+ <lastmod>2009-11-05</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/08/tip-open-new-tab-in-osx-terminal</loc>
- <lastmod>2009-08-19</lastmod>
+ <loc>http://tomafro.net/2009/11/a-rails-template-for-gem-bundler</loc>
+ <lastmod>2009-11-03</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/09/quickly-list-missing-foreign-key-indexes</loc>
- <lastmod>2009-09-22</lastmod>
+ <loc>http://tomafro.net/2009/10/tip-cdpath-am-i-the-last-to-know</loc>
+ <lastmod>2009-10-06</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
@@ -110,103 +110,98 @@
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/10/tip-cdpath-am-i-the-last-to-know</loc>
- <lastmod>2009-10-06</lastmod>
- <changefreq>monthly</changefreq>
- </url>
- <url>
- <loc>http://tomafro.net/2009/11/a-rails-template-for-gem-bundler</loc>
- <lastmod>2009-11-03</lastmod>
+ <loc>http://tomafro.net/2009/09/quickly-list-missing-foreign-key-indexes</loc>
+ <lastmod>2009-09-22</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/11/building-gems-from-a-rails-branch</loc>
- <lastmod>2009-11-05</lastmod>
+ <loc>http://tomafro.net/2009/08/tip-open-new-tab-in-osx-terminal</loc>
+ <lastmod>2009-08-19</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/11/zoom-keyboard-shortcut-for-os-x</loc>
- <lastmod>2009-11-06</lastmod>
+ <loc>http://tomafro.net/2009/08/using-indexes-in-rails-choosing-additional-indexes</loc>
+ <lastmod>2009-08-18</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2009/11/taking-screenshots-of-web-pages-with-macruby</loc>
- <lastmod>2009-11-30</lastmod>
+ <loc>http://tomafro.net/2009/08/zsh-completion-for-gem-and-gem-open</loc>
+ <lastmod>2009-08-14</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2010/01/tip-relative-paths-with-file-expand-path</loc>
- <lastmod>2010-01-23</lastmod>
+ <loc>http://tomafro.net/2009/08/tip-create-and-move-to-directory</loc>
+ <lastmod>2009-08-12</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2010/01/how-to-use-rails3-gems-now</loc>
- <lastmod>2010-01-24</lastmod>
+ <loc>http://tomafro.net/2009/08/using-indexes-in-rails-index-your-associations</loc>
+ <lastmod>2009-08-11</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2010/02/rails-3-direct-column-reader</loc>
- <lastmod>2010-02-11</lastmod>
+ <loc>http://tomafro.net/2009/08/tip-move-to-directory-and-open-in-textmate</loc>
+ <lastmod>2009-08-07</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2010/02/updated-rails-template-for-bundler</loc>
- <lastmod>2010-02-28</lastmod>
+ <loc>http://tomafro.net/2009/08/the-cost-of-explicit-returns-in-ruby</loc>
+ <lastmod>2009-08-04</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/02/rails-3-column-reader-tweak</loc>
- <lastmod>2011-02-08</lastmod>
+ <loc>http://tomafro.net/2009/08/kernel-specific-zsh-dotfiles</loc>
+ <lastmod>2009-08-03</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/02/experimental-mongo-instrumentation</loc>
- <lastmod>2011-02-18</lastmod>
+ <loc>http://tomafro.net/2009/07/salvador-dali-on-whats-my-line</loc>
+ <lastmod>2009-07-10</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/02/rails-mongo-instrumentation-gem</loc>
- <lastmod>2011-02-19</lastmod>
+ <loc>http://tomafro.net/2009/07/dscl-the-easy-way-to-add-hosts-on-osx</loc>
+ <lastmod>2009-07-08</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/03/hashblue-opens-for-business</loc>
- <lastmod>2011-03-03</lastmod>
+ <loc>http://tomafro.net/2009/06/pimp-my-script-console</loc>
+ <lastmod>2009-06-22</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/08/presenting-the-hashblue-api</loc>
- <lastmod>2011-08-02</lastmod>
+ <loc>http://tomafro.net/2009/05/read-active-record-columns-directly-from-the-class</loc>
+ <lastmod>2009-05-29</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/09/tip-automatic-bundle-exec-for-rake-and-more</loc>
- <lastmod>2011-09-01</lastmod>
+ <loc>http://tomafro.net/2009/05/an-objective-c-implementation-of-active-supports-inflector</loc>
+ <lastmod>2009-05-28</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/09/a-small-toy-to-explore-geohashes</loc>
- <lastmod>2011-09-15</lastmod>
+ <loc>http://tomafro.net/2009/05/i-thought-we-were-going-to-kew-gardens</loc>
+ <lastmod>2009-05-23</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2011/09/geohash-toy-code-released</loc>
- <lastmod>2011-09-24</lastmod>
+ <loc>http://tomafro.net/2009/05/using-rack-middleware-for-good-and-evil</loc>
+ <lastmod>2009-05-22</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2012/02/working-inside-government</loc>
- <lastmod>2012-02-29</lastmod>
+ <loc>http://tomafro.net/2009/05/imitation-is-the-sincerest-form-of-flattery</loc>
+ <lastmod>2009-05-14</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net/2012/06/tip-bundler-with-binstubs</loc>
- <lastmod>2012-06-21</lastmod>
+ <loc>http://tomafro.net/2009/05/automatching-rails-paths-in-cucumber</loc>
+ <lastmod>2009-05-13</lastmod>
<changefreq>monthly</changefreq>
</url>
<url>
- <loc>http://tomafro.net</loc>
- <lastmod></lastmod>
+ <loc>http://tomafro.net/2009/05/adam-sandersons-open-gem</loc>
+ <lastmod>2009-05-06</lastmod>
<changefreq>monthly</changefreq>
</url>
</urlset>
@@ -1,3 +0,0 @@
-{{#posts}}
-{{{article}}}
-{{/posts}}
View
No changes.
View
No changes.
Oops, something went wrong.

0 comments on commit b19e66b

Please sign in to comment.