all repos — h3rald @ 33455297d89b82345dd2e74a6e57567bbf73b20f

The sources of https://h3rald.com

Refactoring
* Tag page generation
* Utility modules
h3rald h3rald@h3rald.com
Fri, 28 Aug 2009 09:30:32 +0200
commit

33455297d89b82345dd2e74a6e57567bbf73b20f

parent

ae434fa1e27329b57f0a691710c32b42735a802d

M content/tags/ajax.textilecontent/tags/ajax.textile

@@ -9,7 +9,7 @@ -----

3 items are tagged with _ajax_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('ajax')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('ajax').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/books.textilecontent/tags/books.textile

@@ -9,7 +9,7 @@ -----

8 items are tagged with _books_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('books')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('books').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/browsers.textilecontent/tags/browsers.textile

@@ -9,7 +9,7 @@ -----

7 items are tagged with _browsers_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('browsers')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('browsers').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/cakephp.textilecontent/tags/cakephp.textile

@@ -9,7 +9,7 @@ -----

23 items are tagged with _cakephp_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('cakephp')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('cakephp').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/concatenative.textilecontent/tags/concatenative.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _concatenative_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('concatenative')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('concatenative').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/databases.textilecontent/tags/databases.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _databases_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('databases')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('databases').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/firefox.textilecontent/tags/firefox.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _firefox_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('firefox')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('firefox').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/frameworks.textilecontent/tags/frameworks.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _frameworks_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('frameworks')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('frameworks').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/google.textilecontent/tags/google.textile

@@ -9,7 +9,7 @@ -----

5 items are tagged with _google_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('google')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('google').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/ie.textilecontent/tags/ie.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _ie_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('ie')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('ie').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/internet.textilecontent/tags/internet.textile

@@ -9,7 +9,7 @@ -----

12 items are tagged with _internet_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('internet')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('internet').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/italy.textilecontent/tags/italy.textile

@@ -9,7 +9,7 @@ -----

3 items are tagged with _italy_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('italy')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('italy').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/microsoft.textilecontent/tags/microsoft.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _microsoft_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('microsoft')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('microsoft').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/opensource.textilecontent/tags/opensource.textile

@@ -9,7 +9,7 @@ -----

10 items are tagged with _opensource_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('opensource')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('opensource').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/opera.textilecontent/tags/opera.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _opera_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('opera')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('opera').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/personal.textilecontent/tags/personal.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _personal_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('personal')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('personal').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/personal_log.textilecontent/tags/personal_log.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _personal_log_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('personal_log')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('personal_log').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/php.textilecontent/tags/php.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _php_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('php')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('php').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/politics.textilecontent/tags/politics.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _politics_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('politics')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('politics').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/productivity.textilecontent/tags/productivity.textile

@@ -9,7 +9,7 @@ -----

7 items are tagged with _productivity_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('productivity')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('productivity').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/programming.textilecontent/tags/programming.textile

@@ -9,7 +9,7 @@ -----

11 items are tagged with _programming_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('programming')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('programming').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/rails.textilecontent/tags/rails.textile

@@ -9,7 +9,7 @@ -----

19 items are tagged with _rails_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('rails')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('rails').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/rant.textilecontent/tags/rant.textile

@@ -9,7 +9,7 @@ -----

4 items are tagged with _rant_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('rant')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('rant').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/rawline.textilecontent/tags/rawline.textile

@@ -9,7 +9,7 @@ -----

5 items are tagged with _rawline_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('rawline')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('rawline').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/redbook.textilecontent/tags/redbook.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _redbook_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('redbook')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('redbook').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/review.textilecontent/tags/review.textile

@@ -9,7 +9,7 @@ -----

33 items are tagged with _review_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('review')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('review').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/ruby.textilecontent/tags/ruby.textile

@@ -9,7 +9,7 @@ -----

27 items are tagged with _ruby_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('ruby')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('ruby').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/software.textilecontent/tags/software.textile

@@ -9,7 +9,7 @@ -----

4 items are tagged with _software_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('software')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('software').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/tools.textilecontent/tags/tools.textile

@@ -9,7 +9,7 @@ -----

4 items are tagged with _tools_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('tools')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('tools').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/travelling.textilecontent/tags/travelling.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _travelling_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('travelling')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('travelling').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/tutorial.textilecontent/tags/tutorial.textile

@@ -9,7 +9,7 @@ -----

4 items are tagged with _tutorial_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('tutorial')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('tutorial').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/vim.textilecontent/tags/vim.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _vim_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('vim')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('vim').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/web-development.textilecontent/tags/web-development.textile

@@ -9,7 +9,7 @@ -----

2 items are tagged with _web-development_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('web-development')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('web-development').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/web20.textilecontent/tags/web20.textile

@@ -9,7 +9,7 @@ -----

8 items are tagged with _web20_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('web20')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('web20').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/webdevelopment.textilecontent/tags/webdevelopment.textile

@@ -9,7 +9,7 @@ -----

12 items are tagged with _webdevelopment_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('webdevelopment')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('webdevelopment').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/website.textilecontent/tags/website.textile

