mirror of
https://github.com/wezm/wezm.net.git
synced 2024-11-10 01:42:32 +00:00
Bunch of new files to support archive listings
This commit is contained in:
parent
162a93b59b
commit
5da45019a8
14 changed files with 76 additions and 22 deletions
25
Rules
25
Rules
|
@ -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
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
title: Articles
|
||||
body_class: articles
|
|
@ -1,7 +1,7 @@
|
|||
<%
|
||||
articles = []
|
||||
sorted_articles.each do |article|
|
||||
articles << { :title => article[:title] }
|
||||
articles << article_to_json(article)
|
||||
end
|
||||
%>
|
||||
<%= articles.to_json %>
|
2
content/articles/json.yaml
Normal file
2
content/articles/json.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
title: A New Item
|
|
@ -1 +1,3 @@
|
|||
Hi, I'm a new item!
|
||||
<% sorted_articles[0..9].each do |article| %>
|
||||
<%= render 'article', :article => article %>
|
||||
<% end %>
|
||||
|
|
7
content/personal/articles/json.json
Normal file
7
content/personal/articles/json.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
<%
|
||||
articles = []
|
||||
personal_articles.each do |article|
|
||||
articles << article_to_json(article)
|
||||
end
|
||||
%>
|
||||
<%= articles.to_json %>
|
2
content/personal/articles/json.yaml
Normal file
2
content/personal/articles/json.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
title: A New Item
|
|
@ -1 +1,3 @@
|
|||
Hi, I'm a new item!
|
||||
<% sorted_articles[0..9].each do |article| %>
|
||||
<%= render 'article', :article => article %>
|
||||
<% end %>
|
||||
|
|
7
content/technical/articles/json.json
Normal file
7
content/technical/articles/json.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
<%
|
||||
articles = []
|
||||
technical_articles.each do |article|
|
||||
articles << article_to_json(article)
|
||||
end
|
||||
%>
|
||||
<%= articles.to_json %>
|
2
content/technical/articles/json.yaml
Normal file
2
content/technical/articles/json.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
title: A New Item
|
|
@ -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">« Older</a>
|
||||
<a href="#page-0" class="older">« Older</a>
|
||||
|
|
||||
<a href="/articles/#page-2" class="newer">Newer »</a>
|
||||
<a href="#page-2" class="newer">Newer »</a>
|
||||
</div>
|
||||
</div>
|
||||
<%= render 'footer' %>
|
||||
|
|
|
@ -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
22
lib/articles.rb
Normal 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
|
|
@ -4,4 +4,5 @@
|
|||
require 'json'
|
||||
|
||||
include Nanoc3::Helpers::Rendering
|
||||
include Nanoc3::Helpers::Blogging
|
||||
include Nanoc3::Helpers::Blogging
|
||||
include WezM::Helpers::Articles
|
Loading…
Reference in a new issue