Commit d6077c5689740068d5de91cd3a351786f3ce99aa

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent 604ed17a

A lightbox is displayed with all available articles

  * Added rss-feed-16.png (a 16x16 image of rss feed)
  * icon_name now is a class method
  * removing image_tags with article's icons
  * added icon_for_article on class to display icons

(ActionItem1770)
app/controllers/my_profile/cms_controller.rb
@@ -44,6 +44,7 @@ class CmsController < MyProfileController @@ -44,6 +44,7 @@ class CmsController < MyProfileController
44 TextileArticle, 44 TextileArticle,
45 Event 45 Event
46 ] 46 ]
  47 + articles += special_article_types if params && params[:cms]
47 parent_id = params ? params[:parent_id] : nil 48 parent_id = params ? params[:parent_id] : nil
48 if !parent_id or !Article.find(parent_id).has_posts? 49 if !parent_id or !Article.find(parent_id).has_posts?
49 articles += [ 50 articles += [
app/helpers/assets_helper.rb
@@ -9,7 +9,7 @@ module AssetsHelper @@ -9,7 +9,7 @@ module AssetsHelper
9 [ options.merge(:asset => 'products'), "icon-menu-product", _('Products') ], 9 [ options.merge(:asset => 'products'), "icon-menu-product", _('Products') ],
10 [ options.merge(:asset => 'enterprises'), "icon-menu-enterprise", __('Enterprises') ], 10 [ options.merge(:asset => 'enterprises'), "icon-menu-enterprise", __('Enterprises') ],
11 [ options.merge(:asset => 'communities'), "icon-menu-community", __('Communities') ], 11 [ options.merge(:asset => 'communities'), "icon-menu-community", __('Communities') ],
12 - [ options.merge(:asset => 'events'), "icon-menu-events", __('Events') ], 12 + [ options.merge(:asset => 'events'), "icon-event", __('Events') ],
13 13
14 ].select do |target, css_class, name| 14 ].select do |target, css_class, name|
15 !environment.enabled?('disable_asset_' + target[:asset]) 15 !environment.enabled?('disable_asset_' + target[:asset])
app/helpers/cms_helper.rb
@@ -30,9 +30,13 @@ module CmsHelper @@ -30,9 +30,13 @@ module CmsHelper
30 def link_to_article(article) 30 def link_to_article(article)
31 article_name = short_filename(article.name, 30) 31 article_name = short_filename(article.name, 30)
32 if article.folder? 32 if article.folder?
33 - link_to article_name, :action => 'view', :id => article.id 33 + link_to article_name, {:action => 'view', :id => article.id}, :class => icon_for_article(article)
34 else 34 else
35 - link_to article_name, article.url 35 + if article.image?
  36 + image_tag(icon_for_article(article)) + link_to(article_name, article.url)
  37 + else
  38 + link_to article_name, article.url, :class => icon_for_article(article)
  39 + end
36 end 40 end
37 end 41 end
38 42
app/helpers/events_helper.rb
@@ -15,7 +15,7 @@ module EventsHelper @@ -15,7 +15,7 @@ module EventsHelper
15 def display_event_in_listing(article) 15 def display_event_in_listing(article)
16 content_tag( 16 content_tag(
17 'tr', 17 'tr',
18 - content_tag('td', link_to(image_tag(icon_for_article(article)) + article.name, article.url)), 18 + content_tag('td', link_to(article.name, article.url, :class => icon_for_article(article))),
19 :class => 'agenda-item' 19 :class => 'agenda-item'
20 ) 20 )
21 end 21 end
app/helpers/folder_helper.rb
@@ -21,9 +21,14 @@ module FolderHelper @@ -21,9 +21,14 @@ module FolderHelper
21 end 21 end
22 22
23 def display_article_in_listing(article, recursive = false, level = 0) 23 def display_article_in_listing(article, recursive = false, level = 0)
  24 + article_link = if article.image?
  25 + link_to(' ' * (level * 4) + image_tag(icon_for_article(article)) + short_filename(article.name), article.url.merge(:view => true))
  26 + else
  27 + link_to(' ' * (level * 4) + short_filename(article.name), article.url.merge(:view => true), :class => icon_for_article(article))
  28 + end
