From a61b1b26f877fdce7301360560c92e7c6cbaf3b7 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Tue, 18 Mar 2008 18:16:07 +0000 Subject: [PATCH] ActionItem51: --- app/controllers/public/category_controller.rb | 5 +++++ app/models/comment.rb | 16 ++++++++++++++++ app/views/category/_article.rhtml | 1 + app/views/category/_category.rhtml | 24 +++++++++++++++--------- app/views/category/view.rhtml | 4 ++-- app/views/content_viewer/_comment.rhtml | 1 + test/functional/category_controller_test.rb | 36 ++++++++++++++++++++++++++++++++++-- test/unit/comment_test.rb | 24 ++++++++++++++++++++++++ 8 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 app/views/category/_article.rhtml diff --git a/app/controllers/public/category_controller.rb b/app/controllers/public/category_controller.rb index e2d8a92..6b394d0 100644 --- a/app/controllers/public/category_controller.rb +++ b/app/controllers/public/category_controller.rb @@ -3,8 +3,13 @@ class CategoryController < PublicController # view the summary of one category def view # TODO: load articles, documents, etc so the view can list them. + @recent_articles = category.recent_articles + @recent_comments = category.recent_comments + @most_commented_articles = category.most_commented_articles end + attr_reader :category + before_filter :load_category, :only => [ :view ] def load_category path = params[:path].join('/') diff --git a/app/models/comment.rb b/app/models/comment.rb index e99f35d..d9f7d32 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -15,4 +15,20 @@ class Comment < ActiveRecord::Base end end + def author_name + if author + author.name + else + name + end + end + + def url + article.url.merge(:anchor => anchor) + end + + def anchor + "comment-#{id}" + end + end diff --git a/app/views/category/_article.rhtml b/app/views/category/_article.rhtml new file mode 100644 index 0000000..83ee999 --- /dev/null +++ b/app/views/category/_article.rhtml @@ -0,0 +1 @@ +
  • <%= _('"%s", by %s. Last update: %s.') % [link_to(article.title, article.url), link_to(article.last_changed_by.name, article.last_changed_by.url), show_date(article.updated_on) ] %>
  • diff --git a/app/views/category/_category.rhtml b/app/views/category/_category.rhtml index 76f9d00..de35a9d 100644 --- a/app/views/category/_category.rhtml +++ b/app/views/category/_category.rhtml @@ -1,10 +1,16 @@ -<%# FIXME %> -

    -This page will list everything (articles, documents, photos, etc) that is -related to <%= @category.full_name %>. Actually generating this content is not -implement yet, though. -

    +

    <%= _('Recent articles') %>

    + -

    -And yes, this placeholder text is not translated. -

    +

    <%= _('Recent Comments') %>

    + + +

    <%= _('Most commented articles') %>

    + diff --git a/app/views/category/view.rhtml b/app/views/category/view.rhtml index 8cdf450..1931932 100644 --- a/app/views/category/view.rhtml +++ b/app/views/category/view.rhtml @@ -9,11 +9,11 @@ <%= render :partial => @category.class.name.underscore %>
    +

    <%= _('Sub-categories') %>

    <% if @category.children.empty? %> - <%= _('No children categories') %> + <%= _('No sub-categories') %> <% else %> -

    <%= _('Child categories:') %>