Commit b07fd53aab1bd75e8a95ec376a2bfffea8920215

Authored by Leandro Santos
1 parent 436bdb44
Exists in staging and in 1 other branch production

adding discussion block

plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
... ... @@ -47,7 +47,8 @@ class CommentParagraphPlugin < Noosfero::Plugin
47 47 def article_extra_toolbar_buttons(article)
48 48 user = context.send :user
49 49 return [] if !article.comment_paragraph_plugin_enabled? || !article.allow_edit?(user) || article.kind_of?(CommentParagraphPlugin::Discussion)
50   - {
  50 + buttons = [
  51 + {
51 52 :title => article.comment_paragraph_plugin_activated? ? _('Deactivate Comments') : _('Activate Comments'),
52 53 :url => {:controller => 'comment_paragraph_plugin_myprofile', :profile => article.profile.identifier, :action => 'toggle_activation', :id => article.id},
53 54 :icon => :toggle_comment_paragraph
... ... @@ -65,6 +66,12 @@ class CommentParagraphPlugin < Noosfero::Plugin
65 66 [CommentParagraphPlugin::API]
66 67 end
67 68  
  69 + def self.extra_blocks
  70 + {
  71 + CommentParagraphPlugin::DiscussionBlock => {:position => ['1','2','3'] }
  72 + }
  73 + end
  74 +
68 75 def content_types
69 76 [CommentParagraphPlugin::Discussion]
70 77 end
... ...
plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +class CommentParagraphPlugin::DiscussionBlock < Block
  2 +
  3 + settings_items :presentation_mode, :type => String, :default => 'title_only'
  4 + settings_items :total_items, :type => Integer, :default => 5
  5 + settings_items :show_blog_picture, :type => :boolean, :default => false
  6 + settings_items :discussion_status, :type => Integer
  7 +
  8 + attr_accessible :presentation_mode, :total_items, :show_blog_picture, :discussion_status
  9 +
  10 + VALID_CONTENT = ['CommentParagraphPlugin::Discussion']
  11 +
  12 + def self.description
  13 + c_('Discussion Articles')
  14 + end
  15 +
  16 + def help
  17 + _("This block displays all profile's article discussion")
  18 + end
  19 +
  20 + def discussions
  21 +# start_date = nil
  22 +# end_date = nil
  23 +# case self.discussion_status.to_s
  24 +# when '0'
  25 +# start_date > Time.now
  26 +# when '2'
  27 +# end_date < Time.now
  28 +# else
  29 +# start_date < Time.now && end_date > Time.now
  30 +# end
  31 + holder.articles.where(type: VALID_CONTENT).order('created_at DESC').limit(self.total_items)
  32 + end
  33 +
  34 + def holder
  35 + return nil if self.box.nil? || self.box.owner.nil?
  36 + if self.box.owner.kind_of?(Environment)
  37 + return nil if self.box.owner.portal_community.nil?
  38 + self.box.owner.portal_community
  39 + else
  40 + self.box.owner
  41 + end
  42 + end
  43 +
  44 + include DatesHelper
  45 +
  46 + def mode?(attr)
  47 + attr == self.presentation_mode
  48 + end
  49 +
  50 +end
... ...
plugins/comment_paragraph/views/blocks/discussion.html.erb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +<div id="discussion-block">
  2 + <% children = block.discussions %>
  3 + <div class="discussion">
  4 + <%= block_title(block.title.blank? ? c_("Discussions") : block.title, block.subtitle ) %>
  5 + </div>
  6 + <% if block.mode?('title_only') %>
  7 + <div class="discussion-title">
  8 + <ul>
  9 + <% children.each do |item| %>
  10 + <li> <%= link_to(h(item.title), item.url)%></li>
  11 + <% end %>
  12 + </ul>
  13 + </div>
  14 + <% elsif block.mode?('title_and_abstract') %>
  15 + <div class="discussion-abstract">
  16 + <% children.each do |item| %>
  17 + <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2>
  18 + <span class="post-date"><%= show_date(item.published_at, true)%></span>
  19 + <div class="headline"><%=item.lead%></div>
  20 + <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p>
  21 + <% end %>
  22 + </div>
  23 + <% else %>
  24 + <div class="discussion-full">
  25 + <% children.each do |item| %>
  26 + <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2>
  27 + <span class="post-date"><%= show_date(item.published_at, true)%></span>
  28 + <div class="headline"><%=item.body%></div>
  29 + <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p>
  30 + <% end %>
  31 + </div>
  32 + <% end %>
  33 +</div>
... ...
plugins/comment_paragraph/views/box_organizer/comment_paragraph_plugin/_discussion_block.html.erb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +<%=
  2 +labelled_form_field(_('Choose which blog should be displayed'),
  3 + select_tag(
  4 + 'block[discussion_status]',
  5 + options_for_select([[_('Not Openned Discussions'), 0],[_('Available Discussions'), 1], [_('Closed Discussions'),2]], @block.discussion_status)
  6 + )
  7 +)
  8 +%>
  9 +<%=
  10 +labelled_form_field(_('Choose how the content should be displayed'),
  11 + select_tag(
  12 + 'block[presentation_mode]',
  13 + options_for_select(
  14 + {
  15 + _("Title only") => "title_only",
  16 + _("Title and abstract") => "title_and_abstract",
  17 + _("Full content") => "full_content"
  18 + },
  19 + @block.presentation_mode
  20 + )
  21 + )
  22 +)
  23 +%>
  24 +<%= labelled_form_field(_('Choose how many items will be displayed'),
  25 + text_field_tag('block[total_items]',
  26 + @block.total_items, :size => 3, :maxlength => 5)
  27 + )
  28 +%>
... ...
plugins/comment_paragraph/views/environment_design 0 → 120000
... ... @@ -0,0 +1 @@
  1 +box_organizer
0 2 \ No newline at end of file
... ...
plugins/comment_paragraph/views/profile_design 0 → 120000
... ... @@ -0,0 +1 @@
  1 +box_organizer
0 2 \ No newline at end of file
... ...