1
0
Fork 0
forked from wezm/wezm.net

Bunch of new files to support archive listings

This commit is contained in:
Wesley Moore 2010-01-30 16:50:07 +11:00
parent 162a93b59b
commit 5da45019a8
14 changed files with 76 additions and 22 deletions

25
Rules
View file

@ -4,13 +4,23 @@ compile '/' do
layout 'home'
end
compile '/articles/', :rep => :json do
compile '/articles/json/' do
filter :erb
end
compile '/technical/articles/json/' do
filter :erb
end
compile '/personal/articles/json/' do
filter :erb
end
compile '/articles/' do
layout 'articles'
end
compile '/*/articles/' do
compile '/technical/articles/' do
layout 'articles'
end
compile '/personal/articles/' do
layout 'articles'
end
@ -19,11 +29,14 @@ compile '*' do
layout 'default'
end
route '/articles/', :rep => :json do
item.identifier + 'index.json'
route '/articles/json/' do
item.identifier + 'articles.json'
end
route '/articles/' do
item.identifier + 'index.html'
route '/technical/articles/json/' do
item.identifier + 'articles.json'
end
route '/personal/articles/json/' do
item.identifier + 'articles.json'
end
route '*' do

View file

@ -1,2 +1,3 @@
---
title: Articles
body_class: articles

View file

@ -1,7 +1,7 @@
<%
articles = []
sorted_articles.each do |article|
articles << { :title => article[:title] }
articles << article_to_json(article)
end
%>
<%= articles.to_json %>

View file

@ -0,0 +1,2 @@
---
title: A New Item

View file

@ -1 +1,3 @@
Hi, I'm a new item!
<% sorted_articles[0..9].each do |article| %>
<%= render 'article', :article => article %>
<% end %>

View file

@ -0,0 +1,7 @@
<%
articles = []
personal_articles.each do |article|
articles << article_to_json(article)
end
%>
<%= articles.to_json %>

View file

@ -0,0 +1,2 @@
---
title: A New Item

View file

@ -1 +1,3 @@
Hi, I'm a new item!
<% sorted_articles[0..9].each do |article| %>
<%= render 'article', :article => article %>
<% end %>

View file

@ -0,0 +1,7 @@
<%
articles = []
technical_articles.each do |article|
articles << article_to_json(article)
end
%>
<%= articles.to_json %>

View file

@ -0,0 +1,2 @@
---
title: A New Item

View file

@ -1,12 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=600" />
<title><%= @item[:title] %></title>
<link rel="stylesheet" href="/css/reset.css" type="text/css" media="screen,projection" />
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen,projection" />
<link rel="stylesheet" href="/css/mobile.css" type="text/css" media="only screen and (max-device-width: 480px)" />
<%= render 'head_common' %>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script>
<script src="/js/articles.js" type="text/javascript" charset="utf-8"></script>
</head>
@ -15,15 +10,13 @@
<div id="content">
<h1><%= @item[:title] %></h1>
<ul class="articles">
<% sorted_articles[0..9].each do |article| %>
<%= render 'article', :article => article %>
<% end %>
<%= yield %>
</ul>
<div class="pagination">
<a href="/articles/#page-0" class="older">&laquo; Older</a>
<a href="#page-0" class="older">&laquo; Older</a>
|
<a href="/articles/#page-2" class="newer">Newer &raquo;</a>
<a href="#page-2" class="newer">Newer &raquo;</a>
</div>
</div>
<%= render 'footer' %>

View file

@ -8,7 +8,7 @@
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen,projection" />
<link rel="stylesheet" href="/css/mobile.css" type="text/css" media="only screen and (max-device-width: 480px)" />
</head>
<body class="article">
<body<%= %Q( class="#{@item[:body_class]}") if @item[:body_class] %>>
<%= render 'header' %>
<h1><a href="<%= @item.reps.first.path %>"><%= @item[:title] %></a></h1>
<div id="content">

22
lib/articles.rb Normal file
View file

@ -0,0 +1,22 @@
module WezM
module Helpers
module Articles
def personal_articles
sorted_articles.select { |a| a.identifier =~ %r{^/personal/} }
end
def technical_articles
sorted_articles.select { |a| a.identifier =~ %r{^/technical/} }
end
def article_to_json(article)
{
:title => article[:title],
:path => article.identifier,
}
end
end
end
end

View file

@ -4,4 +4,5 @@
require 'json'
include Nanoc3::Helpers::Rendering
include Nanoc3::Helpers::Blogging
include Nanoc3::Helpers::Blogging
include WezM::Helpers::Articles