From 8cd2832ee0e7920c6cad76d16dbbd4a594ad1aef Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Mon, 11 Jan 2016 14:49:31 -0300 Subject: [PATCH] removing content() method from all blocks --- app/helpers/boxes_helper.rb | 9 +++++++-- app/models/article_block.rb | 7 ------- app/models/blog_archives_block.rb | 7 ------- app/models/categories_block.rb | 7 ------- app/models/communities_block.rb | 2 +- app/models/disabled_enterprise_message_block.rb | 7 ------- app/models/featured_products_block.rb | 7 ------- app/models/feed_reader_block.rb | 3 --- app/models/highlights_block.rb | 7 ------- app/models/link_list_block.rb | 7 ------- app/models/location_block.rb | 7 ------- app/models/login_block.rb | 6 ------ app/models/main_block.rb | 4 ---- app/models/my_network_block.rb | 7 ------- app/models/product_categories_block.rb | 7 ------- app/models/products_block.rb | 7 ------- app/models/profile_image_block.rb | 7 ------- app/models/profile_info_block.rb | 7 ------- app/models/profile_search_block.rb | 7 ------- app/models/raw_html_block.rb | 7 ------- app/models/recent_documents_block.rb | 7 ------- app/models/sellers_search_block.rb | 6 ------ app/models/slideshow_block.rb | 7 ------- app/models/tags_block.rb | 7 ------- app/views/blocks/communities.html.erb | 17 ----------------- app/views/blocks/communities.html.erb | 1 + app/views/blocks/communities_footer.html.erb | 17 +++++++++++++++++ app/views/blocks/enterprises.html.erb | 1 + app/views/blocks/fans.html.erb | 1 + app/views/blocks/favorite_enterprises.html.erb | 1 + app/views/blocks/login.html.erb | 16 ++++++++++++++++ app/views/blocks/login_block.html.erb | 16 ---------------- app/views/shared/block.html.erb | 4 ++-- 33 files changed, 47 insertions(+), 183 deletions(-) delete mode 100644 app/views/blocks/communities.html.erb create mode 120000 app/views/blocks/communities.html.erb create mode 100644 app/views/blocks/communities_footer.html.erb create mode 120000 app/views/blocks/enterprises.html.erb create mode 120000 app/views/blocks/fans.html.erb create mode 120000 app/views/blocks/favorite_enterprises.html.erb create mode 100644 app/views/blocks/login.html.erb delete mode 100644 app/views/blocks/login_block.html.erb diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index 2a60bc0..b8ca2d1 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -87,8 +87,13 @@ module BoxesHelper box_decorator == DontMoveBlocks end - def display_block_content(block, person, main_content = nil) - content = block.main? ? wrap_main_content(main_content) : block.content({:person => person}) + def render_block_content(block) + # TODO: se nao existe retornar nil + render :file => "blocks/#{block.name.underscore.gsub('_block', '')}", :locals => { :block => block } + end + + def display_block_content(block, main_content = nil) + content = block.main? ? wrap_main_content(main_content) : render_block_content(block) result = extract_block_content(content) footer_content = extract_block_content(block.footer) unless footer_content.blank? diff --git a/app/models/article_block.rb b/app/models/article_block.rb index 8324bc4..1d36cb7 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -18,13 +18,6 @@ class ArticleBlock < Block _('This block displays one of your articles. You can edit the block to select which one of your articles is going to be displayed in the block.') end - def content(args={}) - block = self - proc do - render :file => 'blocks/article', :locals => { :block => block } - end - end - def article_id self.settings[:article_id] end diff --git a/app/models/blog_archives_block.rb b/app/models/blog_archives_block.rb index e16c3ba..55e4b76 100644 --- a/app/models/blog_archives_block.rb +++ b/app/models/blog_archives_block.rb @@ -21,13 +21,6 @@ class BlogArchivesBlock < Block blog_id && owner.blogs.exists?(blog_id) ? owner.blogs.find(blog_id) : owner.blog end - def content(args={}) - block = self - proc do - render :file => 'blocks/blog_archives', :locals => { :block => block } - end - end - def self.expire_on { :profile => [:article], :environment => [:article] } end diff --git a/app/models/categories_block.rb b/app/models/categories_block.rb index 2601e98..27bc072 100644 --- a/app/models/categories_block.rb +++ b/app/models/categories_block.rb @@ -30,13 +30,6 @@ class CategoriesBlock < Block Category.top_level_for(self.owner).from_types(self.category_types) end - def content(args={}) - block = self - proc do - render :file => 'blocks/categories', :locals => { :block => block } - end - end - def self.expire_on { :profile => [], :environment => [:category] } end diff --git a/app/models/communities_block.rb b/app/models/communities_block.rb index 33f3330..7942613 100644 --- a/app/models/communities_block.rb +++ b/app/models/communities_block.rb @@ -32,7 +32,7 @@ class CommunitiesBlock < ProfileListBlock suggestions = self.suggestions return '' unless owner.kind_of?(Profile) || owner.kind_of?(Environment) proc do - render :file => 'blocks/communities', :locals => { :owner => owner, :suggestions => suggestions } + render :file => 'blocks/communities_footer', :locals => { :owner => owner, :suggestions => suggestions } end end diff --git a/app/models/disabled_enterprise_message_block.rb b/app/models/disabled_enterprise_message_block.rb index 5d06f89..a60b658 100644 --- a/app/models/disabled_enterprise_message_block.rb +++ b/app/models/disabled_enterprise_message_block.rb @@ -12,13 +12,6 @@ class DisabledEnterpriseMessageBlock < Block _('Message') end - def content(args={}) - block = self - proc do - render :file => 'blocks/disabled_enterprise_message', :locals => { :block => block } - end - end - def editable?(user=nil) false end diff --git a/app/models/featured_products_block.rb b/app/models/featured_products_block.rb index 90b72de..b6fd1d1 100644 --- a/app/models/featured_products_block.rb +++ b/app/models/featured_products_block.rb @@ -32,11 +32,4 @@ class FeaturedProductsBlock < Block self.owner.highlighted_products_with_image end - def content(args={}) - block = self - proc do - render :file => 'blocks/featured_products', :locals => { :block => block } - end - end - end diff --git a/app/models/feed_reader_block.rb b/app/models/feed_reader_block.rb index 0c510ed..3b38350 100644 --- a/app/models/feed_reader_block.rb +++ b/app/models/feed_reader_block.rb @@ -75,7 +75,4 @@ class FeedReaderBlock < Block self.save! end - def content(args={}) - end - end diff --git a/app/models/highlights_block.rb b/app/models/highlights_block.rb index cd8558f..2884367 100644 --- a/app/models/highlights_block.rb +++ b/app/models/highlights_block.rb @@ -43,13 +43,6 @@ class HighlightsBlock < Block end end - def content(args={}) - block = self - proc do - render :file => 'blocks/highlights', :locals => { :block => block } - end - end - def folder_choices owner.image_galleries end diff --git a/app/models/link_list_block.rb b/app/models/link_list_block.rb index 62e35aa..c17a747 100644 --- a/app/models/link_list_block.rb +++ b/app/models/link_list_block.rb @@ -59,13 +59,6 @@ class LinkListBlock < Block _('Link list') end - def content(args={}) - block = self - proc do - render :file => 'blocks/link_list', :locals => { :block => block } - end - end - def expand_address(address) add = if owner.respond_to?(:identifier) address.gsub('{profile}', owner.identifier) diff --git a/app/models/location_block.rb b/app/models/location_block.rb index ec6ea26..aa41301 100644 --- a/app/models/location_block.rb +++ b/app/models/location_block.rb @@ -13,11 +13,4 @@ class LocationBlock < Block _('Shows where the profile is on the material world.') end - def content(args={}) - block = self - proc do - render :file => 'blocks/location', :locals => {:block => block} - end - end - end diff --git a/app/models/login_block.rb b/app/models/login_block.rb index 2f6adfe..8b99df4 100644 --- a/app/models/login_block.rb +++ b/app/models/login_block.rb @@ -8,12 +8,6 @@ class LoginBlock < Block _('This block presents a login/logout block.') end - def content(args={}) - lambda do |context| - render :file => 'blocks/login_block' - end - end - def cacheable? false end diff --git a/app/models/main_block.rb b/app/models/main_block.rb index 0ed3650..2ddd070 100644 --- a/app/models/main_block.rb +++ b/app/models/main_block.rb @@ -8,10 +8,6 @@ class MainBlock < Block _('This block presents the main content of your pages.') end - def content(args={}) - nil - end - def main? true end diff --git a/app/models/my_network_block.rb b/app/models/my_network_block.rb index e0e9459..7153602 100644 --- a/app/models/my_network_block.rb +++ b/app/models/my_network_block.rb @@ -14,13 +14,6 @@ class MyNetworkBlock < Block _('This block displays some info about your networking.') end - def content(args={}) - block = self - proc do - render :file => 'blocks/my_network', :locals => { :block => block } - end - end - def cacheable? false end diff --git a/app/models/product_categories_block.rb b/app/models/product_categories_block.rb index 071412f..4b81eb6 100644 --- a/app/models/product_categories_block.rb +++ b/app/models/product_categories_block.rb @@ -13,13 +13,6 @@ class ProductCategoriesBlock < Block _('Helps to filter the products catalog.') end - def content(args={}) - block = self - proc do - render :file => 'blocks/product_categories', :locals => { :block => block } - end - end - DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog')) def display diff --git a/app/models/products_block.rb b/app/models/products_block.rb index 1ae7ace..d54dc29 100644 --- a/app/models/products_block.rb +++ b/app/models/products_block.rb @@ -19,13 +19,6 @@ class ProductsBlock < Block _('This block presents a list of your products.') end - def content(args={}) - block = self - proc do - render :file => 'blocks/products', :locals => { :block => block } - end - end - def footer link_to(_('View all products'), owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) end diff --git a/app/models/profile_image_block.rb b/app/models/profile_image_block.rb index eb461d7..767cc98 100644 --- a/app/models/profile_image_block.rb +++ b/app/models/profile_image_block.rb @@ -12,13 +12,6 @@ class ProfileImageBlock < Block _('This block presents the profile image') end - def content(args={}) - block = self - proc do - render :file => 'blocks/profile_image', :locals => { :block => block } - end - end - def cacheable? false end diff --git a/app/models/profile_info_block.rb b/app/models/profile_info_block.rb index 724cb38..62c2f4e 100644 --- a/app/models/profile_info_block.rb +++ b/app/models/profile_info_block.rb @@ -16,13 +16,6 @@ class ProfileInfoBlock < Block _('Basic information about %{user}: how long %{user} is part of %{env} and useful links.') % { :user => self.owner.name(), :env => self.owner.environment.name() } end - def content(args={}) - block = self - proc do - render :file => 'blocks/profile_info', :locals => { :block => block } - end - end - def cacheable? false end diff --git a/app/models/profile_search_block.rb b/app/models/profile_search_block.rb index 02adb4e..a194567 100644 --- a/app/models/profile_search_block.rb +++ b/app/models/profile_search_block.rb @@ -4,11 +4,4 @@ class ProfileSearchBlock < Block _('Display a form to search the profile') end - def content(args={}) - block = self - proc do - render :file => 'blocks/profile_search', :locals => { :block => block } - end - end - end diff --git a/app/models/raw_html_block.rb b/app/models/raw_html_block.rb index 7060f77..905e5aa 100644 --- a/app/models/raw_html_block.rb +++ b/app/models/raw_html_block.rb @@ -12,13 +12,6 @@ class RawHTMLBlock < Block attr_accessible :html - def content(args={}) - block = self - proc do - render :file => 'blocks/raw_html', :locals => { :block => block } - end - end - def has_macro? true end diff --git a/app/models/recent_documents_block.rb b/app/models/recent_documents_block.rb index d32a7a3..2acf624 100644 --- a/app/models/recent_documents_block.rb +++ b/app/models/recent_documents_block.rb @@ -22,13 +22,6 @@ class RecentDocumentsBlock < Block settings_items :limit, :type => :integer, :default => 5 - def content(args={}) - block = self - proc do - render :file => 'blocks/recent_documents', :locals => { :block => block } - end - end - def footer return nil unless self.owner.is_a?(Profile) diff --git a/app/models/sellers_search_block.rb b/app/models/sellers_search_block.rb index fee3884..085f92b 100644 --- a/app/models/sellers_search_block.rb +++ b/app/models/sellers_search_block.rb @@ -22,10 +22,4 @@ class SellersSearchBlock < Block _('This block presents a search engine for products.') end - def content(args={}) - block = self - proc do - render :file => 'blocks/sellers_search', :locals => { :block => block } - end - end end diff --git a/app/models/slideshow_block.rb b/app/models/slideshow_block.rb index d855454..ecafb93 100644 --- a/app/models/slideshow_block.rb +++ b/app/models/slideshow_block.rb @@ -33,13 +33,6 @@ class SlideshowBlock < Block gallery.images.reject {|item| item.folder?} end - def content(args={}) - block = self - proc do - render :file => 'blocks/slideshow', :locals => { :block => block } - end - end - def folder_choices owner.image_galleries end diff --git a/app/models/tags_block.rb b/app/models/tags_block.rb index bd14289..a9dfb2a 100644 --- a/app/models/tags_block.rb +++ b/app/models/tags_block.rb @@ -28,13 +28,6 @@ class TagsBlock < Block Try to add some tags to some articles and you'l see your tag cloud growing.") end - def content(args={}) - block = self - proc do - render :file => 'blocks/tags', :locals => { :block => block } - end - end - def footer if owner.class == Environment proc do diff --git a/app/views/blocks/communities.html.erb b/app/views/blocks/communities.html.erb deleted file mode 100644 index 45a467a..0000000 --- a/app/views/blocks/communities.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<% if owner.kind_of?(Profile) %> - <%= link_to s_('communities|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %> -<% elsif owner.kind_of?(Environment) %> - <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %> -<% end %> - -<% if user && user == profile && suggestions && !suggestions.empty? %> -
-

