From f919497c2b590402c3cbd7744097a9bd32b70afd Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 5 Sep 2009 18:08:23 +0200 Subject: added tag resource, widget and auxillary files --- app/controllers/tags_controller.rb | 16 ++++++++++++++++ app/helpers/content_helper.rb | 4 ++++ app/helpers/tags_helper.rb | 2 ++ app/views/content/_tags.html.erb | 8 ++++++++ app/views/layouts/application.html.erb | 2 +- app/views/tags/index.html.erb | 2 ++ app/views/tags/show.html.erb | 9 +++++++++ 7 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/controllers/tags_controller.rb create mode 100644 app/helpers/tags_helper.rb create mode 100644 app/views/content/_tags.html.erb create mode 100644 app/views/tags/index.html.erb create mode 100644 app/views/tags/show.html.erb (limited to 'app') diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb new file mode 100644 index 0000000..9248402 --- /dev/null +++ b/app/controllers/tags_controller.rb @@ -0,0 +1,16 @@ +class TagsController < ApplicationController + def index + end + + def show + @tag = Tag.find_by_name(params[:id]) + @page = Page.new + @pages = Page.heads.find_tagged_with( + @tag.name, :order => 'published_at DESC' + ).paginate( + :page=>params[:page], + :per_page => 23 + ) + end + +end diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 8b16462..d9ec5db 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb @@ -16,6 +16,10 @@ module ContentHelper ) end + def tags + render :partial => 'content/tags' + end + def headline_image image = @page.assets.images.first if image diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb new file mode 100644 index 0000000..23450bc --- /dev/null +++ b/app/helpers/tags_helper.rb @@ -0,0 +1,2 @@ +module TagsHelper +end diff --git a/app/views/content/_tags.html.erb b/app/views/content/_tags.html.erb new file mode 100644 index 0000000..8012796 --- /dev/null +++ b/app/views/content/_tags.html.erb @@ -0,0 +1,8 @@ +
+

Tags

+ +
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2496595..69db939 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,7 +23,7 @@ <%= yield :layout %>
- + <%= tags %>
diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb new file mode 100644 index 0000000..19cf908 --- /dev/null +++ b/app/views/tags/index.html.erb @@ -0,0 +1,2 @@ +

Tags#index

+

Find me in app/views/tags/index.html.erb

diff --git a/app/views/tags/show.html.erb b/app/views/tags/show.html.erb new file mode 100644 index 0000000..4012bbf --- /dev/null +++ b/app/views/tags/show.html.erb @@ -0,0 +1,9 @@ +<%= + render( + :partial => 'custom/partials/article', + :collection => @pages, + :as => :page + ) + %> + +<%= will_paginate @pages %> -- cgit v1.3