Commit 16fadb1e2fc80dd5d2a4b266945bfb14471f277f

Authored by AntonioTerceiro
1 parent a9e829e6

ActionItem601: making sitemap look a little better

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2349 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/folder_helper.rb
1 module FolderHelper 1 module FolderHelper
2 2
3 def list_articles(articles, recursive = false) 3 def list_articles(articles, recursive = false)
4 - articles.map {|item| display_article_in_listing(item, recursive, 0)}.join('') 4 + content_tag(
  5 + 'table',
  6 + content_tag('tr', content_tag('th', _('Title')) + content_tag('th', _('Last update'))) +
  7 + articles.map {|item| display_article_in_listing(item, recursive, 0)}.join('')
  8 + )
5 end 9 end
6 10
7 def display_article_in_listing(article, recursive = false, level = 0) 11 def display_article_in_listing(article, recursive = false, level = 0)
8 result = content_tag( 12 result = content_tag(
9 - 'div',  
10 - link_to((' ' * (level * 4) ) + image_tag(icon_for_article(article)) + article.name, article.url), 13 + 'tr',
  14 + content_tag('td', link_to((' ' * (level * 4) ) + image_tag(icon_for_article(article)) + article.name, article.url))+
  15 + content_tag('td', show_date(article.updated_at), :class => 'last-update'),
11 :class => 'sitemap-item' 16 :class => 'sitemap-item'
12 ) 17 )
13 if recursive 18 if recursive
app/models/folder.rb
@@ -18,8 +18,9 @@ class Folder < Article @@ -18,8 +18,9 @@ class Folder < Article
18 include ActionController::UrlWriter 18 include ActionController::UrlWriter
19 include ActionView::Helpers::AssetTagHelper 19 include ActionView::Helpers::AssetTagHelper
20 include FolderHelper 20 include FolderHelper
  21 + include DatesHelper
21 def to_html 22 def to_html
22 - content_tag('div', body) + tag('hr') + list_articles(children) 23 + content_tag('div', body) + tag('hr') + (children.empty? ? content_tag('em', _('(empty folder)')) : list_articles(children))
23 end 24 end
24 25
25 def folder? 26 def folder?
public/stylesheets/common.css
@@ -275,18 +275,22 @@ div.pending-tasks { @@ -275,18 +275,22 @@ div.pending-tasks {
275 } 275 }
276 276
277 /* sitemap */ 277 /* sitemap */
278 -div.sitemap-item a:link,  
279 -div.sitemap-item a:visited { 278 +.sitemap-item a:link,
  279 +.sitemap-item a:visited {
280 display: block; 280 display: block;
281 border: none; 281 border: none;
282 text-decoration: none; 282 text-decoration: none;
283 } 283 }
284 -div.sitemap-item img { 284 +.sitemap-item img {
285 border: none; 285 border: none;
286 } 286 }
287 -div.sitemap-item a:hover {  
288 - background-color: #f0f0f0; 287 +.sitemap-item a:hover {
  288 + background: #e0e0e0;
289 color: red; 289 color: red;
  290 + text-decoration: underline;
  291 +}
  292 +.last-update {
  293 + font-size: small;
290 } 294 }
291 295
292 296
test/unit/folder_test.rb
@@ -23,9 +23,16 @@ class FolderTest < ActiveSupport::TestCase @@ -23,9 +23,16 @@ class FolderTest < ActiveSupport::TestCase
23 f = Folder.create!(:profile => p, :name => 'f') 23 f = Folder.create!(:profile => p, :name => 'f')
24 f.children.create!(:profile => p, :name => 'onearticle') 24 f.children.create!(:profile => p, :name => 'onearticle')
25 f.children.create!(:profile => p, :name => 'otherarticle') 25 f.children.create!(:profile => p, :name => 'otherarticle')
  26 + f.reload
26 27
27 - assert_tag_in_string f.to_html, :tag => 'div', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/onearticle$/ } }, :content => /onearticle/  
28 - assert_tag_in_string f.to_html, :tag => 'div', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/otherarticle$/ } }, :content => /otherarticle/ 28 + assert_tag_in_string f.to_html, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/onearticle$/ } }, :content => /onearticle/
  29 + assert_tag_in_string f.to_html, :tag => 'td', :descendant => { :tag => 'a', :attributes => { :href => /.*\/testuser\/f\/otherarticle$/ } }, :content => /otherarticle/
  30 + end
  31 +
  32 + should 'explictly advise if empty' do
  33 + p = create_user('testuser').person
  34 + f = Folder.create!(:profile => p, :name => 'f')
  35 + assert_tag_in_string f.to_html, :content => '(empty folder)'
29 end 36 end
30 37
31 should 'show text body in HTML content' do 38 should 'show text body in HTML content' do