Skip to content

Commit 22cd439

Browse files
committed
start filtering changes ourselves
1 parent 873de78 commit 22cd439

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

content/changes/2012-9-5-watcher-api.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
kind: article
2+
kind: change
33
title: Upcoming Changes to Watcher and Star APIs
44
created_at: 2012-9-5
55
author_name: technoweenie

content/changes/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# API Changes
66

7-
<% sorted_articles.each do |article| %>
7+
<% api_changes.each do |article| %>
88
<div class="change" id="<%= article.path %>">
99
<%= render '_meta', :item => article %>
1010
<%= article.compiled_content %>

content/feed.atom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ author_uri: https://github.com/technoweenie
66
layout: false
77
---
88

9-
<%= atom_feed :limit => 30 %>
9+
<%= atom_feed :limit => 30, :articles => api_changes %>

lib/changes_helper.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module ChangesHelper
2+
# Public: Filters the change items out. If a version is given, show only the
3+
# items related to that version.
4+
#
5+
# version - Optional String version key.
6+
#
7+
# Returns an Array of the first 30 Nanoc::Item objects, sorted in reverse
8+
# chronological order.
9+
def api_changes(version = nil)
10+
changes = @items.select { |item| item[:kind] == 'change' }
11+
if version
12+
version_s = version.to_s
13+
changes.select { |item| item[:api_version] == version_s }
14+
else
15+
changes
16+
end.sort! do |x, y|
17+
attribute_to_time(y[:created_at]) <=> attribute_to_time(x[:created_at])
18+
end.first(30)
19+
end
20+
end

lib/default.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# All files in the 'lib' directory will be loaded
22
# before nanoc starts compiling.
3-
include Nanoc::Helpers::Rendering, Nanoc::Helpers::Blogging
3+
include Nanoc::Helpers::Rendering, Nanoc::Helpers::Blogging, ChangesHelper

0 commit comments

Comments
 (0)