diff --git a/app/models/link_list_block.rb b/app/models/link_list_block.rb index 874c52e..62e35aa 100644 --- a/app/models/link_list_block.rb +++ b/app/models/link_list_block.rb @@ -60,17 +60,10 @@ class LinkListBlock < Block end def content(args={}) - block_title(title) + - content_tag('ul', - links.select{|i| !i[:name].blank? and !i[:address].blank?}.map{|i| content_tag('li', link_html(i))}.join - ) - end - - def link_html(link) - klass = 'icon-' + link[:icon] if link[:icon] - sanitize_link( - link_to(link[:name], expand_address(link[:address]), :target => link[:target], :class => klass, :title => link[:title]) - ) + block = self + proc do + render :file => 'blocks/link_list', :locals => { :block => block } + end end def expand_address(address) @@ -99,8 +92,6 @@ class LinkListBlock < Block end end - private - def sanitize_link(text) sanitizer = HTML::WhiteListSanitizer.new sanitizer.sanitize(text) diff --git a/app/models/location_block.rb b/app/models/location_block.rb index 9dc28ab..ec6ea26 100644 --- a/app/models/location_block.rb +++ b/app/models/location_block.rb @@ -15,9 +15,8 @@ class LocationBlock < Block def content(args={}) block = self - profile = self.owner proc do - render :file => 'blocks/location', :locals => {:block => block, :profile => profile} + render :file => 'blocks/location', :locals => {:block => block} end end diff --git a/app/models/my_network_block.rb b/app/models/my_network_block.rb index 182824d..e0e9459 100644 --- a/app/models/my_network_block.rb +++ b/app/models/my_network_block.rb @@ -17,10 +17,7 @@ class MyNetworkBlock < Block def content(args={}) block = self proc do - render :file => 'blocks/my_network', :locals => { - :title => block.title, - :owner => block.owner - } + render :file => 'blocks/my_network', :locals => { :block => block } end end diff --git a/app/models/products_block.rb b/app/models/products_block.rb index 3e1ad06..1ae7ace 100644 --- a/app/models/products_block.rb +++ b/app/models/products_block.rb @@ -20,19 +20,10 @@ class ProductsBlock < Block end def content(args={}) - block_title(title) + - content_tag( - 'ul', - products.map {|product| - content_tag('li', - link_to( product.name, - product.url, - :style => 'background-image:url(%s)' % product.default_image('minor') - ), - :class => 'product' - ) - }.join - ) + block = self + proc do + render :file => 'blocks/products', :locals => { :block => block } + end end def footer diff --git a/app/models/profile_image_block.rb b/app/models/profile_image_block.rb index 84ddce9..eb461d7 100644 --- a/app/models/profile_image_block.rb +++ b/app/models/profile_image_block.rb @@ -14,12 +14,8 @@ class ProfileImageBlock < Block def content(args={}) block = self - s = show_name - lambda do |object| - render( - :file => 'blocks/profile_image', - :locals => { :block => block, :show_name => s } - ) + proc do + render :file => 'blocks/profile_image', :locals => { :block => block } end end diff --git a/app/models/profile_info_block.rb b/app/models/profile_info_block.rb index 153dba4..724cb38 100644 --- a/app/models/profile_info_block.rb +++ b/app/models/profile_info_block.rb @@ -18,7 +18,7 @@ class ProfileInfoBlock < Block def content(args={}) block = self - lambda do |_| + proc do render :file => 'blocks/profile_info', :locals => { :block => block } end end diff --git a/app/models/profile_search_block.rb b/app/models/profile_search_block.rb index b21a3e6..02adb4e 100644 --- a/app/models/profile_search_block.rb +++ b/app/models/profile_search_block.rb @@ -5,9 +5,9 @@ class ProfileSearchBlock < Block end def content(args={}) - title = self.title - lambda do |_| - render :file => 'blocks/profile_search', :locals => { :title => title } + block = self + proc do + render :file => 'blocks/profile_search', :locals => { :block => block } end end diff --git a/app/models/raw_html_block.rb b/app/models/raw_html_block.rb index 09d4f60..7060f77 100644 --- a/app/models/raw_html_block.rb +++ b/app/models/raw_html_block.rb @@ -13,7 +13,10 @@ class RawHTMLBlock < Block attr_accessible :html def content(args={}) - (title.blank? ? '' : block_title(title)).html_safe + html.to_s.html_safe + block = self + proc do + render :file => 'blocks/raw_html', :locals => { :block => block } + end end def has_macro? diff --git a/app/models/recent_documents_block.rb b/app/models/recent_documents_block.rb index 5749e88..d32a7a3 100644 --- a/app/models/recent_documents_block.rb +++ b/app/models/recent_documents_block.rb @@ -23,11 +23,9 @@ class RecentDocumentsBlock < Block settings_items :limit, :type => :integer, :default => 5 def content(args={}) - docs = self.docs - title = self.title + block = self proc do - block_title(title) + - content_tag('ul', docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) + render :file => 'blocks/recent_documents', :locals => { :block => block } end end diff --git a/app/models/sellers_search_block.rb b/app/models/sellers_search_block.rb index ae98ca6..fee3884 100644 --- a/app/models/sellers_search_block.rb +++ b/app/models/sellers_search_block.rb @@ -23,9 +23,9 @@ class SellersSearchBlock < Block end def content(args={}) - title = self.title - lambda do |object| - render :file => 'search/_sellers_form', :locals => { :title => title } + 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 e15df70..d855454 100644 --- a/app/models/slideshow_block.rb +++ b/app/models/slideshow_block.rb @@ -35,18 +35,8 @@ class SlideshowBlock < Block def content(args={}) block = self - if gallery - images = block_images - if shuffle - images = images.shuffle - end - proc do - render :file => 'blocks/slideshow', :locals => { :block => block, :images => images } - end - else - proc do - render :file => 'blocks/slideshow', :locals => { :block => block, :images => nil } - end + proc do + render :file => 'blocks/slideshow', :locals => { :block => block } end end diff --git a/app/views/blocks/link_list.html.erb b/app/views/blocks/link_list.html.erb new file mode 100644 index 0000000..f5ea223 --- /dev/null +++ b/app/views/blocks/link_list.html.erb @@ -0,0 +1,12 @@ +<%= block_title(block.title) %> + + diff --git a/app/views/blocks/location.html.erb b/app/views/blocks/location.html.erb index 98bc8e9..35774b1 100644 --- a/app/views/blocks/location.html.erb +++ b/app/views/blocks/location.html.erb @@ -1,7 +1,7 @@ -<% if profile.lat %> +<% if block.owner.lat %> <%= block_title block.title %>
- +
<% else %> <%= _('This profile has no geographical position registered.') %> diff --git a/app/views/blocks/my_network.html.erb b/app/views/blocks/my_network.html.erb index 1d3a03e..884ea7d 100644 --- a/app/views/blocks/my_network.html.erb +++ b/app/views/blocks/my_network.html.erb @@ -1,13 +1,13 @@ -<%= block_title(title) %> +<%= block_title(block.title) %>
- <%= render_profile_actions owner.class %> + <%= render_profile_actions block.owner.class %>
diff --git a/app/views/blocks/products.html.erb b/app/views/blocks/products.html.erb new file mode 100644 index 0000000..a65dfbf --- /dev/null +++ b/app/views/blocks/products.html.erb @@ -0,0 +1,9 @@ +<%= block_title(block.title) %> + + diff --git a/app/views/blocks/profile_image.html.erb b/app/views/blocks/profile_image.html.erb index 0b76327..5c58a08 100644 --- a/app/views/blocks/profile_image.html.erb +++ b/app/views/blocks/profile_image.html.erb @@ -12,7 +12,7 @@ -<% if show_name %> +<% if block.show_name %>