@@ -9,7 +9,7 @@ -----

11 items are tagged with _website_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('website')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('website').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/wedding.textilecontent/tags/wedding.textile

@@ -9,7 +9,7 @@ -----

6 items are tagged with _wedding_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('wedding')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('wedding').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M content/tags/writing.textilecontent/tags/writing.textile

@@ -9,7 +9,7 @@ -----

15 items are tagged with _writing_: -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('writing')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| +<% articles_tagged_with('writing').each do |pg| %>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> <% end %>
M layouts/default.htmlayouts/default.htm

@@ -27,17 +27,6 @@ <link href="/css/layout.css" media="all" rel="stylesheet" type="text/css" />

<link href="/css/text.css" media="all" rel="stylesheet" type="text/css" /> <link href="/css/elements.css" media="all" rel="stylesheet" type="text/css" /> <link href="/css/code.css" media="all" rel="stylesheet" type="text/css" /> - <!-- - <script src="/js/jquery-1.3.2.js" type="text/javascript"></script> - <script src="/js/cufon-yui.js" type="text/javascript"></script> - <script src="/js/Mutlu_400.font.js" type="text/javascript"></script> - <script src="/js/jquery.preload.js" type="text/javascript"></script> - <script src="/js/jquery.timeago.js" type="text/javascript"></script> - <script src="/js/date.js" type="text/javascript"></script> - <script src="/js/feeds.js" type="text/javascript"></script> - <script src="/js/search.js" type="text/javascript"></script> - <script src="/js/init.js" type="text/javascript"></script> - --> </head> <body> <div id="wrapper">
M lib/helpers.rblib/helpers.rb

@@ -25,6 +25,10 @@ def sorted_site_tags

site_tags.sort{|a, b| a[1] <=> b[1]}.reverse end + def articles_tagged_with(tag) + @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?(tag)}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse + end + end module Nanoc3::Helpers::Blogging
A lib/utils.rb

@@ -0,0 +1,118 @@

+module SiteUtils + + def write_tag_page(dir, tag, count) + # Create tag page + meta = {} + meta[:title] = "Tag: #{tag}" + meta[:type] = 'page' + meta[:filters_pre] = ['erb', 'redcloth'] + meta[:permalink] = tag + pl = (count == 1) ? ' is' : 's are' + contents = %{\n#{count} item#{pl} tagged with _#{tag}_: + +<% articles_tagged_with('#{tag}').each do |pg| +%>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> +<% end %> + } + # Write html page + write_item dir/"#{tag}.textile", meta, contents + end + + def write_archive_page(dir, name, count) + # Create archive page + meta = {} + meta[:title] = "Archive: #{name}" + meta[:type] = 'page' + meta[:filters_pre] = ['erb', 'redcloth'] + meta[:permalink] = name.downcase.gsub /\s/, '-' + pl = (count == 1) ? ' was' : 's were' + contents = %{\n#{count} item#{pl} written in _#{name}_: + +<% articles_by_month.select{|i| i[0] == "#{name}"}[0][1].each do |pg| +%>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> +<% end %> + } + # Write file + write_item dir/"#{meta[:permalink]}.textile", meta, contents + end + + def write_item(path, meta, contents) + path.parent.mkpath + (path).open('w+') do |f| + f.print "--" + f.puts meta.to_yaml + f.puts "-----" + f.puts contents + end + end + +end + +module TypoUtils extend SiteUtils + + # Ignored by Nanoc 3 + def get_filter(db, fid) + filter = db[:text_filters].where("id = ?", fid).get(:name).downcase + # Multiple filters are not handled (e.g. markdown smartypants) + filter = filter.split(' ')[0] + # Prepare metadata + case filter + when 'textile' then + return ['redcloth'], 'textile' + when 'markdown' then + return ['bluecloth'], 'markdown' + when 'bbcode' then + return ['bbcode'], 'bbcode' + else + return [], 'txt' + end + end + + def get_tags(keywords=nil) + tags = [] + if keywords then + if keywords.match ',' then + tags = keywords.downcase.split(", ") + else + tags = keywords.downcase.split(" ") + end + end + tags + end + + def get_comments(db, aid) + dataset = db[:feedback].where("article_id = ? && state LIKE '%ham%'", aid) + comments = [] + dataset.each do |c| + comment = {} + comment[:id] = c[:id] + comment[:author] = c[:author] + comment[:body] = c[:body].to_s + comment[:url] = c[:url] + comment[:date] = c[:published_at] + comments << comment + end + comments + end + + def convert_code_blocks(meta, contents) + if contents.match /<typo:code/ then + # troubles if erb filter is enabled! + contents.gsub! /<%/, '&lt;%' + contents.gsub! /%>/, '%&gt;' + contents.gsub!(/<typo:code lang="([a-zA-Z0-9]+)">/, '<% highlight :\1 do %>') + contents.gsub!(/<typo:code>/, '<% highlight :text do %>') + contents.gsub!(/<\/typo:code>/, "<% end %>") + meta['filters_pre'] = ['erb'].concat meta['filters_pre'] + end + contents + end + + def write_page(meta, contents, extension) + path = (meta['type'] == 'article') ? Pathname.new(Dir.pwd)/"content/articles/" : Pathname.new(Dir.pwd)/"content/" + name = "#{meta['permalink']}.#{extension}" + write_item path/name, meta, contents + end + +end +
A resources/js/README.textile