24 result = content_tag( 29 result = content_tag(
25 'tr', 30 'tr',
26 - content_tag('td', link_to((' ' * (level * 4) ) + image_tag(icon_for_article(article)) + short_filename(article.name), article.url.merge(:view => true)))+ 31 + content_tag('td', article_link )+
27 content_tag('td', show_date(article.updated_at), :class => 'last-update'), 32 content_tag('td', show_date(article.updated_at), :class => 'last-update'),
28 :class => 'sitemap-item' 33 :class => 'sitemap-item'
29 ) 34 )
@@ -35,18 +40,18 @@ module FolderHelper @@ -35,18 +40,18 @@ module FolderHelper
35 end 40 end
36 41
37 def icon_for_article(article) 42 def icon_for_article(article)
38 - icon = article.icon_name 43 + icon = article.class.icon_name(article)
39 if (icon =~ /\//) 44 if (icon =~ /\//)
40 icon 45 icon
41 else 46 else
42 - if File.exists?(File.join(RAILS_ROOT, 'public', 'images', 'icons-mime', "#{icon}.png"))  
43 - "icons-mime/#{icon}.png"  
44 - else  
45 - "icons-mime/unknown.png"  
46 - end 47 + 'icon icon-' + icon
47 end 48 end
48 end 49 end
49 50
  51 + def icon_for_new_article(type)
  52 + "icon-new icon-new%s" % type.constantize.icon_name
  53 + end
  54 +
50 def custom_options_for_article(article) 55 def custom_options_for_article(article)
51 @article = article 56 @article = article
52 content_tag('h4', _('Options')) + 57 content_tag('h4', _('Options')) +
app/models/article.rb
@@ -198,7 +198,7 @@ class Article < ActiveRecord::Base @@ -198,7 +198,7 @@ class Article < ActiveRecord::Base
198 # to return their specific icons. 198 # to return their specific icons.
199 # 199 #
200 # FIXME use mime_type and generate this name dinamically 200 # FIXME use mime_type and generate this name dinamically
201 - def icon_name 201 + def self.icon_name(article = nil)
202 'text-html' 202 'text-html'
203 end 203 end
204 204
app/models/blog.rb
@@ -54,6 +54,10 @@ class Blog < Folder @@ -54,6 +54,10 @@ class Blog < Folder
54 end 54 end
55 end 55 end
56 56
  57 + def self.icon_name(article = nil)
  58 + 'blog'
  59 + end
  60 +
57 settings_items :visualization_format, :type => :string, :default => 'full' 61 settings_items :visualization_format, :type => :string, :default => 'full'
58 validates_inclusion_of :visualization_format, :in => [ 'full', 'short' ], :if => :visualization_format 62 validates_inclusion_of :visualization_format, :in => [ 'full', 'short' ], :if => :visualization_format
59 63
app/models/event.rb
@@ -37,7 +37,7 @@ class Event < Article @@ -37,7 +37,7 @@ class Event < Article
37 _('Event') 37 _('Event')
38 end 38 end
39 39
40 - def icon_name 40 + def self.icon_name(article = nil)
41 'event' 41 'event'
42 end 42 end
43 43
app/models/folder.rb
@@ -15,7 +15,7 @@ class Folder < Article @@ -15,7 +15,7 @@ class Folder < Article
15 _('A folder, inside which you can put other articles.') 15 _('A folder, inside which you can put other articles.')
16 end 16 end
17 17
18 - def icon_name 18 + def self.icon_name(article = nil)
19 'folder' 19 'folder'
20 end 20 end
21 21
app/models/forum.rb
@@ -21,4 +21,7 @@ class Forum < Folder @@ -21,4 +21,7 @@ class Forum < Folder
21 true 21 true
22 end 22 end
23 23
  24 + def self.icon_name(article = nil)
  25 + 'forum'
  26 + end
24 end 27 end
app/models/gallery.rb
@@ -20,4 +20,8 @@ class Gallery < Folder @@ -20,4 +20,8 @@ class Gallery < Folder
20 true 20 true
21 end 21 end
22 22
  23 + def self.icon_name(article = nil)
  24 + 'gallery'
  25 + end
  26 +
23 end 27 end
app/models/link_list_block.rb
@@ -25,7 +25,7 @@ class LinkListBlock < Block @@ -25,7 +25,7 @@ class LinkListBlock < Block
25 ['eyes', N_('Eyes')], 25 ['eyes', N_('Eyes')],
26 ['photos', N_('Photos')], 26 ['photos', N_('Photos')],
27 ['menu-people', N_('Person')], 27 ['menu-people', N_('Person')],
28 - ['menu-events', N_('Event')] 28 + ['event', N_('Event')]
29 ] 29 ]
30 30
31 settings_items :links, Array, :default => [] 31 settings_items :links, Array, :default => []
app/models/organization.rb
@@ -102,7 +102,7 @@ class Organization < Profile @@ -102,7 +102,7 @@ class Organization < Profile
102 links = [ 102 links = [
103 {:name => _("Community's profile"), :address => '/profile/{profile}', :icon => 'ok'}, 103 {:name => _("Community's profile"), :address => '/profile/{profile}', :icon => 'ok'},
104 {:name => _('Invite Friends'), :address => '/profile/{profile}/invite/friends', :icon => 'send'}, 104 {:name => _('Invite Friends'), :address => '/profile/{profile}/invite/friends', :icon => 'send'},
105 - {:name => _('Agenda'), :address => '/profile/{profile}/events', :icon => 'menu-events'}, 105 + {:name => _('Agenda'), :address => '/profile/{profile}/events', :icon => 'event'},
106 {:name => _('Image gallery'), :address => '/{profile}/gallery', :icon => 'photos'}, 106 {:name => _('Image gallery'), :address => '/{profile}/gallery', :icon => 'photos'},
107 {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'}, 107 {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'},
108 ] 108 ]
app/models/person.rb
@@ -210,7 +210,7 @@ class Person < Profile @@ -210,7 +210,7 @@ class Person < Profile
210 links = [ 210 links = [
211 {:name => _('Profile'), :address => '/profile/{profile}', :icon => 'menu-people'}, 211 {:name => _('Profile'), :address => '/profile/{profile}', :icon => 'menu-people'},
212 {:name => _('Image gallery'), :address => '/{profile}/gallery', :icon => 'photos'}, 212 {:name => _('Image gallery'), :address => '/{profile}/gallery', :icon => 'photos'},
213 - {:name => _('Agenda'), :address => '/profile/{profile}/events', :icon => 'menu-events'}, 213 + {:name => _('Agenda'), :address => '/profile/{profile}/events', :icon => 'event'},
214 {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'}, 214 {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'},
215 ] 215 ]
216 [ 216 [
app/models/rss_feed.rb
@@ -91,7 +91,7 @@ class RssFeed < Article @@ -91,7 +91,7 @@ class RssFeed < Article
91 _('Provides a news feed of your more recent articles.') 91 _('Provides a news feed of your more recent articles.')
92 end 92 end
93 93
94 - def icon_name 94 + def self.icon_name(article = nil)
95 'rss-feed' 95 'rss-feed'
96 end 96 end
97 97
app/models/uploaded_file.rb
@@ -46,8 +46,12 @@ class UploadedFile < Article @@ -46,8 +46,12 @@ class UploadedFile < Article
46 46
47 delay_attachment_fu_thumbnails 47 delay_attachment_fu_thumbnails
48 48
49 - def icon_name  
50 - self.image? ? public_filename(:icon) : self.content_type.gsub('/', '-') 49 + def self.icon_name(article = nil)
  50 + if article && article.image?
  51 + article.public_filename(:icon)
  52 + else
  53 + 'upload-file'
  54 + end
51 end 55 end
52 56
53 def mime_type 57 def mime_type
app/views/cms/_document_link.rhtml
1 <div id='media-listing-folder-documents' > 1 <div id='media-listing-folder-documents' >
2 <ul> 2 <ul>
3 <% documents.each do |document| %> 3 <% documents.each do |document| %>
4 - <li><%= link_to(image_tag(icon_for_article(document)) + document.name, document.view_url) %></li> 4 + <li><%= link_to(document.name, document.view_url, :class => icon_for_article(document)) %></li>
5 <% end %> 5 <% end %>
6 </ul> 6 </ul>
7 <div id='pagination-documents'> 7 <div id='pagination-documents'>
app/views/cms/select_article_type.rhtml
1 -<h2> <%= _('Choose the type of article:') %> </h2> 1 +<h2> <%= _('Choose the type of content:') %> </h2>
2 2
3 <ul id="article_types"> 3 <ul id="article_types">
4 <% for type in @article_types %> 4 <% for type in @article_types %>
5 - <li>  
6 - <%= link_to type[:short_description], :action => 'new', :type => type[:name], :parent_id => @parent_id, :back_to => @back_to %>  
7 - <br/> <%= type[:description] %>  
8 - </li> 5 + <% action = type[:name] == 'UploadedFile' ? {:action => 'upload_files'} : {:action => 'new', :type => type[:name]} %>
  6 + <% content_tag('a', :href => url_for(action.merge(:parent_id => @parent_id, :back_to => @back_to))) do %>
  7 + <li class="<%= icon_for_new_article(type[:name]) %>" onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')">
  8 + <strong><%= type[:short_description] %></strong>
  9 + <div class='description'><%= type[:description] %></div>
  10 + </li>
  11 + <% end %>
9 <% end %> 12 <% end %>
10 </ul> 13 </ul>
  14 +<br style="clear:both" />
11 15
12 <%= lightbox_close_button(_('Cancel')) %> 16 <%= lightbox_close_button(_('Cancel')) %>
app/views/cms/view.rhtml
@@ -5,14 +5,7 @@ @@ -5,14 +5,7 @@
5 <% button_bar(:style => 'margin-bottom: 1em;') do %> 5 <% button_bar(:style => 'margin-bottom: 1em;') do %>
6 <% parent_id = ((@article && @article.allow_children?) ? @article : nil) %> 6 <% parent_id = ((@article && @article.allow_children?) ? @article : nil) %>
7 7
8 - <% if !@article or !@article.has_posts? %>  
9 - <%= button :newfolder, _('New folder'), :action => 'new', :type => 'Folder', :parent_id => parent_id %>  
10 - <%= button :newblog, _('New Blog'), :action => 'new', :type => 'Blog', :parent_id => parent_id %>  
11 - <%= button :newforum, _('New Forum'), :action => 'new', :type => 'Forum', :parent_id => parent_id %>  
12 - <%= button :newgallery, _('New Gallery'), :action => 'new', :type => 'Gallery', :parent_id => parent_id %>  
13 - <%= button('upload-file', _('Upload files'), :action => 'upload_files', :parent_id => parent_id) %>  
14 - <% end %>  
15 - <%= lightbox_button('new', label_for_new_article(@article), :action => 'new', :parent_id => parent_id) %> 8 + <%= lightbox_button('new', _('New content'), :action => 'new', :parent_id => parent_id, :cms => true) %>
16 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor', :action => "index") %> 9 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor', :action => "index") %>
17 <% end %> 10 <% end %>
18 11
@@ -36,11 +29,10 @@ @@ -36,11 +29,10 @@
36 <% if @article %> 29 <% if @article %>
37 <tr> 30 <tr>
38 <td> 31 <td>
39 - <%= image_tag 'icons-mime/gnome-folder.png' %>  
40 <% if @article.parent %> 32 <% if @article.parent %>
41 - <%= link_to '.. (' + _('parent folder') + ')', :action => 'view', :id => @article.parent.id %> 33 + <%= link_to '.. (' + _('parent folder') + ')', {:action => 'view', :id => @article.parent.id}, :class => 'icon-parent-folder' %>
42 <% else %> 34 <% else %>
43 - <%= link_to '.. (' + _('parent folder') + ')', :action => 'index' %> 35 + <%= link_to '.. (' + _('parent folder') + ')', {:action => 'index'}, :class => 'icon-parent-folder' %>
44 <% end %> 36 <% end %>
45 </td> 37 </td>
46 <td><%= Folder.short_description %></td> 38 <td><%= Folder.short_description %></td>
@@ -51,7 +43,6 @@ @@ -51,7 +43,6 @@
51 <% @articles.each do |article| %> 43 <% @articles.each do |article| %>
52 <tr> 44 <tr>
53 <td> 45 <td>
54 - <%= image_tag(icon_for_article(article)) %>  
55 <%= link_to_article(article) %> 46 <%= link_to_article(article) %>
56 </td> 47 </td>
57 <td> 48 <td>
app/views/search/_article.rhtml
1 <li> 1 <li>
2 - <%= image_tag 'icons-mime/text-html.png', :style => 'float: left' %>  
3 - <strong><%= link_to(article.title, article.url) %></strong> 2 + <strong><%= link_to(article.title, article.url, :class => icon_for_article(article)) %></strong>
4 <div class="item_meta"> 3 <div class="item_meta">
5 <% if article.last_changed_by %> 4 <% if article.last_changed_by %>
6 <span class="cat_item_by"> 5 <span class="cat_item_by">
app/views/search/_event.rhtml
1 <li> 1 <li>
2 - <%= image_tag 'icons-mime/event.png', :style => 'float: left' %>  
3 - <strong><%= link_to(event.title, event.url) %></strong> 2 + <strong><%= link_to(event.title, event.url, :class => icon_for_article(event)) %></strong>
4 <div class="item_meta"> 3 <div class="item_meta">
5 <%= show_period(event.start_date, event.end_date) %> 4 <%= show_period(event.start_date, event.end_date) %>
6 </div> 5 </div>
features/blog.feature
@@ -30,7 +30,8 @@ Feature: blog @@ -30,7 +30,8 @@ Feature: blog
30 Scenario: redirect to blog after create blog from cms 30 Scenario: redirect to blog after create blog from cms
31 Given I go to the Control panel 31 Given I go to the Control panel
32 And I follow "Manage Content" 32 And I follow "Manage Content"
33 - When I follow "New Blog" 33 + And I follow "New content"
  34 + When I follow "Blog"
34 And I fill in "Title" with "Blog from cms" 35 And I fill in "Title" with "Blog from cms"
35 And I press "Save" 36 And I press "Save"
36 Then I should be on /joaosilva/blog-from-cms 37 Then I should be on /joaosilva/blog-from-cms
@@ -38,12 +39,14 @@ Feature: blog @@ -38,12 +39,14 @@ Feature: blog
38 Scenario: create multiple blogs 39 Scenario: create multiple blogs
39 Given I go to the Control panel 40 Given I go to the Control panel
40 And I follow "Manage Content" 41 And I follow "Manage Content"
41 - And I follow "New Blog" 42 + And I follow "New content"
  43 + And I follow "Blog"
42 And I fill in "Title" with "Blog One" 44 And I fill in "Title" with "Blog One"
43 And I press "Save" 45 And I press "Save"
44 Then I go to the Control panel 46 Then I go to the Control panel
45 And I follow "Manage Content" 47 And I follow "Manage Content"
46 - And I follow "New Blog" 48 + And I follow "New content"
  49 + And I follow "Blog"
47 And I fill in "Title" with "Blog Two" 50 And I fill in "Title" with "Blog Two"
48 And I press "Save" 51 And I press "Save"
49 Then I should not see "error" 52 Then I should not see "error"
@@ -52,7 +55,8 @@ Feature: blog @@ -52,7 +55,8 @@ Feature: blog
52 Scenario: cancel button back to cms 55 Scenario: cancel button back to cms
53 Given I go to the Control panel 56 Given I go to the Control panel
54 And I follow "Manage Content" 57 And I follow "Manage Content"
55 - And I follow "New Blog" 58 + And I follow "New content"
  59 + And I follow "Blog"
56 When I follow "Cancel" within ".main-block" 60 When I follow "Cancel" within ".main-block"
57 Then I should be on /myprofile/joaosilva/cms 61 Then I should be on /myprofile/joaosilva/cms
58 62
@@ -101,5 +105,6 @@ Feature: blog @@ -101,5 +105,6 @@ Feature: blog
101 Scenario: display tag list field when creating new blog 105 Scenario: display tag list field when creating new blog
102 Given I go to the Control panel 106 Given I go to the Control panel
103 And I follow "Manage Content" 107 And I follow "Manage Content"
104 - When I follow "New blog" 108 + And I follow "New content"
  109 + When I follow "Blog"
105 Then I should see "Tag list" 110 Then I should see "Tag list"
features/edit_article.feature
@@ -15,7 +15,8 @@ Feature: edit article @@ -15,7 +15,8 @@ Feature: edit article
15 Scenario: create a folder 15 Scenario: create a folder
16 Given I am on Joao Silva's control panel 16 Given I am on Joao Silva's control panel
17 And I follow "Manage Content" 17 And I follow "Manage Content"
18 - When I follow "New Folder" 18 + And I follow "New content"
  19 + When I follow "Folder"
19 And I fill in "Title" with "My Folder" 20 And I fill in "Title" with "My Folder"
20 And I press "Save" 21 And I press "Save"
21 And I go to Joao Silva's control panel 22 And I go to Joao Silva's control panel
@@ -24,7 +25,8 @@ Feature: edit article @@ -24,7 +25,8 @@ Feature: edit article
24 Scenario: redirect to the created folder 25 Scenario: redirect to the created folder
25 Given I am on Joao Silva's control panel 26 Given I am on Joao Silva's control panel
26 And I follow "Manage Content" 27 And I follow "Manage Content"
27 - When I follow "New Folder" 28 + And I follow "New content"
  29 + When I follow "Folder"
28 And I fill in "Title" with "My Folder" 30 And I fill in "Title" with "My Folder"
29 And I press "Save" 31 And I press "Save"
30 Then I should see "My Folder" 32 Then I should see "My Folder"
@@ -33,27 +35,29 @@ Feature: edit article @@ -33,27 +35,29 @@ Feature: edit article
33 Scenario: cancel button back to cms 35 Scenario: cancel button back to cms
34 Given I go to the Control panel 36 Given I go to the Control panel
35 And I follow "Manage Content" 37 And I follow "Manage Content"
36 - And I follow "New Folder" 38 + And I follow "New content"
  39 + And I follow "Folder"
37 When I follow "Cancel" within ".main-block" 40 When I follow "Cancel" within ".main-block"
38 Then I should be on Joao Silva's cms 41 Then I should be on Joao Silva's cms
39 42
40 Scenario: display tag list field when creating event 43 Scenario: display tag list field when creating event
41 Given I go to the Control panel 44 Given I go to the Control panel
42 And I follow "Manage Content" 45 And I follow "Manage Content"
43 - And I follow "New article" 46 + And I follow "New content"
44 When I follow "Event" 47 When I follow "Event"
45 Then I should see "Tag list" 48 Then I should see "Tag list"
46 49
47 Scenario: display tag list field when creating folder 50 Scenario: display tag list field when creating folder
48 Given I go to the Control panel 51 Given I go to the Control panel
49 And I follow "Manage Content" 52 And I follow "Manage Content"
50 - When I follow "New folder" 53 + And I follow "New content"
  54 + When I follow "Folder"
51 Then I should see "Tag list" 55 Then I should see "Tag list"
52 56
53 Scenario: create new article with tags 57 Scenario: create new article with tags
54 Given I go to the Control panel 58 Given I go to the Control panel
55 And I follow "Manage Content" 59 And I follow "Manage Content"
56 - And I follow "New article" 60 + And I follow "New content"
57 When I follow "Text article with Textile markup language" 61 When I follow "Text article with Textile markup language"
58 Then I should see "Tag list" 62 Then I should see "Tag list"
59 When I fill in "Title" with "Article with tags" 63 When I fill in "Title" with "Article with tags"
@@ -66,7 +70,7 @@ Feature: edit article @@ -66,7 +70,7 @@ Feature: edit article
66 Scenario: redirect to the created article 70 Scenario: redirect to the created article
67 Given I am on Joao Silva's control panel 71 Given I am on Joao Silva's control panel
68 And I follow "Manage Content" 72 And I follow "Manage Content"
69 - When I follow "New article" 73 + When I follow "New content"
70 When I follow "Text article with visual editor" 74 When I follow "Text article with visual editor"
71 And I fill in "Title" with "My Article" 75 And I fill in "Title" with "My Article"
72 And I press "Save" 76 And I press "Save"
@@ -91,7 +95,8 @@ Feature: edit article @@ -91,7 +95,8 @@ Feature: edit article
91 Scenario: create an article inside a folder 95 Scenario: create an article inside a folder
92 Given I am on Joao Silva's control panel 96 Given I am on Joao Silva's control panel
93 And I follow "Manage Content" 97 And I follow "Manage Content"
94 - And I follow "New Folder" 98 + And I follow "New content"
  99 + And I follow "Folder"
95 And I fill in "Title" with "My Folder" 100 And I fill in "Title" with "My Folder"
96 And I press "Save" 101 And I press "Save"
97 Then I should be on /joaosilva/my-folder 102 Then I should be on /joaosilva/my-folder
@@ -105,7 +110,8 @@ Feature: edit article @@ -105,7 +110,8 @@ Feature: edit article
105 Scenario: cancel button back to folder after giving up creating 110 Scenario: cancel button back to folder after giving up creating
106 Given I am on Joao Silva's control panel 111 Given I am on Joao Silva's control panel
107 And I follow "Manage Content" 112 And I follow "Manage Content"
108 - And I follow "New Folder" 113 + And I follow "New content"
  114 + And I follow "Folder"
109 And I fill in "Title" with "My Folder" 115 And I fill in "Title" with "My Folder"
110 And I press "Save" 116 And I press "Save"
111 Then I should be on /joaosilva/my-folder 117 Then I should be on /joaosilva/my-folder
@@ -125,7 +131,7 @@ Feature: edit article @@ -125,7 +131,7 @@ Feature: edit article
125 Scenario: save and continue when creating a new article 131 Scenario: save and continue when creating a new article
126 Given I am on Joao Silva's control panel 132 Given I am on Joao Silva's control panel
127 When I follow "Manage Content" 133 When I follow "Manage Content"
128 - And I follow "New article" 134 + And I follow "New content"
129 And I follow "Text article with visual editor" 135 And I follow "Text article with visual editor"
130 And I fill in "Title" with "My new article" 136 And I fill in "Title" with "My new article"
131 And I fill in "Text" with "text for the new article" 137 And I fill in "Text" with "text for the new article"
features/forum.feature
@@ -13,7 +13,8 @@ Feature: forum @@ -13,7 +13,8 @@ Feature: forum
13 Scenario: create a forum 13 Scenario: create a forum
14 Given I go to the Control panel 14 Given I go to the Control panel
15 And I follow "Manage Content" 15 And I follow "Manage Content"
16 - When I follow "New Forum" 16 + And I follow "New content"
  17 + When I follow "Forum"
17 And I fill in "Title" with "My Forum" 18 And I fill in "Title" with "My Forum"
18 And I press "Save" 19 And I press "Save"
19 Then I should see "Configure forum" 20 Then I should see "Configure forum"
@@ -21,7 +22,8 @@ Feature: forum @@ -21,7 +22,8 @@ Feature: forum
21 Scenario: redirect to forum after create forum from cms 22 Scenario: redirect to forum after create forum from cms
22 Given I go to the Control panel 23 Given I go to the Control panel
23 And I follow "Manage Content" 24 And I follow "Manage Content"
24 - When I follow "New Forum" 25 + And I follow "New content"
  26 + When I follow "Forum"
25 And I fill in "Title" with "Forum from cms" 27 And I fill in "Title" with "Forum from cms"
26 And I press "Save" 28 And I press "Save"
27 Then I should be on /joaosilva/forum-from-cms 29 Then I should be on /joaosilva/forum-from-cms
@@ -29,12 +31,14 @@ Feature: forum @@ -29,12 +31,14 @@ Feature: forum
29 Scenario: create multiple forums 31 Scenario: create multiple forums
30 Given I go to the Control panel 32 Given I go to the Control panel
31 And I follow "Manage Content" 33 And I follow "Manage Content"
32 - And I follow "New Forum" 34 + And I follow "New content"
  35 + And I follow "Forum"
33 And I fill in "Title" with "Forum One" 36 And I fill in "Title" with "Forum One"
34 And I press "Save" 37 And I press "Save"
35 Then I go to the Control panel 38 Then I go to the Control panel
36 And I follow "Manage Content" 39 And I follow "Manage Content"
37 - And I follow "New Forum" 40 + And I follow "New content"
  41 + And I follow "Forum"
38 And I fill in "Title" with "Forum Two" 42 And I fill in "Title" with "Forum Two"
39 And I press "Save" 43 And I press "Save"
40 Then I should not see "error" 44 Then I should not see "error"
@@ -43,14 +47,16 @@ Feature: forum @@ -43,14 +47,16 @@ Feature: forum
43 Scenario: cancel button back to cms 47 Scenario: cancel button back to cms
44 Given I go to the Control panel 48 Given I go to the Control panel
45 And I follow "Manage Content" 49 And I follow "Manage Content"
46 - And I follow "New Forum" 50 + And I follow "New content"
  51 + And I follow "Forum"
47 When I follow "Cancel" within ".main-block" 52 When I follow "Cancel" within ".main-block"
48 Then I should be on /myprofile/joaosilva/cms 53 Then I should be on /myprofile/joaosilva/cms
49 54
50 Scenario: cancel button back to myprofile 55 Scenario: cancel button back to myprofile
51 Given I go to the Control panel 56 Given I go to the Control panel
52 And I follow "Manage Content" 57 And I follow "Manage Content"
53 - And I follow "New Forum" 58 + And I follow "New content"
  59 + And I follow "Forum"
54 When I follow "Cancel" within ".main-block" 60 When I follow "Cancel" within ".main-block"
55 Then I should be on /myprofile/joaosilva/cms 61 Then I should be on /myprofile/joaosilva/cms
56 62
features/new_content_on_cms.feature 0 → 100644
@@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
  1 +Feature: create content on cms
  2 + As a noosfero user
  3 + I want to create articles and upload files
  4 +
  5 + Background:
  6 + Given the following users
  7 + | login | name |
  8 + | joaosilva | Joao Silva |
  9 + And I am logged in as "joaosilva"
  10 + And I am on Joao Silva's cms
  11 +
  12 + Scenario: open page to select type of content
  13 + Given I follow "New Content"
  14 + Then I should see "Choose the type of content"
  15 +
  16 + Scenario: list all content types
  17 + Given I follow "New content"
  18 + Then I should see "Text article with visual editor"
  19 + And I should see "Text article with Textile markup"
  20 + And I should see "Folder"
  21 + And I should see "Blog"
  22 + And I should see "Uploaded file"
  23 + And I should see "Event"
  24 +
  25 + Scenario: create a folder
  26 + Given I follow "New content"
  27 + When I follow "Folder"
  28 + And I fill in "Title" with "My Folder"
  29 + And I press "Save"
  30 + And I go to Joao Silva's cms
  31 + Then I should see "My Folder"
  32 +
  33 + Scenario: create a tiny_mce article
  34 + Given I follow "New content"
  35 + When I follow "Text article with visual editor"
  36 + And I fill in "Title" with "My tiny_mce article"
  37 + And I press "Save"
  38 + And I go to Joao Silva's cms
  39 + Then I should see "My tiny_mce article"
  40 +
  41 + Scenario: create a textile article
  42 + Given I follow "New content"
  43 + When I follow "Text article with Textile markup"
  44 + And I fill in "Title" with "My textile article"
  45 + And I press "Save"
  46 + And I go to Joao Silva's cms
  47 + Then I should see "My textile article"
  48 +
  49 + Scenario: create a Blog
  50 + Given I follow "New content"
  51 + When I follow "Blog"
  52 + And I fill in "Title" with "My blog"
  53 + And I press "Save"
  54 + And I go to Joao Silva's cms
  55 + Then I should see "My blog"
  56 +
  57 + Scenario: create an event
  58 + Given I follow "New content"
  59 + When I follow "Event"
  60 + And I fill in "Title" with "My event"
  61 + And I press "Save"
  62 + And I go to Joao Silva's cms
  63 + Then I should see "My event"
  64 +
  65 + Scenario: redirect to upload files if choose UploadedFile
  66 + Given I follow "New content"
  67 + When I follow "Uploaded file"
  68 + Then I should be on /myprofile/joaosilva/cms/upload_files
features/publish_article.feature
@@ -55,7 +55,7 @@ Feature: publish article @@ -55,7 +55,7 @@ Feature: publish article
55 And "Maria Silva" is a member of "Sample Community" 55 And "Maria Silva" is a member of "Sample Community"
56 And I am on Maria Silva's control panel 56 And I am on Maria Silva's control panel
57 And I follow "Manage Content" 57 And I follow "Manage Content"
58 - And I follow "New article" 58 + And I follow "New content"
59 And I follow "Text article with Textile markup language" 59 And I follow "Text article with Textile markup language"
60 And I fill in the following: 60 And I fill in the following:
61 | Title | Sample Article | 61 | Title | Sample Article |
public/designs/icons/tango/style.css
@@ -6,7 +6,9 @@ @@ -6,7 +6,9 @@
6 .icon-close { background-image: url(Tango/16x16/actions/gtk-cancel.png) } 6 .icon-close { background-image: url(Tango/16x16/actions/gtk-cancel.png) }
7 .icon-newfolder { background-image: url(Tango/16x16/actions/folder-new.png) } 7 .icon-newfolder { background-image: url(Tango/16x16/actions/folder-new.png) }
8 .icon-folder { background-image: url(Tango/16x16/places/folder.png) } 8 .icon-folder { background-image: url(Tango/16x16/places/folder.png) }
  9 +.icon-parent-folder { background-image: url(Tango/16x16/places/folder_home.png) }
9 .icon-newblog { background-image: url(mod/16x16/apps/text-editor.png) } 10 .icon-newblog { background-image: url(mod/16x16/apps/text-editor.png) }
  11 +.icon-blog { background-image: url(mod/16x16/apps/text-editor.png) }
10 /*.icon-open { background-image: url(folder-open.gif) } UNUSED*/ 12 /*.icon-open { background-image: url(folder-open.gif) } UNUSED*/
11 /*.icon-cms { background-image: url(abiword_48.png) } UNUSED*/ 13 /*.icon-cms { background-image: url(abiword_48.png) } UNUSED*/
12 .icon-save { background-image: url(Tango/16x16/actions/filesave.png) } 14 .icon-save { background-image: url(Tango/16x16/actions/filesave.png) }
@@ -57,13 +59,17 @@ @@ -57,13 +59,17 @@
57 .icon-menu-search { background-image: url(Tango/16x16/actions/search.png) } 59 .icon-menu-search { background-image: url(Tango/16x16/actions/search.png) }
58 /*.icon-menu-ed-design { background-image: url(edit-design-HC.gif) } UNUSED */ 60 /*.icon-menu-ed-design { background-image: url(edit-design-HC.gif) } UNUSED */
59 .icon-menu-events { background-image: url(Tango/16x16/mimetypes/stock_calendar.png) } 61 .icon-menu-events { background-image: url(Tango/16x16/mimetypes/stock_calendar.png) }
  62 +.icon-event { background-image: url(Tango/16x16/mimetypes/stock_calendar.png) }
  63 +.icon-newevent { background-image: url(Tango/16x16/mimetypes/stock_calendar.png) }
60 .icon-menu-articles { background-image: url(Tango/16x16/apps/text-editor.png) } 64 .icon-menu-articles { background-image: url(Tango/16x16/apps/text-editor.png) }
61 /*.icon-menu-comments { background-image: url(blog-HC.gif) } UNUSED */ 65 /*.icon-menu-comments { background-image: url(blog-HC.gif) } UNUSED */
62 .icon-menu-people { background-image: url(mod/16x16/apps/user.png) } 66 .icon-menu-people { background-image: url(mod/16x16/apps/user.png) }
63 .icon-menu-mail { background-image: url(Tango/16x16/apps/email.png) } 67 .icon-menu-mail { background-image: url(Tango/16x16/apps/email.png) }
64 .icon-upload-file { background-image: url(Tango/16x16/actions/filesave.png) } 68 .icon-upload-file { background-image: url(Tango/16x16/actions/filesave.png) }
  69 +.icon-newupload-file { background-image: url(Tango/16x16/actions/filesave.png) }
65 .icon-slideshow { background-image: url(Tango/16x16/mimetypes/x-office-presentation.png) } 70 .icon-slideshow { background-image: url(Tango/16x16/mimetypes/x-office-presentation.png) }
66 .icon-photos { background-image: url(Tango/16x16/devices/camera-photo.png) } 71 .icon-photos { background-image: url(Tango/16x16/devices/camera-photo.png) }
  72 +.icon-text-html { background-image: url(Tango/16x16/mimetypes/text-html.png) }
67 73
68 .icon-media-pause { background-image: url(Tango/16x16/actions/media-playback-pause.png) } 74 .icon-media-pause { background-image: url(Tango/16x16/actions/media-playback-pause.png) }
69 .icon-media-play { background-image: url(Tango/16x16/actions/media-playback-start.png) } 75 .icon-media-play { background-image: url(Tango/16x16/actions/media-playback-start.png) }
@@ -74,5 +80,6 @@ @@ -74,5 +80,6 @@
74 .icon-scrap { background-image: url(Tango/16x16/actions/format-justify-left.png) } 80 .icon-scrap { background-image: url(Tango/16x16/actions/format-justify-left.png) }
75 .icon-reply { background-image: url(Tango/16x16/actions/mail-reply-sender.png) } 81 .icon-reply { background-image: url(Tango/16x16/actions/mail-reply-sender.png) }
76 .icon-newforum { background-image: url(Tango/16x16/apps/system-users.png) } 82 .icon-newforum { background-image: url(Tango/16x16/apps/system-users.png) }
  83 +.icon-forum { background-image: url(Tango/16x16/apps/system-users.png) }
77 .icon-newgallery { background-image: url(Tango/16x16/mimetypes/image-x-generic.png) } 84 .icon-newgallery { background-image: url(Tango/16x16/mimetypes/image-x-generic.png) }
78 .icon-locale { background-image: url(Tango/16x16/apps/preferences-desktop-locale.png) } 85 .icon-locale { background-image: url(Tango/16x16/apps/preferences-desktop-locale.png) }
79 \ No newline at end of file 86 \ No newline at end of file
public/images/icons-mime/rss-feed-16.png 0 → 100644

849 Bytes

public/stylesheets/application.css
@@ -315,11 +315,21 @@ div.pending-tasks { @@ -315,11 +315,21 @@ div.pending-tasks {
315 315
316 /* sitemap and agenda */ 316 /* sitemap and agenda */
317 317
  318 +.agenda-item a.icon,
  319 +.sitemap-item a.icon {
  320 + background-repeat: no-repeat;
  321 + padding-left: 20px;
  322 +}
  323 +
  324 +.agenda-item .icon:hover,
  325 +.sitemap-item .icon:hover {
  326 + background-color: transparent;
  327 +}
  328 +
318 .sitemap-item a:link, 329 .sitemap-item a:link,
319 .agenda-item a:link, 330 .agenda-item a:link,
320 .sitemap-item a:visited, 331 .sitemap-item a:visited,
321 .agenda-item a:visited { 332 .agenda-item a:visited {
322 - display: block;  
323 border: none; 333 border: none;
324 text-decoration: none; 334 text-decoration: none;
325 } 335 }
@@ -329,7 +339,6 @@ div.pending-tasks { @@ -329,7 +339,6 @@ div.pending-tasks {
329 } 339 }
330 .sitemap-item a:hover, 340 .sitemap-item a:hover,
331 .agenda-item a:hover { 341 .agenda-item a:hover {
332 - background: #e0e0e0;  
333 color: red; 342 color: red;
334 text-decoration: underline; 343 text-decoration: underline;
335 } 344 }
@@ -2750,13 +2759,64 @@ div#activation_enterprise div { @@ -2750,13 +2759,64 @@ div#activation_enterprise div {
2750 2759
2751 /* ==> public/stylesheets/controller_cms.css <== */ 2760 /* ==> public/stylesheets/controller_cms.css <== */
2752 2761
2753 -.controller-cms #article_types li {  
2754 - margin-bottom: 14px; 2762 +
  2763 +table.cms-articles img {
  2764 + width: 16px;
  2765 + height: 16px;
  2766 +}
  2767 +
  2768 +table.cms-articles a.icon {
  2769 + display: block;
  2770 + border: none;
  2771 +}
  2772 +
  2773 +table.cms-articles a.icon,
  2774 +table.cms-articles a.icon-parent-folder {
  2775 + padding: 0px 0px 3px 20px;
  2776 + background-repeat: no-repeat;
  2777 +}
  2778 +
  2779 +table.cms-articles .icon:hover {
  2780 + background-color: transparent;
  2781 +}
  2782 +
  2783 +#article_types {
  2784 + padding-left: 5px;
  2785 + margin-top: 20px;
  2786 +}
  2787 +
  2788 +#article_types li {
2755 list-style: none; 2789 list-style: none;
  2790 + float: left;
  2791 + width: 180px;
  2792 + height: 50px;
  2793 + background-repeat: no-repeat;
  2794 + background-position: 5px 5px;
  2795 + padding-left: 30px;
  2796 + padding-right: 12px;
  2797 + padding-top: 5px;
  2798 + padding-bottom: 5px;
  2799 + -moz-border-radius: 5px;
  2800 + -webkit-border-radius: 5px;
2756 } 2801 }
2757 2802
2758 -.controller-cms #article_types a {  
2759 - font-weight: bold; 2803 +#article_types .description {
  2804 + color: #888a85;
  2805 + font-size: smaller;
  2806 +}
  2807 +
  2808 +#article_types .icon-newrss-feed,
  2809 +#content .icon-rss-feed {
  2810 + background-image: url(../images/icons-mime/rss-feed-16.png);
  2811 +}
  2812 +
  2813 +#article_types a {
  2814 + text-decoration: none;
  2815 + color: black;
  2816 +}
  2817 +
  2818 +#article_types li.mouseover {
  2819 + background-color: #eeeeec;
