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 +++++++++ config/routes.rb | 4 ++-- public/stylesheets/ccc.css | 7 ++++--- test/functional/tags_controller_test.rb | 8 ++++++++ test/unit/helpers/tags_helper_test.rb | 4 ++++ 11 files changed, 60 insertions(+), 6 deletions(-) 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 create mode 100644 test/functional/tags_controller_test.rb create mode 100644 test/unit/helpers/tags_helper_test.rb 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 %> diff --git a/config/routes.rb b/config/routes.rb index b8c877b..c3b2e84 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ ActionController::Routing::Routes.draw do |map| - map.resources :assets map.filter :locale @@ -9,7 +8,8 @@ ActionController::Routing::Routes.draw do |map| :action => 'render_page', :page_path => ['home'] ) - + map.resources :assets + map.resources :tags map.resources :occurrences map.resources :events map.resources :revisions, :member => {:diff => :post, :restore => :put} diff --git a/public/stylesheets/ccc.css b/public/stylesheets/ccc.css index 33e726a..4307f0e 100644 --- a/public/stylesheets/ccc.css +++ b/public/stylesheets/ccc.css @@ -62,7 +62,7 @@ div#frontpage_calendar { div#frontpage_calendar h2 { border-top: 2px solid #000000; border-bottom: 2px dashed #000000; - font-size: 18px; + font-size: 16px; padding-top: 2px; padding-bottom: 2px; } @@ -119,9 +119,10 @@ div#center_column h2 a { div#right_column { position: absolute; - background-color: #f1f1f1; + background-color: #ffffff; + padding-left: 70px; left: 735px; - width: 174px; + width: 115px; height: 100px; } diff --git a/test/functional/tags_controller_test.rb b/test/functional/tags_controller_test.rb new file mode 100644 index 0000000..dcf6b7e --- /dev/null +++ b/test/functional/tags_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class TagsControllerTest < ActionController::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end diff --git a/test/unit/helpers/tags_helper_test.rb b/test/unit/helpers/tags_helper_test.rb new file mode 100644 index 0000000..4b1935f --- /dev/null +++ b/test/unit/helpers/tags_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class TagsHelperTest < ActionView::TestCase +end -- cgit v1.3