@@ -0,0 +1,11 @@

+h1. Javascript Loading Order + +# jquery-1.3.2.js +# cufon-yui.js +# Mutlu_400.font.js +# jquery.preload.js +# jquery.timeago.js +# date.js +# feeds.js +# search.js +# init.js
M tasks/site.raketasks/site.rake

@@ -3,55 +3,7 @@ require 'extlib'

require 'pathname' require 'fileutils' require 'nanoc3' - -module SiteUtils - - def write_tag_page(dir, name, count) - # Create tag page - meta = {} - meta[:title] = "Tag: #{name}" - meta[:type] = 'page' - meta[:filters_pre] = ['erb', 'redcloth'] - meta[:permalink] = name - pl = (count == 1) ? ' is' : 's are' - contents = %{\n#{count} item#{pl} tagged with _#{name}_: - -<% @site.items.select{|p| p.attributes[:tags] && p.attributes[:tags].include?('#{name}')}.sort{|a,b| a.attributes[:date] <=> b.attributes[:date]}.reverse.each do |pg| -%>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> -<% end %> - } - # Write file - (dir/"#{name}.textile").open('w+') do |f| - f.print "--" - f.puts meta.to_yaml - f.puts "-----" - f.puts contents - end - end - - def write_archive_page(dir, name, count) - # Create archive page - meta = {} - meta[:title] = "Archive: #{name}" - meta[:type] = 'page' - meta[:filters_pre] = ['erb', 'redcloth'] - meta[:permalink] = name.downcase.gsub /\s/, '-' - pl = (count == 1) ? ' was' : 's were' - contents = %{\n#{count} item#{pl} written in _#{name}_: - -<% articles_by_month.select{|i| i[0] == "#{name}"}[0][1].each do |pg| -%>* <span class="<%= pg.attributes[:type] %>_link"> <a href="/articles/<%= pg.attributes[:permalink] %>/"><%= pg.attributes[:title] %></a></span> -<% end %> - } - # Write file - (dir/"#{meta[:permalink]}.textile").open('w+') do |f| - f.print "--" - f.puts meta.to_yaml - f.puts "-----" - f.puts contents - end - end -end +require 'lib/utils.rb' include SiteUtils

@@ -69,7 +21,7 @@ system "nanoc3 co"

end task :run => [:copy_resources] do - system "nanoc3 aco" + system "nanoc3 aco -s thin" end task :rebuild => [:clear_output, :update] do
M tasks/typo.raketasks/typo.rake

@@ -9,80 +9,7 @@ rescue Exception => e

end require 'yaml' require 'iconv' - -module TypoUtils - - # Ignored by Nanoc 3 - def get_filter(db, fid) - filter = db[:text_filters].where("id = ?", fid).get(:name).downcase - # Multiple filters are not handled (e.g. markdown smartypants) - filter = filter.split(' ')[0] - # Prepare metadata - case filter - when 'textile' then - return ['redcloth'], 'textile' - when 'markdown' then - return ['bluecloth'], 'markdown' - when 'bbcode' then - return ['bbcode'], 'bbcode' - else - return [], 'txt' - end - end - - def get_tags(keywords=nil) - tags = [] - if keywords then - if keywords.match ',' then - tags = keywords.downcase.split(", ") - else - tags = keywords.downcase.split(" ") - end - end - tags - end - - def get_comments(db, aid) - dataset = db[:feedback].where("article_id = ? && state LIKE '%ham%'", aid) - comments = [] - dataset.each do |c| - comment = {} - comment[:id] = c[:id] - comment[:author] = c[:author] - comment[:body] = c[:body].to_s - comment[:url] = c[:url] - comment[:date] = c[:published_at] - comments << comment - end - comments - end - - def convert_code_blocks(meta, contents) - if contents.match /<typo:code/ then - # troubles if erb filter is enabled! - contents.gsub! /<%/, '&lt;%' - contents.gsub! /%>/, '%&gt;' - contents.gsub!(/<typo:code lang="([a-zA-Z0-9]+)">/, '<% highlight :\1 do %>') - contents.gsub!(/<typo:code>/, '<% highlight :text do %>') - contents.gsub!(/<\/typo:code>/, "<% end %>") - meta['filters_pre'] = ['erb'].concat meta['filters_pre'] - end - contents - end - - def write_page(meta, contents, extension) - path = (meta['type'] == 'article') ? Pathname.new(Dir.pwd)/"content/articles/" : Pathname.new(Dir.pwd)/"content/" - name = "#{meta['permalink']}.#{extension}" - path.mkpath - (path/name).open('w+') do |f| - f.print "--" - f.puts meta.to_yaml - f.puts "-----" - f.puts contents - end - end - -end +require 'lib/utils.rb' include TypoUtils