Commit 753770b353db3d018fdb554f9cee414f4f590c49

Authored by Weblate
2 parents 95cb82f9 e568ca79

Merge remote-tracking branch 'origin/master'

Showing 92 changed files with 910 additions and 794 deletions   Show diff stats
app/helpers/application_helper.rb
... ... @@ -48,6 +48,8 @@ module ApplicationHelper
48 48  
49 49 include PluginsHelper
50 50  
  51 + include ButtonsHelper
  52 +
51 53 def locale
52 54 (@page && !@page.language.blank?) ? @page.language : FastGettext.locale
53 55 end
... ... @@ -209,52 +211,6 @@ module ApplicationHelper
209 211 result
210 212 end
211 213  
212   - def button(type, label, url, html_options = {})
213   - html_options ||= {}
214   - the_class = 'with-text'
215   - if html_options.has_key?(:class)
216   - the_class << ' ' << html_options[:class]
217   - end
218   - button_without_text type, label, url, html_options.merge(:class => the_class)
219   - end
220   -
221   - def button_without_text(type, label, url, html_options = {})
222   - the_class = "button icon-#{type}"
223   - if html_options.has_key?(:class)
224   - the_class << ' ' << html_options[:class]
225   - end
226   - the_title = html_options[:title] || label
227   - if html_options[:disabled]
228   - content_tag('a', '&nbsp;'+content_tag('span', label), html_options.merge(:class => the_class, :title => the_title))
229   - else
230   - link_to('&nbsp;'+content_tag('span', label), url, html_options.merge(:class => the_class, :title => the_title))
231   - end
232   - end
233   -
234   - def button_to_function(type, label, js_code, html_options = {}, &block)
235   - html_options[:class] = "button with-text" unless html_options[:class]
236   - html_options[:class] << " icon-#{type}"
237   - link_to_function(label, js_code, html_options, &block)
238   - end
239   -
240   - def button_to_function_without_text(type, label, js_code, html_options = {}, &block)
241   - html_options[:class] = "" unless html_options[:class]
242   - html_options[:class] << " button icon-#{type}"
243   - link_to_function(content_tag('span', label), js_code, html_options, &block)
244   - end
245   -
246   - def button_to_remote(type, label, options, html_options = {})
247   - html_options[:class] = "button with-text" unless html_options[:class]
248   - html_options[:class] << " icon-#{type}"
249   - link_to_remote(label, options, html_options)
250   - end
251   -
252   - def button_to_remote_without_text(type, label, options, html_options = {})
253   - html_options[:class] = "" unless html_options[:class]
254   - html_options[:class] << " button icon-#{type}"
255   - link_to_remote(content_tag('span', label), options, html_options.merge(:title => label))
256   - end
257   -
258 214 def icon(icon_name, html_options = {})
259 215 the_class = "button #{icon_name}"
260 216 if html_options.has_key?(:class)
... ... @@ -934,13 +890,6 @@ module ApplicationHelper
934 890 content_for(:head) { stylesheet_link_tag(*args) }
935 891 end
936 892  
937   - def article_to_html(article, options = {})
938   - options.merge!(:page => params[:npage])
939   - content = article.to_html(options)
940   - content = content.kind_of?(Proc) ? self.instance_exec(&content).html_safe : content.html_safe
941   - filter_html(content, article)
942   - end
943   -
944 893 # Please, use link_to by default!
945 894 # This method was created to work around to inexplicable
946 895 # chain of problems when display_short_format was called
... ... @@ -1365,16 +1314,6 @@ module ApplicationHelper
1365 1314 @no_design_blocks = true
1366 1315 end
1367 1316  
1368   - def filter_html(html, source)
1369   - if @plugins && source && source.has_macro?
1370   - html = convert_macro(html, source) unless @plugins.enabled_macros.blank?
1371   - #TODO This parse should be done through the macro infra, but since there
1372   - # are old things that do not support it we are keeping this hot spot.
1373   - html = @plugins.pipeline(:parse_content, html, source).first
1374   - end
1375   - html && html.html_safe
1376   - end
1377   -
1378 1317 def convert_macro(html, source)
1379 1318 doc = Nokogiri::HTML.fragment html
1380 1319 #TODO This way is more efficient but do not support macro inside of
... ...
app/helpers/article_helper.rb
... ... @@ -181,4 +181,21 @@ module ArticleHelper
181 181 end
182 182 end
183 183  
  184 + def filter_html(html, source)
  185 + if @plugins && source && source.has_macro?
  186 + html = convert_macro(html, source) unless @plugins.enabled_macros.blank?
  187 + #TODO This parse should be done through the macro infra, but since there
  188 + # are old things that do not support it we are keeping this hot spot.
  189 + html = @plugins.pipeline(:parse_content, html, source).first
  190 + end
  191 + html && html.html_safe
  192 + end
  193 +
  194 + def article_to_html(article, options = {})
  195 + options.merge!(:page => params[:npage])
  196 + content = article.to_html(options)
  197 + content = content.kind_of?(Proc) ? self.instance_exec(&content).html_safe : content.html_safe
  198 + filter_html(content, article)
  199 + end
  200 +