<%= _('Some suggestions for you') %>

-
- <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %> -
-
- <%= link_to _('See all suggestions'), profile.communities_suggestions_url %> -
-
-<% end %> diff --git a/app/views/blocks/communities.html.erb b/app/views/blocks/communities.html.erb new file mode 120000 index 0000000..e1bb652 --- /dev/null +++ b/app/views/blocks/communities.html.erb @@ -0,0 +1 @@ +profile_list.html.erb \ No newline at end of file diff --git a/app/views/blocks/communities_footer.html.erb b/app/views/blocks/communities_footer.html.erb new file mode 100644 index 0000000..45a467a --- /dev/null +++ b/app/views/blocks/communities_footer.html.erb @@ -0,0 +1,17 @@ +<% if owner.kind_of?(Profile) %> + <%= link_to s_('communities|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %> +<% elsif owner.kind_of?(Environment) %> + <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %> +<% end %> + +<% if user && user == profile && suggestions && !suggestions.empty? %> +
+

<%= _('Some suggestions for you') %>

+
+ <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %> +
+
+ <%= link_to _('See all suggestions'), profile.communities_suggestions_url %> +
+
+<% end %> diff --git a/app/views/blocks/enterprises.html.erb b/app/views/blocks/enterprises.html.erb new file mode 120000 index 0000000..e1bb652 --- /dev/null +++ b/app/views/blocks/enterprises.html.erb @@ -0,0 +1 @@ +profile_list.html.erb \ No newline at end of file diff --git a/app/views/blocks/fans.html.erb b/app/views/blocks/fans.html.erb new file mode 120000 index 0000000..e1bb652 --- /dev/null +++ b/app/views/blocks/fans.html.erb @@ -0,0 +1 @@ +profile_list.html.erb \ No newline at end of file diff --git a/app/views/blocks/favorite_enterprises.html.erb b/app/views/blocks/favorite_enterprises.html.erb new file mode 120000 index 0000000..e1bb652 --- /dev/null +++ b/app/views/blocks/favorite_enterprises.html.erb @@ -0,0 +1 @@ +profile_list.html.erb \ No newline at end of file diff --git a/app/views/blocks/login.html.erb b/app/views/blocks/login.html.erb new file mode 100644 index 0000000..ed8e1e1 --- /dev/null +++ b/app/views/blocks/login.html.erb @@ -0,0 +1,16 @@ +<% if user.present? %> +
+

<%= _('Logged in as %s') % user.identifier %>

+ + +
+<% else %> +
+ <%= render :file => 'account/login_block' %> +
+<% end%> diff --git a/app/views/blocks/login_block.html.erb b/app/views/blocks/login_block.html.erb deleted file mode 100644 index ed8e1e1..0000000 --- a/app/views/blocks/login_block.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% if user.present? %> -
-

<%= _('Logged in as %s') % user.identifier %>

- - -
-<% else %> -
- <%= render :file => 'account/login_block' %> -
-<% end%> diff --git a/app/views/shared/block.html.erb b/app/views/shared/block.html.erb index 011c6e7..9792231 100644 --- a/app/views/shared/block.html.erb +++ b/app/views/shared/block.html.erb @@ -1,7 +1,7 @@ <% if block.cacheable? && use_cache %> <% cache_timeout(block.cache_key(language, user), block.timeout) do %> - <%= display_block_content(block, user, main_content) %> + <%= display_block_content(block, main_content) %> <% end %> <% else %> - <%= display_block_content(block, user, main_content) %> + <%= display_block_content(block, main_content) %> <% end %> -- libgit2 0.21.2