<%= h block.owner.short_name %>

<% end %> diff --git a/app/views/blocks/profile_search.html.erb b/app/views/blocks/profile_search.html.erb index d597920..9da842c 100644 --- a/app/views/blocks/profile_search.html.erb +++ b/app/views/blocks/profile_search.html.erb @@ -1,3 +1,3 @@ -<%= block_title(title) %> +<%= block_title(block.title) %> <%= render :partial => 'shared/profile_search_form' %> diff --git a/app/views/blocks/raw_html.html.erb b/app/views/blocks/raw_html.html.erb new file mode 100644 index 0000000..87c19cd --- /dev/null +++ b/app/views/blocks/raw_html.html.erb @@ -0,0 +1,3 @@ +<%=h block_title(block.title) %> + +<%=h block.html %> diff --git a/app/views/blocks/recent_documents.html.erb b/app/views/blocks/recent_documents.html.erb new file mode 100644 index 0000000..e45a555 --- /dev/null +++ b/app/views/blocks/recent_documents.html.erb @@ -0,0 +1,7 @@ +<%= block_title(block.title) %> + + diff --git a/app/views/blocks/sellers_search.html.erb b/app/views/blocks/sellers_search.html.erb new file mode 100644 index 0000000..7cdf8ff --- /dev/null +++ b/app/views/blocks/sellers_search.html.erb @@ -0,0 +1,24 @@ +

<%= block.title %>

+ +<%= form_tag({:controller => 'search', :action => 'assets'}, {:method => 'get'}) do %> + +
<%= _('Search in:') %> + + <%= labelled_radio_button _('Enterprises'), 'asset', 'enterprises', true %>
+ <%= labelled_radio_button _('Products'), 'asset', 'products', false %> +
+
+ +
+ <%= select_city(true) %> +
+ +
+ <%= labelled_select(_('Distance:'), 'radius', :first, :last, nil, [15, 30, 50, 100, 150, 200, 300, 400, 500, 1000].map{|n|[n, n.to_s + 'km']}) %> +
+ +
+ <%= submit_button :search, _('Search') %> +
+ +<% end %> diff --git a/app/views/blocks/slideshow.html.erb b/app/views/blocks/slideshow.html.erb index a06396a..7742801 100644 --- a/app/views/blocks/slideshow.html.erb +++ b/app/views/blocks/slideshow.html.erb @@ -1,4 +1,14 @@ +<% + if block.gallery + images = block.block_images + if block.shuffle + images = images.shuffle + end + end +%> + <%= block_title(block.title) %> + <% if images %> <% description = images.any? { |img| !img.abstract.blank? } %>
'> diff --git a/app/views/search/_sellers_form.html.erb b/app/views/search/_sellers_form.html.erb deleted file mode 100644 index 281dd08..0000000 --- a/app/views/search/_sellers_form.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -

<%= title %>

- -<%= form_tag({:controller => 'search', :action => 'assets'}, {:method => 'get'}) do %> - -
<%= _('Search in:') %> - - <%= labelled_radio_button _('Enterprises'), 'asset', 'enterprises', true %>
- <%= labelled_radio_button _('Products'), 'asset', 'products', false %> -
-
- -
- <%= select_city(true) %> -
- -
- <%= labelled_select(_('Distance:'), 'radius', :first, :last, nil, [15, 30, 50, 100, 150, 200, 300, 400, 500, 1000].map{|n|[n, n.to_s + 'km']}) %> -
- -
- <%= submit_button :search, _('Search') %> -
- -<% end %> -- libgit2 0.21.2