2760 } 2820 }
2761 2821
2762 .controller-cms #article-subitems-hide.hide-button { 2822 .controller-cms #article-subitems-hide.hide-button {
@@ -3736,6 +3796,21 @@ h1#agenda-title { @@ -3736,6 +3796,21 @@ h1#agenda-title {
3736 width: 100%; 3796 width: 100%;
3737 } 3797 }
3738 3798
  3799 +#search-results li a.icon {
  3800 + display: block;
  3801 + border: none;
  3802 + padding-left: 20px;
  3803 + background-repeat: no-repeat;
  3804 +}
  3805 +
  3806 +#search-results li .icon:hover {
  3807 + background-color: transparent;
  3808 +}
  3809 +
  3810 +#search-results li:hover {
  3811 + background-color: #F0F0F0;
  3812 +}
  3813 +
3739 .controller-search .has_cat_list #map, 3814 .controller-search .has_cat_list #map,
3740 .controller-search .msie .has_cat_list #map, 3815 .controller-search .msie .has_cat_list #map,
3741 .controller-search .has_cat_list .only-one-result-box .search-results-box, 3816 .controller-search .has_cat_list .only-one-result-box .search-results-box,
public/stylesheets/media_listing.css
@@ -40,6 +40,10 @@ h4 { @@ -40,6 +40,10 @@ h4 {
40 margin: 0px; 40 margin: 0px;
41 } 41 }
42 42
  43 +#media-listing li:hover {
  44 + background-color: #CCC;
  45 +}
  46 +
