diff --git a/Rules b/Rules index 5c770db..8057967 100644 --- a/Rules +++ b/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 diff --git a/content/articles.yaml b/content/articles.yaml index 36c1c5f..349c365 100644 --- a/content/articles.yaml +++ b/content/articles.yaml @@ -1,2 +1,3 @@ --- title: Articles +body_class: articles \ No newline at end of file diff --git a/content/articles.json b/content/articles/json.json similarity index 65% rename from content/articles.json rename to content/articles/json.json index ce6e07f..5f5af20 100644 --- a/content/articles.json +++ b/content/articles/json.json @@ -1,7 +1,7 @@ <% articles = [] sorted_articles.each do |article| - articles << { :title => article[:title] } + articles << article_to_json(article) end %> <%= articles.to_json %> \ No newline at end of file diff --git a/content/articles/json.yaml b/content/articles/json.yaml new file mode 100644 index 0000000..e521976 --- /dev/null +++ b/content/articles/json.yaml @@ -0,0 +1,2 @@ +--- +title: A New Item diff --git a/content/personal/articles.html b/content/personal/articles.html index b2cbfed..f214efe 100644 --- a/content/personal/articles.html +++ b/content/personal/articles.html @@ -1 +1,3 @@ -Hi, I'm a new item! +<% sorted_articles[0..9].each do |article| %> + <%= render 'article', :article => article %> +<% end %> diff --git a/content/personal/articles/json.json b/content/personal/articles/json.json new file mode 100644 index 0000000..d4267f3 --- /dev/null +++ b/content/personal/articles/json.json @@ -0,0 +1,7 @@ +<% + articles = [] + personal_articles.each do |article| + articles << article_to_json(article) + end +%> +<%= articles.to_json %> \ No newline at end of file diff --git a/content/personal/articles/json.yaml b/content/personal/articles/json.yaml new file mode 100644 index 0000000..e521976 --- /dev/null +++ b/content/personal/articles/json.yaml @@ -0,0 +1,2 @@ +--- +title: A New Item diff --git a/content/technical/articles.html b/content/technical/articles.html index b2cbfed..f214efe 100644 --- a/content/technical/articles.html +++ b/content/technical/articles.html @@ -1 +1,3 @@ -Hi, I'm a new item! +<% sorted_articles[0..9].each do |article| %> + <%= render 'article', :article => article %> +<% end %> diff --git a/content/technical/articles/json.json b/content/technical/articles/json.json new file mode 100644 index 0000000..9ba992b --- /dev/null +++ b/content/technical/articles/json.json @@ -0,0 +1,7 @@ +<% + articles = [] + technical_articles.each do |article| + articles << article_to_json(article) + end +%> +<%= articles.to_json %> \ No newline at end of file diff --git a/content/technical/articles/json.yaml b/content/technical/articles/json.yaml new file mode 100644 index 0000000..e521976 --- /dev/null +++ b/content/technical/articles/json.yaml @@ -0,0 +1,2 @@ +--- +title: A New Item diff --git a/layouts/articles.html b/layouts/articles.html index aacf95b..6b5991c 100644 --- a/layouts/articles.html +++ b/layouts/articles.html @@ -1,12 +1,7 @@ - - - <%= @item[:title] %> - - - + <%= render 'head_common' %> @@ -15,15 +10,13 @@

<%= @item[:title] %>

<%= render 'footer' %> diff --git a/layouts/default.html b/layouts/default.html index 6c4f293..d5589f2 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -8,7 +8,7 @@ - +> <%= render 'header' %>

<%= @item[:title] %>

diff --git a/lib/articles.rb b/lib/articles.rb new file mode 100644 index 0000000..cf029da --- /dev/null +++ b/lib/articles.rb @@ -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 \ No newline at end of file diff --git a/lib/default.rb b/lib/default.rb index 0d5ae7d..f252f08 100644 --- a/lib/default.rb +++ b/lib/default.rb @@ -4,4 +4,5 @@ require 'json' include Nanoc3::Helpers::Rendering -include Nanoc3::Helpers::Blogging \ No newline at end of file +include Nanoc3::Helpers::Blogging +include WezM::Helpers::Articles \ No newline at end of file