Commit cc5fdb28f995ac18833aa5553a49b51796ebe894
Committed by
Daniela Feitosa
1 parent
8796893a
Exists in
staging
and in
32 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 | 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 | 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 | 13 | end |
8 | 14 | |
9 | 15 | def highlights_block_config_image_fields(block, image={}, row_number=nil) | ... | ... |
app/models/block.rb
1 | 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 | 4 | :visualization_format, :language, :display_user, |
5 | 5 | :box, :edit_modes, :move_modes, :mirror |
6 | 6 | ... | ... |
app/views/blocks/article.html.erb
app/views/blocks/blog_archives.html.erb
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 | 2 | <% unless block.products.blank? %> |
3 | 3 | <%= link_to content_tag(:span, _('Previous')), '#', :class => 'featured-product-prev featured-product-arrow' %> |
4 | 4 | <div class="featured-products-block-container"> | ... | ... |
app/views/blocks/feed_reader.html.erb
app/views/blocks/highlights.html.erb
app/views/blocks/link_list.html.erb
app/views/blocks/location.html.erb
1 | 1 | <% if block.owner.lat %> |
2 | - <%= block_title block.title %> | |
2 | + <%= block_title(block.title, block.subtitle) %> | |
3 | 3 | <div class='the-localization-map'> |
4 | 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 | 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
app/views/blocks/tags.html.erb
app/views/box_organizer/edit.html.erb
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | <%= form_tag(:action => 'save', :id => @block.id) do %> |
5 | 5 | |
6 | 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 | 9 | <%= render :partial => partial_for_class(@block.class) %> |
9 | 10 | ... | ... |
db/schema.rb
... | ... | @@ -206,6 +206,7 @@ ActiveRecord::Schema.define(version: 20160324132518) do |
206 | 206 | t.boolean "mirror", default: false |
207 | 207 | t.integer "mirror_block_id" |
208 | 208 | t.integer "observers_id" |
209 | + t.string "subtitle", default: "" | |
209 | 210 | end |
210 | 211 | |
211 | 212 | add_index "blocks", ["box_id"], name: "index_blocks_on_box_id", using: :btree | ... | ... |
plugins/community_track/views/blocks/track_list.html.erb
plugins/container_block/views/blocks/container.html.erb
1 | 1 | <% edit_mode = controller.send(:boxes_editor?) && controller.send(:uses_design_blocks?) %> |
2 | 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 | 6 | <div class="box" id="box-<%= block.container_box.id %>"> |
7 | 7 | <%= display_box_content(block.container_box, nil) %> | ... | ... |
plugins/context_content/views/blocks/context_content.html.erb
1 | 1 | <% if block.use_parent_title %> |
2 | - <%= block_title(parent_title) %> | |
2 | + <%= block_title(parent_title, block.subtitle) %> | |
3 | 3 | <% else %> |
4 | - <%= block_title(block.title) %> | |
4 | + <%= block_title(block.title, block.subtitle) %> | |
5 | 5 | <% end %> |
6 | 6 | |
7 | 7 | <div class='contents' id='<%="context_content_#{block.id}"%>'> |
... | ... | @@ -18,4 +18,4 @@ |
18 | 18 | </a> |
19 | 19 | </span> |
20 | 20 | <% end %> |
21 | -</div> | |
22 | 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 | 139 | end |
140 | 140 | |
141 | 141 | proc do |
142 | - block.block_title(block.title) + | |
142 | + block.block_title(block.title, block.subtitle) + | |
143 | 143 | content_tag('ul', docs.map {|item| |
144 | 144 | if !item.folder? && item.class != RssFeed |
145 | 145 | content_sections = '' | ... | ... |
plugins/event/views/blocks/event.html.erb
plugins/gallery_block/views/gallery_block.html.erb
plugins/organization_ratings/views/blocks/organization_ratings_block.html.erb
plugins/people_block/test/unit/friends_block_test.rb
... | ... | @@ -136,7 +136,7 @@ class FriendsBlockViewTest < ActionView::TestCase |
136 | 136 | block.expects(:owner).returns(owner).at_least_once |
137 | 137 | ActionView::Base.any_instance.expects(:profile_image_link).with(friend1, :minor).returns(friend1.name) |
138 | 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 | 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 | 248 | block.expects(:owner).returns(owner).at_least_once |
249 | 249 | ActionView::Base.any_instance.expects(:profile_image_link).with(person1, :minor).returns(person1.name) |
250 | 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 | 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 | 2 | <div id="recent-content-block"> |
3 | 3 | <% children = block.articles_of_folder(root, block.total_items)%> |
4 | 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 | 6 | <% if block.show_blog_picture and !root.image.nil? %> |
7 | 7 | <div class="recent-content-cover"> |
8 | 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 | 25 | |
26 | 26 | def content(args={}) |
27 | 27 | |
28 | - content = block_title(title) | |
28 | + content = block_title(title, subtitle) | |
29 | 29 | |
30 | 30 | if self.show_most_read |
31 | 31 | docs = Article.most_accessed(owner, self.limit) | ... | ... |
plugins/site_tour/views/blocks/tour.html.erb
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 | 108 | block.expects(:title).returns('') |
109 | 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 | 114 | end |
113 | 115 | |
114 | 116 | should "display title if defined" do |
... | ... | @@ -118,7 +120,9 @@ class ArticleBlockViewTest < ActionView::TestCase |
118 | 120 | block.expects(:title).returns('Article title') |
119 | 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 | 126 | end |
123 | 127 | |
124 | 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 | 10 | assert_match /<b>test<\/b>/, block_title(unsafe('<b>test</b>')) |
11 | 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 | 21 | end | ... | ... |
test/unit/block_test.rb
... | ... | @@ -31,6 +31,10 @@ class BlockTest < ActiveSupport::TestCase |
31 | 31 | assert_equal '', Block.new.default_title |
32 | 32 | end |
33 | 33 | |
34 | + should 'provide an empty default subtitle' do | |
35 | + assert_equal '', Block.new.subtitle | |
36 | + end | |
37 | + | |
34 | 38 | should 'be editable by default' do |
35 | 39 | assert Block.new.editable? |
36 | 40 | end | ... | ... |
test/unit/my_network_block_test.rb
... | ... | @@ -42,7 +42,7 @@ class MyNetworkBlockViewTest < ActionView::TestCase |
42 | 42 | attr_reader :owner, :block |
43 | 43 | |
44 | 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 | 46 | ActionView::Base.any_instance.stubs(:user).with(anything).returns(owner) |
47 | 47 | ActionView::Base.any_instance.stubs(:render_profile_actions) |
48 | 48 | assert_match "#{Environment.default.top_url}/profile/testuser", render_block_content(block) | ... | ... |