43 #media-listing a { 47 #media-listing a {
44 text-decoration: none; 48 text-decoration: none;
45 } 49 }
@@ -97,10 +101,24 @@ h4 { @@ -97,10 +101,24 @@ h4 {
97 text-align: center; 101 text-align: center;
98 } 102 }
99 103
100 -#media-listing-folder-documents img { 104 +#media-listing-documents li {
  105 + padding-bottom: 5px;
  106 +}
  107 +
  108 +#media-listing-folder-documents a.icon {
  109 + background-repeat: no-repeat;
  110 + padding-left: 20px;
101 border: none; 111 border: none;
102 } 112 }
103 113
  114 +#media-listing-folder-documents .icon:hover {
  115 + background-color: transparent;
  116 +}
  117 +
  118 +#media-listing .icon-rss-feed {
  119 + background-image: url(../images/icons-mime/rss-feed-16.png);
  120 +}
  121 +
104 #media-listing-upload { 122 #media-listing-upload {
105 width: 98%; 123 width: 98%;
106 padding: 3px; 124 padding: 3px;
test/functional/cms_controller_test.rb
@@ -314,6 +314,21 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -314,6 +314,21 @@ class CmsControllerTest &lt; Test::Unit::TestCase
314 assert_template 'upload_files' 314 assert_template 'upload_files'
315 end 315 end
316 316
  317 + should 'offer to create new content' do
  318 + get :index, :profile => profile.identifier
  319 + assert_response :success
  320 + assert_template 'view'
  321 + assert_tag :tag => 'a', :attributes => { :title => 'New content', :href => "/myprofile/#{profile.identifier}/cms/new?cms=true"}
  322 + end
  323 +
  324 + should 'offer to create new content when viewing an article' do
  325 + article = fast_create(Article, :profile_id => profile.id)
  326 + get :view, :profile => profile.identifier, :id => article.id
  327 + assert_response :success
  328 + assert_template 'view'
  329 + assert_tag :tag => 'a', :attributes => { :title => 'New content', :href => "/myprofile/#{profile.identifier}/cms/new?cms=true&amp;parent_id=#{article.id}"}
  330 + end
  331 +
