Commit cc5fdb28f995ac18833aa5553a49b51796ebe894
Committed by
Daniela Feitosa
1 parent
8796893a
Exists in
web_steps_improvements
and in
6 other branches
Add subtitle field to blocks
Add subtitle support to the following core blocks: * my_network * profile_search * categories * highlights * slideshow * article * blog_archives * featured_products * feed_reader * link_list * location * products * profile_list * raw_html * recent_documents * tags Add subtitle support to the following plugins blocks: * community_track: track_list * container_block: container * context_content: context_content * display_content: display_content_block * event: event * gallery_block: gallery_block * organization_ratings: organization_ratings_block * people_block: people_base * profile_members_headlines: headlines * recent_content: recent_content_block * relevant_content: relevant_content_block * site_tour: tour * sniffer: interests_block Signed-off-by: Daniela Soares Feitosa <danielafeitosa@colivre.coop.br>
Showing
41 changed files
with
77 additions
and
40 deletions
Show diff stats
app/helpers/block_helper.rb
1 | module BlockHelper | 1 | module BlockHelper |
2 | 2 | ||
3 | - def block_title(title) | ||
4 | - tag_class = 'block-title' | 3 | + def block_title(title, subtitle=nil) |
4 | + block_header = block_heading title | ||
5 | + block_header += block_heading(subtitle, 'h4') if subtitle | ||
6 | + content_tag 'div', block_header, :class => 'block-header' | ||
7 | + end | ||
8 | + | ||
9 | + def block_heading(title, heading='h3') | ||
10 | + tag_class = 'block-' + (heading == 'h3' ? 'title' : 'subtitle') | ||
5 | tag_class += ' empty' if title.empty? | 11 | tag_class += ' empty' if title.empty? |
6 | - content_tag 'h3', content_tag('span', h(title)), :class => tag_class | 12 | + content_tag heading, content_tag('span', h(title)), :class => tag_class |
7 | end | 13 | end |
8 | 14 | ||
9 | def highlights_block_config_image_fields(block, image={}, row_number=nil) | 15 | def highlights_block_config_image_fields(block, image={}, row_number=nil) |
app/models/block.rb
1 | class Block < ActiveRecord::Base | 1 | class Block < ActiveRecord::Base |
2 | 2 | ||
3 | - attr_accessible :title, :display, :limit, :box_id, :posts_per_page, | 3 | + attr_accessible :title, :subtitle, :display, :limit, :box_id, :posts_per_page, |
4 | :visualization_format, :language, :display_user, | 4 | :visualization_format, :language, :display_user, |
5 | :box, :edit_modes, :move_modes, :mirror | 5 | :box, :edit_modes, :move_modes, :mirror |
6 | 6 |
app/views/blocks/article.html.erb
app/views/blocks/blog_archives.html.erb
1 | <% if block.blog %> | 1 | <% if block.blog %> |
2 | - <%= block_title(block.title) %> | 2 | + <%= block_title(block.title, block.subtitle) %> |
3 | 3 | ||
4 | <ul class='blog-archives'> | 4 | <ul class='blog-archives'> |
5 | <% block.blog.total_number_of_posts(:by_year).each do |year, count| %> | 5 | <% block.blog.total_number_of_posts(:by_year).each do |year, count| %> |
app/views/blocks/categories.html.erb
app/views/blocks/featured_products.html.erb
1 | -<%= block_title(block.title) %> | 1 | +<%= block_title(block.title, block.subtitle) %> |
2 | <% unless block.products.blank? %> | 2 | <% unless block.products.blank? %> |
3 | <%= link_to content_tag(:span, _('Previous')), '#', :class => 'featured-product-prev featured-product-arrow' %> | 3 | <%= link_to content_tag(:span, _('Previous')), '#', :class => 'featured-product-prev featured-product-arrow' %> |
4 | <div class="featured-products-block-container"> | 4 | <div class="featured-products-block-container"> |
app/views/blocks/feed_reader.html.erb
app/views/blocks/highlights.html.erb
1 | -<%= block_title(block.title) %> | 1 | +<%= block_title(block.title, block.subtitle) %> |
2 | + | ||
2 | <% if !block.featured_images.empty? %> | 3 | <% if !block.featured_images.empty? %> |
3 | <div class='highlights-border'> | 4 | <div class='highlights-border'> |
4 | <div class='highlights-container'> | 5 | <div class='highlights-container'> |
app/views/blocks/link_list.html.erb
1 | -<%= block_title(block.title) %> | 1 | +<%= block_title(block.title, block.subtitle) %> |
2 | 2 | ||
3 | <%= block.links.empty? && block.title.empty? ? content_tag('em', _('Please, edit this block to add links')) : '' %> | 3 | <%= block.links.empty? && block.title.empty? ? content_tag('em', _('Please, edit this block to add links')) : '' %> |
4 | 4 |
app/views/blocks/location.html.erb
1 | <% if block.owner.lat %> | 1 | <% if block.owner.lat %> |
2 | - <%= block_title block.title %> | 2 | + <%= block_title(block.title, block.subtitle) %> |
3 | <div class='the-localization-map'> | 3 | <div class='the-localization-map'> |
4 | <img src="https://maps.google.com/maps/api/staticmap?center=<%=block.owner.lat%>,<%=block.owner.lng%>&zoom=<%=block.zoom%>&size=190x250&maptype=<%=block.map_type%>&markers=<%=block.owner.lat%>,<%=block.owner.lng%>&sensor=false"/> | 4 | <img src="https://maps.google.com/maps/api/staticmap?center=<%=block.owner.lat%>,<%=block.owner.lng%>&zoom=<%=block.zoom%>&size=190x250&maptype=<%=block.map_type%>&markers=<%=block.owner.lat%>,<%=block.owner.lng%>&sensor=false"/> |
5 | </div> | 5 | </div> |
app/views/blocks/my_network.html.erb
app/views/blocks/products.html.erb
app/views/blocks/profile_list.html.erb
app/views/blocks/profile_search.html.erb
app/views/blocks/raw_html.html.erb
app/views/blocks/recent_documents.html.erb
app/views/blocks/slideshow.html.erb
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | end | 7 | end |
8 | %> | 8 | %> |
9 | 9 | ||
10 | -<%= block_title(block.title) %> | 10 | +<%= block_title(block.title, block.subtitle) %> |
11 | 11 | ||
12 | <% if images %> | 12 | <% if images %> |
13 | <% description = images.any? { |img| !img.abstract.blank? } %> | 13 | <% description = images.any? { |img| !img.abstract.blank? } %> |
app/views/blocks/tags.html.erb
app/views/box_organizer/edit.html.erb
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | <%= form_tag(:action => 'save', :id => @block.id) do %> | 4 | <%= form_tag(:action => 'save', :id => @block.id) do %> |
5 | 5 | ||
6 | <%= labelled_form_field(_('Custom title for this block: '), text_field(:block, :title, :maxlength => 20)) %> | 6 | <%= labelled_form_field(_('Custom title for this block: '), text_field(:block, :title, :maxlength => 20)) %> |
7 | + <%= labelled_form_field(_('Custom subtitle for this block: '), text_field(:block, :subtitle)) %> | ||
7 | 8 | ||
8 | <%= render :partial => partial_for_class(@block.class) %> | 9 | <%= render :partial => partial_for_class(@block.class) %> |
9 | 10 |
db/schema.rb
@@ -206,6 +206,7 @@ ActiveRecord::Schema.define(version: 20160324132518) do | @@ -206,6 +206,7 @@ ActiveRecord::Schema.define(version: 20160324132518) do | ||
206 | t.boolean "mirror", default: false | 206 | t.boolean "mirror", default: false |
207 | t.integer "mirror_block_id" | 207 | t.integer "mirror_block_id" |
208 | t.integer "observers_id" | 208 | t.integer "observers_id" |
209 | + t.string "subtitle", default: "" | ||
209 | end | 210 | end |
210 | 211 | ||
211 | add_index "blocks", ["box_id"], name: "index_blocks_on_box_id", using: :btree | 212 | add_index "blocks", ["box_id"], name: "index_blocks_on_box_id", using: :btree |
plugins/community_track/views/blocks/track_list.html.erb
1 | -<%= block_title(block.title) %> | 1 | +<%= block_title(block.title, block.subtitle) %> |
2 | 2 | ||
3 | <div class="track_list" id="track_list_<%= block.id %>"> | 3 | <div class="track_list" id="track_list_<%= block.id %>"> |
4 | <%= render :partial => "blocks/#{block.track_partial}", :collection => block.tracks, :locals => {:block => block} %> | 4 | <%= render :partial => "blocks/#{block.track_partial}", :collection => block.tracks, :locals => {:block => block} %> |
plugins/container_block/views/blocks/container.html.erb
1 | <% edit_mode = controller.send(:boxes_editor?) && controller.send(:uses_design_blocks?) %> | 1 | <% edit_mode = controller.send(:boxes_editor?) && controller.send(:uses_design_blocks?) %> |
2 | <% box_decorator = edit_mode ? self : BoxesHelper::DontMoveBlocks %> | 2 | <% box_decorator = edit_mode ? self : BoxesHelper::DontMoveBlocks %> |
3 | 3 | ||
4 | -<%= block_title(block.title) %> | 4 | +<%= block_title(block.title, block.subtitle) %> |
5 | 5 | ||
6 | <div class="box" id="box-<%= block.container_box.id %>"> | 6 | <div class="box" id="box-<%= block.container_box.id %>"> |
7 | <%= display_box_content(block.container_box, nil) %> | 7 | <%= display_box_content(block.container_box, nil) %> |
plugins/context_content/views/blocks/context_content.html.erb
1 | <% if block.use_parent_title %> | 1 | <% if block.use_parent_title %> |
2 | - <%= block_title(parent_title) %> | 2 | + <%= block_title(parent_title, block.subtitle) %> |
3 | <% else %> | 3 | <% else %> |
4 | - <%= block_title(block.title) %> | 4 | + <%= block_title(block.title, block.subtitle) %> |
5 | <% end %> | 5 | <% end %> |
6 | 6 | ||
7 | <div class='contents' id='<%="context_content_#{block.id}"%>'> | 7 | <div class='contents' id='<%="context_content_#{block.id}"%>'> |
@@ -18,4 +18,4 @@ | @@ -18,4 +18,4 @@ | ||
18 | </a> | 18 | </a> |
19 | </span> | 19 | </span> |
20 | <% end %> | 20 | <% end %> |
21 | -</div> | ||
22 | \ No newline at end of file | 21 | \ No newline at end of file |
22 | +</div> |
plugins/display_content/lib/display_content_block.rb
@@ -139,7 +139,7 @@ class DisplayContentBlock < Block | @@ -139,7 +139,7 @@ class DisplayContentBlock < Block | ||
139 | end | 139 | end |
140 | 140 | ||
141 | proc do | 141 | proc do |
142 | - block.block_title(block.title) + | 142 | + block.block_title(block.title, block.subtitle) + |
143 | content_tag('ul', docs.map {|item| | 143 | content_tag('ul', docs.map {|item| |
144 | if !item.folder? && item.class != RssFeed | 144 | if !item.folder? && item.class != RssFeed |
145 | content_sections = '' | 145 | content_sections = '' |
plugins/event/views/blocks/event.html.erb
plugins/gallery_block/views/gallery_block.html.erb
1 | -<%= block_title(block.title) %> | 1 | +<%= block_title(block.title, block.subtitle) %> |
2 | 2 | ||
3 | <% unless block.images.blank? %> | 3 | <% unless block.images.blank? %> |
4 | <%= link_to content_tag(:span, _('Previous')), '#', :class => 'gallery-block-prev gallery-block-arrow icon-left' %> | 4 | <%= link_to content_tag(:span, _('Previous')), '#', :class => 'gallery-block-prev gallery-block-arrow icon-left' %> |
plugins/organization_ratings/views/blocks/organization_ratings_block.html.erb
1 | <div class="ratings-title"> | 1 | <div class="ratings-title"> |
2 | - <%= block_title(block.title) %> | 2 | + <%= block_title(block.title, block.subtitle) %> |
3 | <% if block.get_ratings(block.owner.id).empty? %> | 3 | <% if block.get_ratings(block.owner.id).empty? %> |
4 | <div class="ratings-list"> | 4 | <div class="ratings-list"> |
5 | <%= render :partial => 'shared/make_report_block' %> | 5 | <%= render :partial => 'shared/make_report_block' %> |
plugins/people_block/test/unit/friends_block_test.rb
@@ -136,7 +136,7 @@ class FriendsBlockViewTest < ActionView::TestCase | @@ -136,7 +136,7 @@ class FriendsBlockViewTest < ActionView::TestCase | ||
136 | block.expects(:owner).returns(owner).at_least_once | 136 | block.expects(:owner).returns(owner).at_least_once |
137 | ActionView::Base.any_instance.expects(:profile_image_link).with(friend1, :minor).returns(friend1.name) | 137 | ActionView::Base.any_instance.expects(:profile_image_link).with(friend1, :minor).returns(friend1.name) |
138 | ActionView::Base.any_instance.expects(:profile_image_link).with(friend2, :minor).returns(friend2.name) | 138 | ActionView::Base.any_instance.expects(:profile_image_link).with(friend2, :minor).returns(friend2.name) |
139 | - ActionView::Base.any_instance.expects(:block_title).with(anything).returns('') | 139 | + ActionView::Base.any_instance.expects(:block_title).with(anything, anything).returns('') |
140 | 140 | ||
141 | content = render_block_content(block) | 141 | content = render_block_content(block) |
142 | 142 |
plugins/people_block/test/unit/members_block_test.rb
@@ -248,7 +248,7 @@ class MembersBlockViewTest < ActionView::TestCase | @@ -248,7 +248,7 @@ class MembersBlockViewTest < ActionView::TestCase | ||
248 | block.expects(:owner).returns(owner).at_least_once | 248 | block.expects(:owner).returns(owner).at_least_once |
249 | ActionView::Base.any_instance.expects(:profile_image_link).with(person1, :minor).returns(person1.name) | 249 | ActionView::Base.any_instance.expects(:profile_image_link).with(person1, :minor).returns(person1.name) |
250 | ActionView::Base.any_instance.expects(:profile_image_link).with(person2, :minor).returns(person2.name) | 250 | ActionView::Base.any_instance.expects(:profile_image_link).with(person2, :minor).returns(person2.name) |
251 | - ActionView::Base.any_instance.expects(:block_title).with(anything).returns('') | 251 | + ActionView::Base.any_instance.expects(:block_title).with(anything, anything).returns('') |
252 | 252 | ||
253 | content = render_block_content(block) | 253 | content = render_block_content(block) |
254 | 254 |
plugins/people_block/views/blocks/people_base.html.erb
plugins/profile_members_headlines/views/blocks/headlines.html.erb
plugins/recent_content/views/blocks/recent_content_block.html.erb
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <div id="recent-content-block"> | 2 | <div id="recent-content-block"> |
3 | <% children = block.articles_of_folder(root, block.total_items)%> | 3 | <% children = block.articles_of_folder(root, block.total_items)%> |
4 | <div class="recent-content"> | 4 | <div class="recent-content"> |
5 | - <%= block_title(block.title.blank? ? c_("Recent content") : block.title ) %> | 5 | + <%= block_title(block.title.blank? ? c_("Recent content") : block.title, block.subtitle ) %> |
6 | <% if block.show_blog_picture and !root.image.nil? %> | 6 | <% if block.show_blog_picture and !root.image.nil? %> |
7 | <div class="recent-content-cover"> | 7 | <div class="recent-content-cover"> |
8 | <%= image_tag(root.image.public_filename(:big)) %> | 8 | <%= image_tag(root.image.public_filename(:big)) %> |
plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb
@@ -25,7 +25,7 @@ class RelevantContentPlugin::RelevantContentBlock < Block | @@ -25,7 +25,7 @@ class RelevantContentPlugin::RelevantContentBlock < Block | ||
25 | 25 | ||
26 | def content(args={}) | 26 | def content(args={}) |
27 | 27 | ||
28 | - content = block_title(title) | 28 | + content = block_title(title, subtitle) |
29 | 29 | ||
30 | if self.show_most_read | 30 | if self.show_most_read |
31 | docs = Article.most_accessed(owner, self.limit) | 31 | docs = Article.most_accessed(owner, self.limit) |
plugins/site_tour/views/blocks/tour.html.erb
1 | -<%= block_title(block.title) %> | 1 | +<%= block_title(block.title, block.subtitle) %> |
2 | 2 | ||
3 | <% if block.display_button %> | 3 | <% if block.display_button %> |
4 | <%= button :help, _('Help'), '#', :class => 'tour-button', :onclick => 'siteTourPlugin.force();' %> | 4 | <%= button :help, _('Help'), '#', :class => 'tour-button', :onclick => 'siteTourPlugin.force();' %> |
plugins/sniffer/views/blocks/sniffer_plugin/interests_block.html.erb
public/stylesheets/blocks.scss
test/unit/article_block_test.rb
@@ -108,7 +108,9 @@ class ArticleBlockViewTest < ActionView::TestCase | @@ -108,7 +108,9 @@ class ArticleBlockViewTest < ActionView::TestCase | ||
108 | block.expects(:title).returns('') | 108 | block.expects(:title).returns('') |
109 | block.stubs(:article).returns(article) | 109 | block.stubs(:article).returns(article) |
110 | 110 | ||
111 | - assert_equal "<h3 class=\"block-title empty\"><span></span></h3>\n Article content\n", render_block_content(block) | 111 | + assert_tag_in_string render_block_content(block), |
112 | + :tag => 'h3', :attributes => {:class => 'block-title empty'}, | ||
113 | + :descendant => { :tag => 'span' } | ||
112 | end | 114 | end |
113 | 115 | ||
114 | should "display title if defined" do | 116 | should "display title if defined" do |
@@ -118,7 +120,9 @@ class ArticleBlockViewTest < ActionView::TestCase | @@ -118,7 +120,9 @@ class ArticleBlockViewTest < ActionView::TestCase | ||
118 | block.expects(:title).returns('Article title') | 120 | block.expects(:title).returns('Article title') |
119 | block.stubs(:article).returns(article) | 121 | block.stubs(:article).returns(article) |
120 | 122 | ||
121 | - assert_equal "<h3 class=\"block-title\"><span>Article title</span></h3>\n Article content\n", render_block_content(block) | 123 | + assert_tag_in_string render_block_content(block), |
124 | + :tag => 'h3', :attributes => {:class => 'block-title'}, | ||
125 | + :descendant => { :tag => 'span', :content => 'Article title' } | ||
122 | end | 126 | end |
123 | 127 | ||
124 | should 'display image if article is an image' do | 128 | should 'display image if article is an image' do |
test/unit/block_helper_test.rb
@@ -10,4 +10,12 @@ class BlockHelperTest < ActiveSupport::TestCase | @@ -10,4 +10,12 @@ class BlockHelperTest < ActiveSupport::TestCase | ||
10 | assert_match /<b>test<\/b>/, block_title(unsafe('<b>test</b>')) | 10 | assert_match /<b>test<\/b>/, block_title(unsafe('<b>test</b>')) |
11 | end | 11 | end |
12 | 12 | ||
13 | + should 'escape subtitle html' do | ||
14 | + assert_no_match /<b>/, block_title('', unsafe('<b>test</b>')) | ||
15 | + assert_match /<b>test<\/b>/, block_title('', unsafe('<b>test</b>')) | ||
16 | + end | ||
17 | + | ||
18 | + should 'add "empty" class to blank subtitles tag' do | ||
19 | + assert_match "block-subtitle empty", block_title('', '') | ||
20 | + end | ||
13 | end | 21 | end |
test/unit/block_test.rb
@@ -31,6 +31,10 @@ class BlockTest < ActiveSupport::TestCase | @@ -31,6 +31,10 @@ class BlockTest < ActiveSupport::TestCase | ||
31 | assert_equal '', Block.new.default_title | 31 | assert_equal '', Block.new.default_title |
32 | end | 32 | end |
33 | 33 | ||
34 | + should 'provide an empty default subtitle' do | ||
35 | + assert_equal '', Block.new.subtitle | ||
36 | + end | ||
37 | + | ||
34 | should 'be editable by default' do | 38 | should 'be editable by default' do |
35 | assert Block.new.editable? | 39 | assert Block.new.editable? |
36 | end | 40 | end |
test/unit/my_network_block_test.rb
@@ -42,7 +42,7 @@ class MyNetworkBlockViewTest < ActionView::TestCase | @@ -42,7 +42,7 @@ class MyNetworkBlockViewTest < ActionView::TestCase | ||
42 | attr_reader :owner, :block | 42 | attr_reader :owner, :block |
43 | 43 | ||
44 | should 'display my-profile' do | 44 | should 'display my-profile' do |
45 | - ActionView::Base.any_instance.stubs(:block_title).with(anything).returns(true) | 45 | + ActionView::Base.any_instance.stubs(:block_title).with(anything, anything).returns(true) |
46 | ActionView::Base.any_instance.stubs(:user).with(anything).returns(owner) | 46 | ActionView::Base.any_instance.stubs(:user).with(anything).returns(owner) |
47 | ActionView::Base.any_instance.stubs(:render_profile_actions) | 47 | ActionView::Base.any_instance.stubs(:render_profile_actions) |
48 | assert_match "#{Environment.default.top_url}/profile/testuser", render_block_content(block) | 48 | assert_match "#{Environment.default.top_url}/profile/testuser", render_block_content(block) |