From cc5fdb28f995ac18833aa5553a49b51796ebe894 Mon Sep 17 00:00:00 2001 From: Arthur Del Esposte Date: Wed, 27 Jan 2016 15:21:23 -0200 Subject: [PATCH] Add subtitle field to blocks --- app/helpers/block_helper.rb | 12 +++++++++--- app/models/block.rb | 2 +- app/views/blocks/article.html.erb | 2 +- app/views/blocks/blog_archives.html.erb | 2 +- app/views/blocks/categories.html.erb | 2 +- app/views/blocks/featured_products.html.erb | 2 +- app/views/blocks/feed_reader.html.erb | 2 +- app/views/blocks/highlights.html.erb | 3 ++- app/views/blocks/link_list.html.erb | 2 +- app/views/blocks/location.html.erb | 2 +- app/views/blocks/my_network.html.erb | 2 +- app/views/blocks/products.html.erb | 2 +- app/views/blocks/profile_list.html.erb | 2 +- app/views/blocks/profile_search.html.erb | 2 +- app/views/blocks/raw_html.html.erb | 2 +- app/views/blocks/recent_documents.html.erb | 2 +- app/views/blocks/slideshow.html.erb | 2 +- app/views/blocks/tags.html.erb | 2 +- app/views/box_organizer/edit.html.erb | 1 + db/migrate/20160127141855_add_subtitle_to_blocks.rb | 8 ++++++++ db/schema.rb | 1 + plugins/community_track/views/blocks/track_list.html.erb | 2 +- plugins/container_block/views/blocks/container.html.erb | 2 +- plugins/context_content/views/blocks/context_content.html.erb | 6 +++--- plugins/display_content/lib/display_content_block.rb | 2 +- plugins/event/views/blocks/event.html.erb | 2 +- plugins/gallery_block/views/gallery_block.html.erb | 2 +- plugins/organization_ratings/views/blocks/organization_ratings_block.html.erb | 2 +- plugins/people_block/test/unit/friends_block_test.rb | 2 +- plugins/people_block/test/unit/members_block_test.rb | 2 +- plugins/people_block/views/blocks/people_base.html.erb | 2 +- plugins/profile_members_headlines/views/blocks/headlines.html.erb | 2 +- plugins/recent_content/views/blocks/recent_content_block.html.erb | 2 +- plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb | 2 +- plugins/site_tour/views/blocks/tour.html.erb | 2 +- plugins/sniffer/views/blocks/sniffer_plugin/interests_block.html.erb | 2 +- public/stylesheets/blocks.scss | 4 ++++ test/unit/article_block_test.rb | 8 ++++++-- test/unit/block_helper_test.rb | 8 ++++++++ test/unit/block_test.rb | 4 ++++ test/unit/my_network_block_test.rb | 2 +- 41 files changed, 77 insertions(+), 40 deletions(-) create mode 100644 db/migrate/20160127141855_add_subtitle_to_blocks.rb diff --git a/app/helpers/block_helper.rb b/app/helpers/block_helper.rb index f0b2699..6749b74 100644 --- a/app/helpers/block_helper.rb +++ b/app/helpers/block_helper.rb @@ -1,9 +1,15 @@ module BlockHelper - def block_title(title) - tag_class = 'block-title' + def block_title(title, subtitle=nil) + block_header = block_heading title + block_header += block_heading(subtitle, 'h4') if subtitle + content_tag 'div', block_header, :class => 'block-header' + end + + def block_heading(title, heading='h3') + tag_class = 'block-' + (heading == 'h3' ? 'title' : 'subtitle') tag_class += ' empty' if title.empty? - content_tag 'h3', content_tag('span', h(title)), :class => tag_class + content_tag heading, content_tag('span', h(title)), :class => tag_class end def highlights_block_config_image_fields(block, image={}, row_number=nil) diff --git a/app/models/block.rb b/app/models/block.rb index 2fd43d0..f703930 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -1,6 +1,6 @@ class Block < ActiveRecord::Base - attr_accessible :title, :display, :limit, :box_id, :posts_per_page, + attr_accessible :title, :subtitle, :display, :limit, :box_id, :posts_per_page, :visualization_format, :language, :display_user, :box, :edit_modes, :move_modes, :mirror diff --git a/app/views/blocks/article.html.erb b/app/views/blocks/article.html.erb index 1e16825..512aeb3 100644 --- a/app/views/blocks/article.html.erb +++ b/app/views/blocks/article.html.erb @@ -1,4 +1,4 @@ -<%= block_title(block.title) %> +<%= block_title(block.title, block.subtitle) %> <% if block.article %> <%= h(article_to_html(FilePresenter.for(block.article), diff --git a/app/views/blocks/blog_archives.html.erb b/app/views/blocks/blog_archives.html.erb index 552490c..624e27f 100644 --- a/app/views/blocks/blog_archives.html.erb +++ b/app/views/blocks/blog_archives.html.erb @@ -1,5 +1,5 @@ <% if block.blog %> - <%= block_title(block.title) %> + <%= block_title(block.title, block.subtitle) %>