317 should 'offer to create children' do 332 should 'offer to create children' do
318 Article.any_instance.stubs(:allow_children?).returns(true) 333 Article.any_instance.stubs(:allow_children?).returns(true)
319 334
@@ -321,10 +336,8 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -321,10 +336,8 @@ class CmsControllerTest &lt; Test::Unit::TestCase
321 article.profile = profile 336 article.profile = profile
322 article.save! 337 article.save!
323 338
324 - get :view, :profile => profile.identifier, :id => article.id  
325 - assert_response :success  
326 - assert_template 'view'  
327 - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}"} 339 + get :new, :profile => profile.identifier, :parent_id => article.id, :cms => true
  340 + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{article.id}&amp;type=TextileArticle"}
328 end 341 end
329 342
330 should 'not offer to create children if article does not accept them' do 343 should 'not offer to create children if article does not accept them' do
@@ -476,13 +489,13 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -476,13 +489,13 @@ class CmsControllerTest &lt; Test::Unit::TestCase
476 end 489 end
477 490
478 should 'offer to create new top-level folder' do 491 should 'offer to create new top-level folder' do
479 - get :index, :profile => profile.identifier 492 + get :new, :profile => profile.identifier, :cms => true
480 assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?type=Folder"} 493 assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?type=Folder"}
481 end 494 end
482 495
483 should 'offer to create sub-folder' do 496 should 'offer to create sub-folder' do
484 f = Folder.new(:name => 'f'); profile.articles << f; f.save! 497 f = Folder.new(:name => 'f'); profile.articles << f; f.save!
485 - get :view, :profile => profile.identifier, :id => f.id 498 + get :new, :profile => profile.identifier, :parent_id => f.id, :cms => true
486 499
487 assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&amp;type=Folder" } 500 assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?parent_id=#{f.id}&amp;type=Folder" }
488 end 501 end
@@ -866,18 +879,18 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -866,18 +879,18 @@ class CmsControllerTest &lt; Test::Unit::TestCase
866 assert_equal 5, profile.blog.posts_per_page 879 assert_equal 5, profile.blog.posts_per_page
867 end 880 end
868 881
869 - should "display 'New article' when create children of folder" do 882 + should "display 'New content' when create children of folder" do
870 a = Folder.new(:name => 'article folder'); profile.articles << a; a.save! 883 a = Folder.new(:name => 'article folder'); profile.articles << a; a.save!
871 Article.stubs(:short_description).returns('bli') 884 Article.stubs(:short_description).returns('bli')
872 get :view, :profile => profile.identifier, :id => a 885 get :view, :profile => profile.identifier, :id => a
873 - assert_tag :tag => 'a', :content => 'New article' 886 + assert_tag :tag => 'a', :content => 'New content'
874 end 887 end
875 888
876 - should "display 'New post' when create children of blog" do 889 + should "display 'New content' when create children of blog" do
877 a = Blog.create!(:name => 'blog_for_test', :profile => profile) 890 a = Blog.create!(:name => 'blog_for_test', :profile => profile)
878 Article.stubs(:short_description).returns('bli') 891 Article.stubs(:short_description).returns('bli')
879 get :view, :profile => profile.identifier, :id => a 892 get :view, :profile => profile.identifier, :id => a
880 - assert_tag :tag => 'a', :content => 'New post' 893 + assert_tag :tag => 'a', :content => 'New content'
881 end 894 end
882 895
883 should 'offer confirmation to remove article' do 896 should 'offer confirmation to remove article' do
@@ -927,7 +940,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -927,7 +940,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
927 940
928 process_delayed_job_queue 941 process_delayed_job_queue
929 file = profile.articles.find_by_name('rails.png') 942 file = profile.articles.find_by_name('rails.png')
930 - assert File.exists?(file.icon_name) 943 + assert File.exists?(file.class.icon_name(file))
931 file.destroy 944 file.destroy
932 end 945 end
933 946
@@ -938,7 +951,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -938,7 +951,7 @@ class CmsControllerTest &lt; Test::Unit::TestCase
938 951
939 process_delayed_job_queue 952 process_delayed_job_queue
940 file = profile.articles.find_by_name('rails.png') 953 file = profile.articles.find_by_name('rails.png')
941 - assert File.exists?(file.icon_name) 954 + assert File.exists?(file.class.icon_name(file))
942 file.destroy 955 file.destroy
943 end 956 end
944 957
@@ -1368,13 +1381,6 @@ class CmsControllerTest &lt; Test::Unit::TestCase @@ -1368,13 +1381,6 @@ class CmsControllerTest &lt; Test::Unit::TestCase
1368 assert_equal 5, profile.forum.posts_per_page 1381 assert_equal 5, profile.forum.posts_per_page
1369 end 1382 end
1370 1383
1371 - should "display 'New post' when create children of forum" do  
1372 - a = Forum.create!(:name => 'forum_for_test', :profile => profile)  
1373 - Article.stubs(:short_description).returns('bli')  
1374 - get :view, :profile => profile.identifier, :id => a  
1375 - assert_tag :tag => 'a', :content => 'New discussion topic'  
1376 - end  
1377 -  
1378 should 'go to forum after create it' do 1384 should 'go to forum after create it' do
1379 assert_difference Forum, :count do 1385 assert_difference Forum, :count do
1380 post :new, :type => Forum.name, :profile => profile.identifier, :article => { :name => 'my-forum' }, :back_to => 'control_panel' 1386 post :new, :type => Forum.name, :profile => profile.identifier, :article => { :name => 'my-forum' }, :back_to => 'control_panel'
test/unit/article_test.rb
@@ -94,7 +94,7 @@ class ArticleTest &lt; Test::Unit::TestCase @@ -94,7 +94,7 @@ class ArticleTest &lt; Test::Unit::TestCase
94 end 94 end
95 95
96 should 'inform the icon to be used' do 96 should 'inform the icon to be used' do
97 - assert_equal 'text-html', Article.new.icon_name 97 + assert_equal 'text-html', Article.icon_name
98 end 98 end
99 99
100 should 'provide a (translatable) description' do 100 should 'provide a (translatable) description' do
test/unit/blog_test.rb
@@ -15,7 +15,11 @@ class BlogTest &lt; ActiveSupport::TestCase @@ -15,7 +15,11 @@ class BlogTest &lt; ActiveSupport::TestCase
15 end 15 end
16 16
17 should 'provide own icon name' do 17 should 'provide own icon name' do
18 - assert_not_equal Article.new.icon_name, Blog.new.icon_name 18 + assert_not_equal Article.icon_name, Blog.icon_name
  19 + end
  20 +
  21 + should 'provide blog as icon name' do
  22 + assert_equal 'blog', Blog.icon_name
