From 16fadb1e2fc80dd5d2a4b266945bfb14471f277f Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 30 Jul 2008 20:52:53 +0000 Subject: [PATCH] ActionItem601: making sitemap look a little better --- app/helpers/folder_helper.rb | 11 ++++++++--- app/models/folder.rb | 3 ++- public/stylesheets/common.css | 14 +++++++++----- test/unit/folder_test.rb | 11 +++++++++-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/app/helpers/folder_helper.rb b/app/helpers/folder_helper.rb index 1a07926..3add4fb 100644 --- a/app/helpers/folder_helper.rb +++ b/app/helpers/folder_helper.rb @@ -1,13 +1,18 @@ module FolderHelper def list_articles(articles, recursive = false) - articles.map {|item| display_article_in_listing(item, recursive, 0)}.join('') + content_tag( + 'table', + content_tag('tr', content_tag('th', _('Title')) + content_tag('th', _('Last update'))) + + articles.map {|item| display_article_in_listing(item, recursive, 0)}.join('') + ) end def display_article_in_listing(article, recursive = false, level = 0) result = content_tag( - 'div', - link_to((' ' * (level * 4) ) + image_tag(icon_for_article(article)) + article.name, article.url), + 'tr', + content_tag('td', link_to((' ' * (level * 4) ) + image_tag(icon_for_article(article)) + article.name, article.url))+ + content_tag('td', show_date(article.updated_at), :class => 'last-update'), :class => 'sitemap-item' ) if recursive diff --git a/app/models/folder.rb b/app/models/folder.rb index 7b54449..4be6136 100644 --- a/app/models/folder.rb +++ b/app/models/folder.rb @@ -18,8 +18,9 @@ class Folder < Article include ActionController::UrlWriter include ActionView::Helpers::AssetTagHelper include FolderHelper + include DatesHelper def to_html - content_tag('div', body) + tag('hr') + list_articles(children) + content_tag('div', body) + tag('hr') + (children.empty? ? content_tag('em', _('(empty folder)')) : list_articles(children)) end def folder? diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index e35bb25..a0f8200 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -275,18 +275,22 @@ div.pending-tasks { } /* sitemap */ -div.sitemap-item a:link, -div.sitemap-item a:visited { +.sitemap-item a:link, +.sitemap-item a:visited { display: block; border: none; text-decoration: none; } -div.sitemap-item img { +.sitemap-item img { border: none; } -div.sitemap-item a:hover { - background-color: #f0f0f0; +.sitemap-item a:hover { + background: #e0e0e0; color: red; + text-decoration: underline; +} +.last-update { + font-size: small; } diff --git a/test/unit/folder_test.rb b/test/unit/folder_test.rb index 92d377a..085fe0b 100644 --- a/test/unit/folder_test.rb +++ b/test/unit/folder_test.rb @@ -23,9 +23,16 @@ class FolderTest < ActiveSupport::TestCase f = Folder.create!(:profile => p, :name => 'f') f.children.create!(:profile => p, :name => 'onearticle') f.children.create!(:profile => p, :name => 'otherarticle') + f.reload - assert_tag_in_string f.to_html, :tag => 'div', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/onearticle$/ } }, :content => /onearticle/ - assert_tag_in_string f.to_html, :tag => 'div', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/otherarticle$/ } }, :content => /otherarticle/ + assert_tag_in_string f.to_html, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/onearticle$/ } }, :content => /onearticle/ + assert_tag_in_string f.to_html, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/otherarticle$/ } }, :content => /otherarticle/ + end + + should 'explictly advise if empty' do + p = create_user('testuser').person + f = Folder.create!(:profile => p, :name => 'f') + assert_tag_in_string f.to_html, :content => '(empty folder)' end should 'show text body in HTML content' do -- libgit2 0.21.2