184 201 end
... ...
app/helpers/boxes_helper.rb
... ... @@ -87,10 +87,30 @@ module BoxesHelper
87 87 box_decorator == DontMoveBlocks
88 88 end
89 89  
90   - def display_block_content(block, person, main_content = nil)
91   - content = block.main? ? wrap_main_content(main_content) : block.content({:person => person})
  90 + def render_block_content(block)
  91 + template_name = block.class.name.underscore.gsub('_block', '')
  92 + template_filename = "#{template_name}.html.erb"
  93 + if File.exists? Rails.root.join('app', 'views', 'blocks', template_filename)
  94 + render :file => "blocks/#{template_name}", :locals => { :block => block }
  95 + else
  96 + nil
  97 + end
  98 + end
  99 +
  100 + def render_block_footer(block)
  101 + template_name = block.class.name.underscore.gsub('_block', '')
  102 + template_filename = "#{template_name}.html.erb"
  103 + if File.exists? Rails.root.join('app', 'views', 'blocks', 'footers', template_filename)
  104 + render :file => "blocks/footers/#{template_name}", :locals => { :block => block }
  105 + else
  106 + nil
  107 + end
  108 + end
  109 +
  110 + def display_block_content(block, main_content = nil)
  111 + content = block.main? ? wrap_main_content(main_content) : render_block_content(block)
92 112 result = extract_block_content(content)
93   - footer_content = extract_block_content(block.footer)
  113 + footer_content = extract_block_content(render_block_footer(block))
94 114 unless footer_content.blank?
95 115 footer_content = content_tag('div', footer_content, :class => 'block-footer-content' )
96 116 end
... ...
app/helpers/buttons_helper.rb 0 → 100644
... ... @@ -0,0 +1,47 @@
  1 +module ButtonsHelper
  2 + def button(type, label, url, html_options = {})
  3 + html_options ||= {}
  4 + the_class = 'with-text'
  5 + if html_options.has_key?(:class)
  6 + the_class << ' ' << html_options[:class]
  7 + end
  8 + button_without_text type, label, url, html_options.merge(:class => the_class)
  9 + end
  10 +
  11 + def button_without_text(type, label, url, html_options = {})
  12 + the_class = "button icon-#{type}"
  13 + if html_options.has_key?(:class)
  14 + the_class << ' ' << html_options[:class]
  15 + end
  16 + the_title = html_options[:title] || label
  17 + if html_options[:disabled]
  18 + content_tag('a', '&nbsp;'+content_tag('span', label), html_options.merge(:class => the_class, :title => the_title))
  19 + else
  20 + link_to('&nbsp;'+content_tag('span', label), url, html_options.merge(:class => the_class, :title => the_title))
  21 + end
  22 + end
  23 +
  24 + def button_to_function(type, label, js_code, html_options = {}, &block)
  25 + html_options[:class] = "button with-text" unless html_options[:class]
  26 + html_options[:class] << " icon-#{type}"
  27 + link_to_function(label, js_code, html_options, &block)
  28 + end
  29 +
  30 + def button_to_function_without_text(type, label, js_code, html_options = {}, &block)
  31 + html_options[:class] = "" unless html_options[:class]
  32 + html_options[:class] << " button icon-#{type}"
  33 + link_to_function(content_tag('span', label), js_code, html_options, &block)
  34 + end
  35 +
  36 + def button_to_remote(type, label, options, html_options = {})
  37 + html_options[:class] = "button with-text" unless html_options[:class]
  38 + html_options[:class] << " icon-#{type}"
  39 + link_to_remote(label, options, html_options)
  40 + end
  41 +
  42 + def button_to_remote_without_text(type, label, options, html_options = {})
  43 + html_options[:class] = "" unless html_options[:class]
  44 + html_options[:class] << " button icon-#{type}"
  45 + link_to_remote(content_tag('span', label), options, html_options.merge(:title => label))
  46 + end
  47 +end
... ...
app/models/article_block.rb
... ... @@ -18,18 +18,6 @@ class ArticleBlock &lt; Block
18 18 _('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.')
19 19 end
20 20  
21   - def content(args={})
22   - block = self
23   - proc do
24   - block_title(block.title) +
25   - (block.article ? article_to_html(FilePresenter.for(block.article),
26   - :gallery_view => false,
27   - :inside_block => block, # For Blogs and folders
28   - :format => block.visualization_format # For Articles and contents
29   - ).html_safe : _('Article not selected yet.'))
30   - end
31   - end
32   -
33 21 def article_id
34 22 self.settings[:article_id]
35 23 end
... ...
app/models/blog.rb
... ... @@ -93,4 +93,20 @@ class Blog &lt; Folder
93 93 posts.where("type != 'RssFeed'").order(:updated_at).limit(limit)
94 94 end
95 95  
  96 + def total_number_of_posts(group_by, year = nil)
  97 + case group_by
  98 + when :by_year
  99 + posts.published.native_translations
  100 + .except(:order)
  101 + .count(:all, :group => 'EXTRACT(YEAR FROM published_at)')
  102 + .sort_by {|year, count| -year.to_i}
  103 + when :by_month
  104 + posts.published.native_translations
  105 + .except(:order)
  106 + .where('EXTRACT(YEAR FROM published_at)=?', year.to_i)
  107 + .group('EXTRACT(MONTH FROM published_at)')
  108 + .count
  109 + .sort_by {|month, count| -month.to_i}
  110 + end
  111 + end