19 end 23 end
20 24
21 should 'identify as folder' do 25 should 'identify as folder' do
test/unit/cms_helper_test.rb
@@ -21,7 +21,7 @@ class CmsHelperTest &lt; Test::Unit::TestCase @@ -21,7 +21,7 @@ class CmsHelperTest &lt; Test::Unit::TestCase
21 should 'display link to folder content if article is folder' do 21 should 'display link to folder content if article is folder' do
22 profile = fast_create(Profile) 22 profile = fast_create(Profile)
23 folder = fast_create(Folder, :name => 'My folder', :profile_id => profile.id) 23 folder = fast_create(Folder, :name => 'My folder', :profile_id => profile.id)
24 - expects(:link_to).with('My folder', :action => 'view', :id => folder.id) 24 + expects(:link_to).with('My folder', {:action => 'view', :id => folder.id}, :class => icon_for_article(folder))
25 25
26 result = link_to_article(folder) 26 result = link_to_article(folder)
27 end 27 end
@@ -29,11 +29,21 @@ class CmsHelperTest &lt; Test::Unit::TestCase @@ -29,11 +29,21 @@ class CmsHelperTest &lt; Test::Unit::TestCase
29 should 'display link to article if article is not folder' do 29 should 'display link to article if article is not folder' do
30 profile = fast_create(Profile) 30 profile = fast_create(Profile)
31 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) 31 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
32 - expects(:link_to).with('My article', article.url) 32 + expects(:link_to).with('My article', article.url, :class => icon_for_article(article))
33 33
34 result = link_to_article(article) 34 result = link_to_article(article)
35 end 35 end
36 36
  37 + should 'display image and link if article is an image' do
  38 + profile = fast_create(Profile)
  39 + file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
  40 + icon = icon_for_article(file)
  41 + expects(:image_tag).with(icon).returns('icon')
  42 +
  43 + expects(:link_to).with('rails.png', file.url).returns('link')
  44 + result = link_to_article(file)
  45 + end
  46 +
