mirror of
https://github.com/wezm/wezm.net.git
synced 2024-12-19 02:39:54 +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'
|
layout 'home'
|
||||||
end
|
end
|
||||||
|
|
||||||
compile '/articles/', :rep => :json do
|
compile '/articles/json/' do
|
||||||
filter :erb
|
filter :erb
|
||||||
end
|
end
|
||||||
|
compile '/technical/articles/json/' do
|
||||||
|
filter :erb
|
||||||
|
end
|
||||||
|
compile '/personal/articles/json/' do
|
||||||
|
filter :erb
|
||||||
|
end
|
||||||
|
|
||||||
compile '/articles/' do
|
compile '/articles/' do
|
||||||
layout 'articles'
|
layout 'articles'
|
||||||
end
|
end
|
||||||
compile '/*/articles/' do
|
compile '/technical/articles/' do
|
||||||
|
layout 'articles'
|
||||||
|
end
|
||||||
|
compile '/personal/articles/' do
|
||||||
layout 'articles'
|
layout 'articles'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,11 +29,14 @@ compile '*' do
|
||||||
layout 'default'
|
layout 'default'
|
||||||
end
|
end
|
||||||
|
|
||||||
route '/articles/', :rep => :json do
|
route '/articles/json/' do
|
||||||
item.identifier + 'index.json'
|
item.identifier + 'articles.json'
|
||||||
end
|
end
|
||||||
route '/articles/' do
|
route '/technical/articles/json/' do
|
||||||
item.identifier + 'index.html'
|
item.identifier + 'articles.json'
|
||||||
|
end
|
||||||
|
route '/personal/articles/json/' do
|
||||||
|
item.identifier + 'articles.json'
|
||||||
end
|
end
|
||||||
|
|
||||||
route '*' do
|
route '*' do
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
---
|
---
|
||||||
title: Articles
|
title: Articles
|
||||||
|
body_class: articles
|
|
@ -1,7 +1,7 @@
|
||||||
<%
|
<%
|
||||||
articles = []
|
articles = []
|
||||||
sorted_articles.each do |article|
|
sorted_articles.each do |article|
|
||||||
articles << { :title => article[:title] }
|
articles << article_to_json(article)
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<%= articles.to_json %>
|
<%= 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>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<%= render 'head_common' %>
|
||||||
<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)" />
|
|
||||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script>
|
<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>
|
<script src="/js/articles.js" type="text/javascript" charset="utf-8"></script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -15,15 +10,13 @@
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<h1><%= @item[:title] %></h1>
|
<h1><%= @item[:title] %></h1>
|
||||||
<ul class="articles">
|
<ul class="articles">
|
||||||
<% sorted_articles[0..9].each do |article| %>
|
<%= yield %>
|
||||||
<%= render 'article', :article => article %>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="pagination">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<%= render 'footer' %>
|
<%= render 'footer' %>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="/css/style.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)" />
|
<link rel="stylesheet" href="/css/mobile.css" type="text/css" media="only screen and (max-device-width: 480px)" />
|
||||||
</head>
|
</head>
|
||||||
<body class="article">
|
<body<%= %Q( class="#{@item[:body_class]}") if @item[:body_class] %>>
|
||||||
<%= render 'header' %>
|
<%= render 'header' %>
|
||||||
<h1><a href="<%= @item.reps.first.path %>"><%= @item[:title] %></a></h1>
|
<h1><a href="<%= @item.reps.first.path %>"><%= @item[:title] %></a></h1>
|
||||||
<div id="content">
|
<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
|
|
@ -5,3 +5,4 @@ require 'json'
|
||||||
|
|
||||||
include Nanoc3::Helpers::Rendering
|
include Nanoc3::Helpers::Rendering
|
||||||
include Nanoc3::Helpers::Blogging
|
include Nanoc3::Helpers::Blogging
|
||||||
|
include WezM::Helpers::Articles
|
Loading…
Reference in a new issue