96 112 end
... ...
app/models/blog_archives_block.rb
... ... @@ -21,30 +21,6 @@ class BlogArchivesBlock &lt; Block
21 21 blog_id && owner.blogs.exists?(blog_id) ? owner.blogs.find(blog_id) : owner.blog
22 22 end
23 23  
24   - def visible_posts(person)
25   - #FIXME Performance issues with display_to. Must convert it to a scope.
26   - # Checkout this page for further information: http://noosfero.org/Development/ActionItem2705
27   - blog.posts.published.native_translations #.select {|post| post.display_to?(person)}
28   - end
29   -
30   - def content(args={})
31   - owner_blog = self.blog
32   - return nil unless owner_blog
33   - results = ''
34   - posts = visible_posts(args[:person])
35   - posts.except(:order).count(:all, :group => 'EXTRACT(YEAR FROM published_at)').sort_by {|year, count| -year.to_i}.each do |year, count|
36   - results << content_tag('li', content_tag('strong', "#{year.to_i} (#{count})"))
37   - results << "<ul class='#{year.to_i}-archive'>"
38   - posts.except(:order).where('EXTRACT(YEAR FROM published_at)=?', year.to_i).group('EXTRACT(MONTH FROM published_at)').count.sort_by {|month, count| -month.to_i}.each do |month, count|
39   - results << content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", owner_blog.url.merge(year: year.to_i, month: month.to_i)))
40   - end
41   - results << "</ul>"
42   - end
43   - block_title(title) +
44   - content_tag('ul', results, :class => 'blog-archives') +
45   - content_tag('div', link_to(_('Subscribe RSS Feed'), owner_blog.feed.url), :class => 'subscribe-feed')
46   - end
47   -
48 24 def self.expire_on
49 25 { :profile => [:article], :environment => [:article] }
50 26 end
... ...
app/models/categories_block.rb
... ... @@ -30,13 +30,6 @@ class CategoriesBlock &lt; Block
30 30 Category.top_level_for(self.owner).from_types(self.category_types)
31 31 end
32 32  
33   - def content(args={})
34   - block = self
35   - proc do
36   - render :file => 'blocks/categories', :locals => { :block => block }
37   - end
38   - end
39   -
40 33 def self.expire_on
41 34 { :profile => [], :environment => [:category] }
42 35 end
... ...
app/models/communities_block.rb
... ... @@ -27,15 +27,6 @@ class CommunitiesBlock &lt; ProfileListBlock
27 27 owner.profile_suggestions.of_community.enabled.limit(3).includes(:suggestion)
28 28 end
29 29  
30   - def footer
31   - owner = self.owner
32   - suggestions = self.suggestions
33   - return '' unless owner.kind_of?(Profile) || owner.kind_of?(Environment)
34   - proc do
35   - render :file => 'blocks/communities', :locals => { :owner => owner, :suggestions => suggestions }
36   - end
37   - end
38   -
39 30 def profiles
40 31 owner.communities
41 32 end
... ...
app/models/disabled_enterprise_message_block.rb
... ... @@ -12,13 +12,6 @@ class DisabledEnterpriseMessageBlock &lt; Block
12 12 _('Message')
13 13 end
14 14  
15   - def content(args={})
16   - message = self.owner.environment.message_for_disabled_enterprise || ''
17   - lambda do |_|
18   - render :file => 'blocks/disabled_enterprise_message', :locals => {:message => message}
19   - end
20   - end
21   -
22 15 def editable?(user=nil)
23 16 false
24 17 end
... ...
app/models/enterprises_block.rb
... ... @@ -12,22 +12,6 @@ class EnterprisesBlock &lt; ProfileListBlock
12 12 _('Enterprises')
13 13 end
14 14  
15   - def footer
16   - owner = self.owner
17   - case owner
18   - when Profile
19   - proc do
20   - link_to s_('enterprises|View all'), :profile => owner.identifier, :controller => 'profile', :action => 'enterprises'
21   - end
22   - when Environment
23   - proc do
24   - link_to s_('enterprises|View all'), :controller => 'search', :action => 'assets', :asset => 'enterprises'
25   - end
26   - else
27   - ''
28   - end
29   - end
30   -
31 15 def profiles
32 16 owner.enterprises
33 17 end
... ...
app/models/fans_block.rb
... ... @@ -12,14 +12,6 @@ class FansBlock &lt; ProfileListBlock
12 12 _('This block presents the fans of an enterprise.')
13 13 end
14 14  
15   - def footer
16   - profile = self.owner
17   - proc do
18   - link_to _('View all'), :profile => profile.identifier, :controller =>
19   - 'profile', :action => 'fans'
20   - end
21   - end
22   -
23 15 def profiles
24 16 owner.fans
25 17 end
... ...
app/models/favorite_enterprises_block.rb
... ... @@ -12,14 +12,6 @@ class FavoriteEnterprisesBlock &lt; ProfileListBlock
12 12 _('Favorite Enterprises')
13 13 end
14 14  
15   - def footer
16   - owner = self.owner
17   - return '' unless owner.kind_of?(Person)
18   - proc do
19   - link_to _('enterprises|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'favorite_enterprises'}, :class => 'view-all'
20   - end
21   - end
22   -
23 15 def profiles
24 16 owner.favorite_enterprises
25 17 end
... ...
app/models/featured_products_block.rb
... ... @@ -32,11 +32,4 @@ class FeaturedProductsBlock &lt; Block
32 32 self.owner.highlighted_products_with_image
33 33 end
34 34  
35   - def content(args={})
36   - block = self
37   - proc do
38   - render :file => 'blocks/featured_products', :locals => { :block => block }
39   - end
40   - end
41   -
42 35 end
... ...
app/models/feed_reader_block.rb
... ... @@ -52,24 +52,6 @@ class FeedReaderBlock &lt; Block
52 52 self.feed_title.nil? ? _('Feed Reader') : self.feed_title
53 53 end
54 54  
55   - def formatted_feed_content
56   - if error_message.blank?
57   - "<ul>\n".html_safe +
58   - self.feed_items[0..(limit-1)].map{ |item| "<li><a href='#{item[:link]}'>#{item[:title]}</a></li>" }.join("\n").html_safe +
59   - "</ul>".html_safe
60   - else
61   - "<p>#{error_message}</p>".html_safe
62   - end
63   - end
64   -
65   - def footer
66   - if self.fetched_at.nil? or self.feed_items.empty?
67   - _('Feed content was not loaded yet')
68   - else
69   - _("Updated: %s") % show_date(self.fetched_at)
70   - end
71   - end
72   -
73 55 def add_item(title, link, date, content)
74 56 self.feed_items.unshift( {:title => title, :link => link})
75 57 end
... ... @@ -85,8 +67,4 @@ class FeedReaderBlock &lt; Block
85 67 self.save!
86 68 end
87 69  
88   - def content(args={})
89   - block_title(title) + formatted_feed_content
90   - end
91   -
92 70 end
... ...
app/models/highlights_block.rb
... ... @@ -43,13 +43,6 @@ class HighlightsBlock &lt; Block
43 43 end
44 44 end
45 45  
46   - def content(args={})
47   - block = self
48   - proc do
49   - render :file => 'blocks/highlights', :locals => { :block => block }
50   - end
51   - end
52   -
53 46 def folder_choices
54 47 owner.image_galleries
55 48 end
... ...
app/models/link_list_block.rb
... ... @@ -59,20 +59,6 @@ class LinkListBlock &lt; Block
59 59 _('Link list')
60 60 end
61 61  
62   - def content(args={})
63   - block_title(title) +
64   - content_tag('ul',
65   - links.select{|i| !i[:name].blank? and !i[:address].blank?}.map{|i| content_tag('li', link_html(i))}.join
66   - )
67   - end
68   -
69   - def link_html(link)
70   - klass = 'icon-' + link[:icon] if link[:icon]
71   - sanitize_link(
72   - link_to(link[:name], expand_address(link[:address]), :target => link[:target], :class => klass, :title => link[:title])
73   - )
74   - end
75   -
76 62 def expand_address(address)
77 63 add = if owner.respond_to?(:identifier)
78 64 address.gsub('{profile}', owner.identifier)
... ... @@ -99,8 +85,6 @@ class LinkListBlock &lt; Block
99 85 end
100 86 end
101 87  
102   - private
103   -
104 88 def sanitize_link(text)
105 89 sanitizer = HTML::WhiteListSanitizer.new
106 90 sanitizer.sanitize(text)
... ...
app/models/location_block.rb
... ... @@ -13,12 +13,4 @@ class LocationBlock &lt; Block
13 13 _('Shows where the profile is on the material world.')
14 14 end
15 15  
16   - def content(args={})
17   - block = self
18   - profile = self.owner
19   - proc do
20   - render :file => 'blocks/location', :locals => {:block => block, :profile => profile}
21   - end
22   - end
23   -
24 16 end
... ...
app/models/login_block.rb
... ... @@ -8,12 +8,6 @@ class LoginBlock &lt; Block
8 8 _('This block presents a login/logout block.')
9 9 end
10 10  
11   - def content(args={})
12   - lambda do |context|
13   - render :file => 'blocks/login_block'
14   - end
15   - end
16   -
17 11 def cacheable?
18 12 false
19 13 end
... ...
app/models/main_block.rb
... ... @@ -8,10 +8,6 @@ class MainBlock &lt; Block
8 8 _('This block presents the main content of your pages.')
9 9 end
10 10  
11   - def content(args={})
12   - nil
13   - end
14   -
15 11 def main?
16 12 true
17 13 end
... ...
app/models/my_network_block.rb
... ... @@ -14,16 +14,6 @@ class MyNetworkBlock &lt; Block
14 14 _('This block displays some info about your networking.')
15 15 end
16 16  
17   - def content(args={})
18   - block = self
19   - proc do
20   - render :file => 'blocks/my_network', :locals => {
21   - :title => block.title,
22   - :owner => block.owner
23   - }
24   - end
25   - end
26   -
27 17 def cacheable?
28 18 false
29 19 end
... ...
app/models/product_categories_block.rb
... ... @@ -13,26 +13,6 @@ class ProductCategoriesBlock &lt; Block
13 13 _('Helps to filter the products catalog.')
14 14 end
15 15  
16   - def content(args={})
17   - profile = owner
18   - proc do
19   - if @categories.nil? or @categories.length == 0
20   - categories = ProductCategory.on_level(nil).order(:name)
21   - if @categories and @categories.length == 0
22   - notice = _('There are no sub-categories for %s') % @category.name
23   - end
24   - else
25   - categories = @categories
26   - end
27   - render :file => 'blocks/product_categories',
28   - :locals => {
29   - :profile => profile,
30   - :categories => categories,
31   - :notice => notice
32   - }
33   - end
34   - end
35   -
36 16 DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog'))
37 17  
38 18 def display
... ...
app/models/products_block.rb
... ... @@ -19,26 +19,6 @@ class ProductsBlock &lt; Block
19 19 _('This block presents a list of your products.')
20 20 end
21 21  
22   - def content(args={})
23   - block_title(title) +
24   - content_tag(
25   - 'ul',
26   - products.map {|product|
27   - content_tag('li',
28   - link_to( product.name,
29   - product.url,
30   - :style => 'background-image:url(%s)' % product.default_image('minor')
31   - ),
32   - :class => 'product'
33   - )
34   - }.join
35   - )
36   - end
37   -
38   - def footer
39   - link_to(_('View all products'), owner.public_profile_url.merge(:controller => 'catalog', :action => 'index'))
40   - end
41   -
42 22 settings_items :product_ids, type: Array
43 23 def product_ids=(array)
44 24 self.settings[:product_ids] = array
... ...
app/models/profile_image_block.rb
... ... @@ -12,17 +12,6 @@ class ProfileImageBlock &lt; Block
12 12 _('This block presents the profile image')
13 13 end
14 14  
15   - def content(args={})
16   - block = self
17   - s = show_name
18   - lambda do |object|
19   - render(
20   - :file => 'blocks/profile_image',
21   - :locals => { :block => block, :show_name => s }
22   - )
23   - end
24   - end
25   -
26 15 def cacheable?
27 16 false
28 17 end
... ...
app/models/profile_info_block.rb
... ... @@ -16,13 +16,6 @@ class ProfileInfoBlock &lt; Block
16 16 _('Basic information about <i>%{user}</i>: how long <i>%{user}</i> is part of <i>%{env}</i> and useful links.') % { :user => self.owner.name(), :env => self.owner.environment.name() }
17 17 end
18 18  
19   - def content(args={})
20   - block = self
21   - lambda do |_|
22   - render :file => 'blocks/profile_info', :locals => { :block => block }
23   - end
24   - end
25   -
26 19 def cacheable?
27 20 false
28 21 end
... ...
app/models/profile_list_block.rb
... ... @@ -40,26 +40,6 @@ result = public_profiles.all(:limit =&gt; get_limit, :order =&gt; &#39;profiles.updated_at
40 40 _('Clicking on the people or groups will take you to their home page.')
41 41 end
42 42  
43   - def content(args={})
44   - profiles = self.profile_list
45   - title = self.view_title
46   - nl = "\n"
47   - proc do |context|
48   - count=0
49   - list = profiles.map {|item|
50   - count+=1
51   - send(:profile_image_link, item, :minor )
52   - }.join("\n ")
53   - if list.empty?
54   - list = content_tag 'div', _('None'), :class => 'common-profile-list-block-none'
55   - else
56   - list = content_tag 'ul', nl +' '+ list + nl
57   - end
58   - block_title(title) + nl +
59   - content_tag('div', nl + list + nl + tag('br', :style => 'clear:both'))
60   - end
61   - end
62   -
63 43 def view_title
64 44 title.gsub('{#}', profile_count.to_s)
65 45 end
... ...
app/models/profile_search_block.rb
... ... @@ -4,11 +4,4 @@ class ProfileSearchBlock &lt; Block
4 4 _('Display a form to search the profile')
5 5 end
6 6  
7   - def content(args={})
8   - title = self.title
9   - lambda do |_|
10   - render :file => 'blocks/profile_search', :locals => { :title => title }
11   - end
12   - end
13   -
14 7 end
... ...
app/models/raw_html_block.rb
... ... @@ -12,10 +12,6 @@ class RawHTMLBlock &lt; Block
12 12  
13 13 attr_accessible :html
14 14  
15   - def content(args={})
16   - (title.blank? ? '' : block_title(title)).html_safe + html.to_s.html_safe
17   - end
18   -
19 15 def has_macro?
20 16 true
21 17 end
... ...
app/models/recent_documents_block.rb
... ... @@ -22,24 +22,6 @@ class RecentDocumentsBlock &lt; Block
22 22  
23 23 settings_items :limit, :type => :integer, :default => 5
24 24  
25   - def content(args={})
26   - docs = self.docs
27   - title = self.title
28   - proc do
29   - block_title(title) +
30   - content_tag('ul', docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n"))
31   - end
32   - end
33   -
34   - def footer
35   - return nil unless self.owner.is_a?(Profile)
36   -
37   - profile = self.owner
38   - proc do
39   - link_to _('All content'), :profile => profile.identifier, :controller => 'profile', :action => 'sitemap'
40   - end
41   - end
42   -
43 25 def docs
44 26 self.limit.nil? ? owner.recent_documents(nil, {}, false) : owner.recent_documents(self.get_limit, {}, false)
45 27 end
... ...
app/models/sellers_search_block.rb
... ... @@ -22,10 +22,4 @@ class SellersSearchBlock &lt; Block
22 22 _('This block presents a search engine for products.')
23 23 end
24 24  
25   - def content(args={})
26   - title = self.title
27   - lambda do |object|
28   - render :file => 'search/_sellers_form', :locals => { :title => title }
29   - end
30   - end
31 25 end
... ...
app/models/slideshow_block.rb
... ... @@ -33,23 +33,6 @@ class SlideshowBlock &lt; Block
33 33 gallery.images.reject {|item| item.folder?}
34 34 end
35 35  
36   - def content(args={})
37   - block = self
38   - if gallery
39   - images = block_images
40   - if shuffle
41   - images = images.shuffle
42   - end
43   - proc do
44   - render :file => 'blocks/slideshow', :locals => { :block => block, :images => images }
45   - end
46   - else
47   - proc do
48   - render :file => 'blocks/slideshow', :locals => { :block => block, :images => nil }
49   - end
50   - end
51   - end
52   -
53 36 def folder_choices
54 37 owner.image_galleries
55 38 end
... ...
app/models/tags_block.rb
... ... @@ -28,42 +28,6 @@ class TagsBlock &lt; Block
28 28 Try to add some tags to some articles and you'l see your tag cloud growing.")
29 29 end
30 30  
31   - def content(args={})
32   - is_env = owner.class == Environment
33   - tags = is_env ? owner.tag_counts : owner.article_tags
34   - return '' if tags.empty?
35   -
36   - if limit
37   - tags_tmp = tags.sort_by{ |k,v| -v }[0..(limit-1)]
38   - tags = {}
39   - tags_tmp.map{ |k,v| tags[k] = v }
40   - end
41   -
42   - url = is_env ? {:host=>owner.default_hostname, :controller=>'search', :action => 'tag'} :
43   - owner.public_profile_url.merge(:controller => 'profile', :action => 'content_tagged')
44   - tagname_option = is_env ? :tag : :id
45   -
46   - block_title(title) +
47   - "\n<div class='tag_cloud'>\n".html_safe+
48   - tag_cloud( tags, tagname_option, url, :max_size => 16, :min_size => 9 ) +
49   - "\n</div><!-- end class='tag_cloud' -->\n".html_safe
50   - end
51   -
52   - def footer
53   - if owner.class == Environment
54   - proc do
55   - link_to s_('tags|View all'),
56   - :controller => 'search', :action => 'tags'
57   - end
58   - else
59   - owner_id = owner.identifier
60   - proc do
61   - link_to s_('tags|View all'),
62   - :profile => owner_id, :controller => 'profile', :action => 'tags'
63   - end
64   - end
65   - end
66   -
67 31 def timeout
68 32 15.minutes
69 33 end
... ...
app/views/blocks/article.html.erb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +<%= block_title(block.title) %>
  2 +<% if block.article %>
  3 + <%=
  4 + h(article_to_html(FilePresenter.for(block.article),
  5 + :gallery_view => false,
  6 + :inside_block => block, # For Blogs and folders
  7 + :format => block.visualization_format # For Articles and contents
  8 + ))
  9 + %>
  10 +<% else %>
  11 + <%= _('Article not selected yet.') %>
  12 +<% end %>
... ...
app/views/blocks/blog_archives.html.erb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<% if block.blog %>
  2 + <%= block_title(block.title) %>
  3 +
  4 + <ul class='blog-archives'>
  5 + <% block.blog.total_number_of_posts(:by_year).each do |year, count| %>
  6 + <%= content_tag('li', content_tag('strong', "#{year.to_i} (#{count})")) %>
  7 + <ul class='<%= year.to_i %>-archive'>
  8 + <% block.blog.total_number_of_posts(:by_month, year).each do |month, count| %>
  9 + <%= content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", block.blog.url.merge(year: year.to_i, month: month.to_i))) %>
  10 + <% end %>
  11 + </ul>
  12 + <% end %>
  13 + </ul>
  14 +
  15 + <%= content_tag('div', link_to(_('Subscribe RSS Feed'), block.blog.feed.url), :class => 'subscribe-feed') %>
  16 +<% end %>
... ...
app/views/blocks/communities.html.erb
... ... @@ -1,17 +0,0 @@
1   -<% if owner.kind_of?(Profile) %>
2   - <%= link_to s_('communities|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %>
3   -<% elsif owner.kind_of?(Environment) %>
4   - <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %>
5   -<% end %>
6   -
7   -<% if user && user == profile && suggestions && !suggestions.empty? %>
8   - <div class='suggestions-block common-profile-list-block'>
9   - <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4>
10   - <div class='profiles-suggestions'>
11   - <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %>
12   - </div>
13   - <div class='more-suggestions'>
14   - <%= link_to _('See all suggestions'), profile.communities_suggestions_url %>
15   - </div>
16   - </div>
17   -<% end %>
app/views/blocks/communities.html.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +profile_list.html.erb
0 2 \ No newline at end of file
... ...
app/views/blocks/disabled_enterprise_message.html.erb
  1 +<% message = block.owner.environment.message_for_disabled_enterprise || '' %>
  2 +
1 3 <div id='enterprise-disabled'>
2 4 <%= message %>
3 5 <% if profile.blocked? && user && user.is_admin?(profile.environment) %>
... ...
app/views/blocks/enterprises.html.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +profile_list.html.erb
0 2 \ No newline at end of file
... ...
app/views/blocks/fans.html.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +profile_list.html.erb
0 2 \ No newline at end of file
... ...
app/views/blocks/favorite_enterprises.html.erb 0 → 120000
... ... @@ -0,0 +1 @@
  1 +profile_list.html.erb
0 2 \ No newline at end of file
... ...
app/views/blocks/feed_reader.html.erb 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +<%= block_title(block.title) %>
  2 +
  3 +<%=
  4 + if block.error_message.blank?
  5 + "<ul>\n".html_safe +
  6 + block.feed_items[0..(block.limit-1)].map{ |item| "<li><a href='#{item[:link]}'>#{item[:title]}</a></li>" }.join("\n").html_safe +
  7 + "</ul>".html_safe
  8 + else
  9 + "<p>#{block.error_message}</p>".html_safe
  10 + end
  11 +%>
... ...
app/views/blocks/footers/communities.html.erb 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +<% if block.owner.kind_of?(Profile) || block.owner.kind_of?(Environment) %>
  2 + <% if block.owner.kind_of?(Profile) %>
  3 + <%= link_to s_('communities|View all'), {:profile => block.owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %>
  4 + <% elsif block.owner.kind_of?(Environment) %>
  5 + <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %>
  6 + <% end %>
  7 +
  8 + <% if user && user == profile && block.suggestions && !block.suggestions.empty? %>
  9 + <div class='suggestions-block common-profile-list-block'>
  10 + <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4>
  11 + <div class='profiles-suggestions'>
  12 + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => block.suggestions, :collection => :communities_suggestions, :per_page => 3 } %>
  13 + </div>
  14 + <div class='more-suggestions'>
  15 + <%= link_to _('See all suggestions'), profile.communities_suggestions_url %>
  16 + </div>
  17 + </div>
  18 + <% end %>
  19 +<% end %>
... ...
app/views/blocks/footers/enterprises.html.erb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +<% if block.owner.is_a?(Profile) %>
  2 + <%= link_to s_('enterprises|View all'), :profile => block.owner.identifier, :controller => 'profile', :action => 'enterprises' %>
  3 +<% elsif block.owner.is_a?(Environment) %>
  4 + <%= link_to s_('enterprises|View all'), :controller => 'search', :action => 'assets', :asset => 'enterprises' %>
  5 +<% end %>
... ...
app/views/blocks/footers/fans.html.erb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<%= link_to _('View all'), :profile => block.owner.identifier, :controller => 'profile', :action => 'fans' %>
... ...
app/views/blocks/footers/favorite_enterprises.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<% if block.owner.is_a?(Person) %>
  2 + <%= link_to _('enterprises|View all'), {:profile => block.owner.identifier, :controller => 'profile', :action => 'favorite_enterprises'}, :class => 'view-all' %>
  3 +<% end %>
... ...
app/views/blocks/footers/feed_reader.html.erb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +<% if block.fetched_at.nil? or block.feed_items.empty? %>
  2 + <%= _('Feed content was not loaded yet') %>
  3 +<% else %>
  4 + <%= _("Updated: %s") % show_date(block.fetched_at) %>
  5 +<% end %>
... ...
app/views/blocks/footers/products.html.erb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<%= link_to(_('View all products'), block.owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) %>
... ...
app/views/blocks/footers/recent_documents.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<% if block.owner.is_a?(Profile) %>
  2 + <%= link_to _('All content'), :profile => block.owner.identifier, :controller => 'profile', :action => 'sitemap' %>
  3 +<% end %>
... ...
app/views/blocks/footers/tags.html.erb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +<% if block.owner.is_a?(Environment) %>
  2 + <%= link_to s_('tags|View all'), :controller => 'search', :action => 'tags' %>
  3 +<% else %>
  4 + <%= link_to s_('tags|View all'), :profile => block.owner.identifier, :controller => 'profile', :action => 'tags' %>
  5 +<% end %>
... ...
app/views/blocks/link_list.html.erb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +<%= block_title(block.title) %>
  2 +
  3 +<ul>
  4 + <% block.links.select{|i| !i[:name].blank? and !i[:address].blank?}.each do |link| %>
  5 + <li>
  6 + <%= block.sanitize_link(link_to(link[:name], block.expand_address(link[:address]),
  7 + :target => link[:target],
  8 + :class => (link[:icon] ? "icon-#{link[:icon]}" : ''),
  9 + :title => link[:title])) %>
  10 + </li>
  11 + <% end %>
  12 +</ul>
... ...
app/views/blocks/location.html.erb
1   -<% if profile.lat %>
  1 +<% if block.owner.lat %>
2 2 <%= block_title block.title %>
3 3 <div class='the-localization-map'>
4   - <img src="https://maps.google.com/maps/api/staticmap?center=<%=profile.lat%>,<%=profile.lng%>&zoom=<%=block.zoom%>&size=190x250&maptype=<%=block.map_type%>&markers=<%=profile.lat%>,<%=profile.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 5 </div>
6 6 <% else %>
7 7 <i><%= _('This profile has no geographical position registered.') %></i>
... ...
app/views/blocks/login.html.erb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<% if user.present? %>
  2 + <div class="logged-user-info">
  3 + <h2><%= _('Logged in as %s') % user.identifier %></h2>
  4 + <ul>
  5 + <li><%= _('User since %s/%s') % [user.created_at.month, user.created_at.year] %></li>
  6 + <li><%= link_to _('Homepage'), user.public_profile_url %></li>
  7 + </ul>
  8 + <div class="user-actions">
  9 + <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %>
  10 + </div>
  11 + </div>
  12 +<% else %>
  13 + <div class='not-logged-user'>
  14 + <%= render :file => 'account/login_block' %>
  15 + </div>
  16 +<% end%>
... ...
app/views/blocks/login_block.html.erb
... ... @@ -1,16 +0,0 @@
1   -<% if user.present? %>
2   - <div class="logged-user-info">
3   - <h2><%= _('Logged in as %s') % user.identifier %></h2>
4   - <ul>
5   - <li><%= _('User since %s/%s') % [user.created_at.month, user.created_at.year] %></li>
6   - <li><%= link_to _('Homepage'), user.public_profile_url %></li>
7   - </ul>
8   - <div class="user-actions">
9   - <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %>
10   - </div>
11   - </div>
12   -<% else %>
13   - <div class='not-logged-user'>
14   - <%= render :file => 'account/login_block' %>
15   - </div>
16   -<% end%>
app/views/blocks/my_network.html.erb
1   -<%= block_title(title) %>
  1 +<%= block_title(block.title) %>
2 2  
3 3 <ul>
4   - <li><%= link_to(_('Homepage'), owner.url, :class => 'url') %></li>
5   - <li><%= link_to(_('View profile'), owner.public_profile_url) %></li>
6   - <% if !user.nil? and owner.organization? and user.has_permission?('edit_profile', profile) %>
  4 + <li><%= link_to(_('Homepage'), block.owner.url, :class => 'url') %></li>
  5 + <li><%= link_to(_('View profile'), block.owner.public_profile_url) %></li>
  6 + <% if !user.nil? and block.owner.organization? and user.has_permission?('edit_profile', profile) %>
7 7 <li><%= link_to _('Control panel'), :controller => 'profile_editor', :profile => profile.identifier %></li>
8 8 <% end %>
9 9 </ul>
10 10  
11 11 <div class="my-network-actions">
12   - <%= render_profile_actions owner.class %>
  12 + <%= render_profile_actions block.owner.class %>
13 13 </div>
... ...
app/views/blocks/product_categories.html.erb
1   -<%= link_to _('Catalog start'), profile.catalog_url, :class=>'catalog-home-link' %>
  1 +<%
  2 + if @categories.nil? or @categories.length == 0
  3 + categories = ProductCategory.on_level(nil).order(:name)
  4 + else
  5 + categories = @categories
  6 + end
  7 +%>
  8 +
  9 +<%= link_to _('Catalog start'), block.owner.catalog_url, :class=>'catalog-home-link' %>
2 10 <ul class="catalog-categories-list">
3 11 <% categories.each do |category| %>
4 12 <%= category_with_sub_list(category) %>
5 13 <% end %>
6 14 </ul>
7   -<% if notice %>
8   - <div class="catalog-categories-notice"><%= notice %></div>
  15 +<% if @categories and @categories.length == 0 %>
  16 + <div class="catalog-categories-notice">
  17 + <%= _('There are no sub-categories for %s') % @category.name %>
  18 + </div>
9 19 <% end %>
... ...
app/views/blocks/products.html.erb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +<%= block_title(block.title) %>
  2 +
  3 +<ul>
  4 + <% block.products.each do |product| %>
  5 + <li class='product'>
  6 + <%= link_to(product.name, product.url, :style => 'background-image:url(%s)' % product.default_image('minor')) %>
  7 + </li>
  8 + <% end %>
  9 +</ul>
... ...
app/views/blocks/profile_image.html.erb
... ... @@ -12,7 +12,7 @@
12 12 </div>
13 13 </div>
14