37 should 'display spread button when profile is a person' do 47 should 'display spread button when profile is a person' do
38 profile = fast_create(Person) 48 profile = fast_create(Person)
39 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) 49 article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
test/unit/event_test.rb
@@ -69,7 +69,7 @@ class EventTest &lt; ActiveSupport::TestCase @@ -69,7 +69,7 @@ class EventTest &lt; ActiveSupport::TestCase
69 end 69 end
70 70
71 should 'use its own icon' do 71 should 'use its own icon' do
72 - assert_equal 'event', Event.new.icon_name 72 + assert_equal 'event', Event.icon_name
73 end 73 end
74 74
75 should 'not allow end date before start date' do 75 should 'not allow end date before start date' do
test/unit/folder_helper_test.rb
@@ -11,14 +11,29 @@ class FolderHelperTest &lt; Test::Unit::TestCase @@ -11,14 +11,29 @@ class FolderHelperTest &lt; Test::Unit::TestCase
11 include FolderHelper 11 include FolderHelper
12 12
13 should 'display icon for articles' do 13 should 'display icon for articles' do
14 - art1 = mock; art1.expects(:icon_name).returns('icon1')  
15 - art2 = mock; art2.expects(:icon_name).returns('icon2') 14 + art1 = mock; art1_class = mock
  15 + art1.expects(:class).returns(art1_class)
  16 + art1_class.expects(:icon_name).returns('icon1')
16 17
17 - File.expects(:exists?).with(File.join(RAILS_ROOT, 'public', 'images', 'icons-mime', 'icon1.png')).returns(true)  
18 - File.expects(:exists?).with(File.join(RAILS_ROOT, 'public', 'images', 'icons-mime', 'icon2.png')).returns(false) 18 + art2 = mock; art2_class = mock
  19 + art2.expects(:class).returns(art2_class)
  20 + art2_class.expects(:icon_name).returns('icon2')
19 21
20 - assert_equal 'icons-mime/icon1.png', icon_for_article(art1)  
21 - assert_equal 'icons-mime/unknown.png', icon_for_article(art2) 22 + assert_equal 'icon icon-icon1', icon_for_article(art1)
  23 + assert_equal 'icon icon-icon2', icon_for_article(art2)
  24 + end
  25 +
  26 + should 'display icon for images' do
  27 + profile = fast_create(Profile)
  28 + file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile)
  29 + process_delayed_job_queue
  30 +
  31 + assert_match /rails_icon\.png/, icon_for_article(file.reload)
  32 + end
  33 +
  34 + should 'display icon for type of article' do
  35 + Article.expects(:icon_name).returns('article')
  36 + assert_match /icon-newarticle/, icon_for_new_article('Article')
22 end 37 end
23 38
24 should 'list all the folder\'s children to the owner' do 39 should 'list all the folder\'s children to the owner' do
test/unit/folder_test.rb
@@ -15,7 +15,7 @@ class FolderTest &lt; ActiveSupport::TestCase @@ -15,7 +15,7 @@ class FolderTest &lt; ActiveSupport::TestCase
15 end 15 end
16 16
17 should 'provide own icon name' do 17 should 'provide own icon name' do
18 - assert_not_equal Article.new.icon_name, Folder.new.icon_name 18 + assert_not_equal Article.icon_name, Folder.icon_name
19 end 19 end
20 20
21 should 'identify as folder' do 21 should 'identify as folder' do
test/unit/forum_test.rb
@@ -11,7 +11,11 @@ class ForumTest &lt; ActiveSupport::TestCase @@ -11,7 +11,11 @@ class ForumTest &lt; ActiveSupport::TestCase
11 end 11 end
12 12
13 should 'provide own icon name' do 13 should 'provide own icon name' do
14 - assert_not_equal Article.new.icon_name, Forum.new.icon_name 14 + assert_not_equal Article.icon_name, Forum.icon_name
  15 + end
  16 +
  17 + should 'provide forum as icon name' do
  18 + assert_equal 'forum', Forum.icon_name
15 end 19 end
16 20
17 should 'identify as folder' do 21 should 'identify as folder' do
test/unit/gallery_test.rb
@@ -15,7 +15,11 @@ class GalleryTest &lt; ActiveSupport::TestCase @@ -15,7 +15,11 @@ class GalleryTest &lt; ActiveSupport::TestCase
15 end 15 end
16 16
17 should 'provide own icon name' do 17 should 'provide own icon name' do
18 - assert_not_equal Article.new.icon_name, Gallery.new.icon_name 18 + assert_not_equal Article.icon_name, Gallery.icon_name
  19 + end
  20 +
  21 + should 'provide gallery as icon name' do
  22 + assert_not_equal Article.icon_name, Gallery.icon_name
19 end 23 end
20 24
21 should 'identify as folder' do 25 should 'identify as folder' do
test/unit/rss_feed_test.rb
@@ -190,7 +190,7 @@ class RssFeedTest &lt; Test::Unit::TestCase @@ -190,7 +190,7 @@ class RssFeedTest &lt; Test::Unit::TestCase
190 end 190 end
191 191
192 should 'provide the correct icon name' do 192 should 'provide the correct icon name' do
193 - assert_equal 'rss-feed', RssFeed.new.icon_name 193 + assert_equal 'rss-feed', RssFeed.icon_name
194 end 194 end
195 195
196 should 'advertise is false before create' do 196 should 'advertise is false before create' do
test/unit/uploaded_file_test.rb
@@ -11,14 +11,11 @@ class UploadedFileTest &lt; Test::Unit::TestCase @@ -11,14 +11,11 @@ class UploadedFileTest &lt; Test::Unit::TestCase
11 f = UploadedFile.new 11 f = UploadedFile.new
12 f.expects(:image?).returns(true) 12 f.expects(:image?).returns(true)
13 f.expects(:public_filename).with(:icon).returns('/path/to/file.xyz') 13 f.expects(:public_filename).with(:icon).returns('/path/to/file.xyz')
14 - assert_equal '/path/to/file.xyz', f.icon_name 14 + assert_equal '/path/to/file.xyz', UploadedFile.icon_name(f)
15 end 15 end
16 16
17 - should 'return mime-type icon for non-image files' do  
18 - f= UploadedFile.new  
19 - f.expects(:image?).returns(false)  
20 - f.expects(:content_type).returns('application/pdf')  
21 - assert_equal 'application-pdf', f.icon_name 17 + should 'return a default icon for uploaded files' do
  18 + assert_equal 'upload-file', UploadedFile.icon_name
22 end 19 end
23 20
24 should 'use attachment_fu content_type method to return mime_type' do 21 should 'use attachment_fu content_type method to return mime_type' do
@@ -213,7 +210,7 @@ class UploadedFileTest &lt; Test::Unit::TestCase @@ -213,7 +210,7 @@ class UploadedFileTest &lt; Test::Unit::TestCase
213 f = UploadedFile.new 210 f = UploadedFile.new
214 f.expects(:image?).returns(true) 211 f.expects(:image?).returns(true)
215 f.expects(:public_filename).with(:icon).returns('/path/to/file.xyz') 212 f.expects(:public_filename).with(:icon).returns('/path/to/file.xyz')
216 - assert_equal '/path/to/file.xyz', f.icon_name 213 + assert_equal '/path/to/file.xyz', UploadedFile.icon_name(f)
217 end 214 end
218 215
219 should 'store width and height after processing' do 216 should 'store width and height after processing' do