Commit 9137af03206f35c389aca13ae55c1c96dc570239

Authored by Evandro Junior
2 parents dc8289e6 4af25348

Merge branch 'AI3074-community_dashboard' of gitlab.com:participa/noosfero into …

…AI3074-community_dashboard
plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb
@@ -53,10 +53,12 @@ class CommunityHubPluginPublicController < PublicController @@ -53,10 +53,12 @@ class CommunityHubPluginPublicController < PublicController
53 def newer_mediation_comment 53 def newer_mediation_comment
54 latest_id = params[:latest_post] 54 latest_id = params[:latest_post]
55 mediation = params[:mediation] 55 mediation = params[:mediation]
56 - comments = Comment.find(:all, :conditions => ["id > :id and source_id = :mediation", {  
57 - :id => latest_id,  
58 - :mediation => mediation  
59 - }]) 56 + comments = Comment.find(:all,
  57 + :limit => 100,
  58 + :conditions => ["id > :id and source_id = :mediation", {
  59 + :id => latest_id,
  60 + :mediation => mediation
  61 + }])
60 62
61 render :partial => "mediation_comment", 63 render :partial => "mediation_comment",
62 :collection => comments 64 :collection => comments
@@ -67,8 +69,12 @@ class CommunityHubPluginPublicController < PublicController @@ -67,8 +69,12 @@ class CommunityHubPluginPublicController < PublicController
67 latest_post = params[:latest_post] 69 latest_post = params[:latest_post]
68 hub = Article.find(params[:hub]) 70 hub = Article.find(params[:hub])
69 posts = Comment.find(:all, 71 posts = Comment.find(:all,
70 - :order => "id desc",  
71 - :conditions => ["id > ?", latest_post]) 72 + :order => "id desc",
  73 + :limit => 100,
  74 + :conditions => ["id > :id and source_id = :hub", {
  75 + :id => latest_post,
  76 + :hub => hub
  77 + }])
72 78
73 if !posts.empty? 79 if !posts.empty?
74 oldest_post = posts.last.id 80 oldest_post = posts.last.id
@@ -93,6 +99,7 @@ class CommunityHubPluginPublicController < PublicController @@ -93,6 +99,7 @@ class CommunityHubPluginPublicController < PublicController
93 hub = Article.find(params[:hub]) 99 hub = Article.find(params[:hub])
94 posts = Article.find(:all, 100 posts = Article.find(:all,
95 :order => "id desc", 101 :order => "id desc",
  102 + :limit => 100,
96 :conditions => ["id > :id and type = :type and parent_id = :hub", { 103 :conditions => ["id > :id and type = :type and parent_id = :hub", {
97 :id => latest_post, 104 :id => latest_post,
98 :type => 'TinyMceArticle', 105 :type => 'TinyMceArticle',
@@ -117,13 +124,6 @@ class CommunityHubPluginPublicController < PublicController @@ -117,13 +124,6 @@ class CommunityHubPluginPublicController < PublicController
117 end 124 end
118 125
119 126
120 - def more_comments  
121 - @posts = Comment.find(:all)  
122 - render :partial => "post", :collection => @posts  
123 - end  
124 -  
125 -  
126 -  
127 def settings 127 def settings
128 settings_section = params[:id] 128 settings_section = params[:id]
129 render :partial => "settings/twitter", :layout => true 129 render :partial => "settings/twitter", :layout => true
plugins/community_hub/lib/community_hub_plugin/hub.rb
@@ -60,4 +60,4 @@ class CommunityHubPlugin::Hub < Folder @@ -60,4 +60,4 @@ class CommunityHubPlugin::Hub < Folder
60 def view_page 60 def view_page
61 "content_viewer/hub.rhtml" 61 "content_viewer/hub.rhtml"
62 end 62 end
63 -end  
64 \ No newline at end of file 63 \ No newline at end of file
  64 +end
plugins/community_hub/public/javascripts/community_hub.js
1 var latest_post_id = 0; 1 var latest_post_id = 0;
2 var oldest_post_id = 0; 2 var oldest_post_id = 0;
  3 +live_scroll_position = 0;
3 4
4 function toogle_mediation_comments(mediation) { 5 function toogle_mediation_comments(mediation) {
5 jQuery("#mediation-comment-list-" + mediation ).toggle(); 6 jQuery("#mediation-comment-list-" + mediation ).toggle();
@@ -153,7 +154,7 @@ function update_mediations() { @@ -153,7 +154,7 @@ function update_mediations() {
153 } 154 }
154 }); 155 });
155 156
156 - setTimeout(update_mediations, 10000); 157 + setTimeout(update_mediations, 7000);
157 } 158 }
158 159
159 160
@@ -176,6 +177,12 @@ function update_live_stream() { @@ -176,6 +177,12 @@ function update_live_stream() {
176 success: function(data) { 177 success: function(data) {
177 if (data.trim().length > 0) { 178 if (data.trim().length > 0) {
178 jQuery("#live-posts").prepend(data); 179 jQuery("#live-posts").prepend(data);
  180 + if (jQuery("#auto_scrolling").attr('checked')) {
  181 + jQuery("#live-posts").scrollTop(0);
  182 + }
  183 + else {
  184 + jQuery("#live-posts").scrollTop(live_scroll_position);
  185 + }
179 } 186 }
180 }, 187 },
181 error: function(ajax, stat, errorThrown) { 188 error: function(ajax, stat, errorThrown) {
@@ -188,6 +195,10 @@ function update_live_stream() { @@ -188,6 +195,10 @@ function update_live_stream() {
188 195
189 196
190 jQuery(document).ready(function() { 197 jQuery(document).ready(function() {
  198 + jQuery("#live-posts").scroll(function() {
  199 + live_scroll_position = jQuery("#live-posts").scrollTop();
  200 + });
  201 +
191 setTimeout(update_live_stream, 5000); 202 setTimeout(update_live_stream, 5000);
192 - setTimeout(update_mediations, 10000); 203 + setTimeout(update_mediations, 7000);
193 }); 204 });
194 \ No newline at end of file 205 \ No newline at end of file
plugins/community_hub/public/style.css
@@ -32,10 +32,12 @@ @@ -32,10 +32,12 @@
32 } 32 }
33 33
34 .hub .post { 34 .hub .post {
35 - border-bottom: 1px solid #ddd !important;  
36 - background: url("images/hub-time-bg.gif") repeat-y left top #fff; 35 + border-bottom: 1px solid #ddd;
  36 + background: url("images/hub-time-bg.gif") repeat-y left top #fff;
  37 + padding: 5px 0;
37 } 38 }
38 39
  40 +
39 .hub .time{ 41 .hub .time{
40 display: inline-block; 42 display: inline-block;
41 font-size: 8px; 43 font-size: 8px;
@@ -52,6 +54,12 @@ @@ -52,6 +54,12 @@
52 margin: 0 10px; 54 margin: 0 10px;
53 vertical-align: top; 55 vertical-align: top;
54 width: 43px; 56 width: 43px;
  57 + text-align: center;
  58 +}
  59 +
  60 +.hub .avatar img{
  61 + max-height: 43px;
  62 + max-width: 43px;
55 } 63 }
56 64
57 .hub .message{ 65 .hub .message{
@@ -60,7 +68,11 @@ @@ -60,7 +68,11 @@
60 } 68 }
61 69
62 .hub .message .author { 70 .hub .message .author {
63 - font-weight: bold; 71 + font-weight: bold;
  72 + float: left;
  73 + display: inline-block;
  74 + line-height: 20px;
  75 + margin-right: 5px;
64 } 76 }
65 77
66 .hub .mediation-bar { 78 .hub .mediation-bar {
@@ -118,6 +130,18 @@ @@ -118,6 +130,18 @@
118 float: right; 130 float: right;
119 } 131 }
120 132
  133 +.hub ul.mediation-comment-list{
  134 + margin-left: 80px;
  135 + display: inline-block;
  136 + padding: 10px 0;
  137 + background-color: #fff;
  138 + margin-bottom: 10px;
  139 +}
  140 +
  141 +.hub ul.mediation-comment-list li{
  142 + padding-left: 10px;
  143 +}
  144 +
121 /**/ 145 /**/
122 146
123 .hub .live { 147 .hub .live {
@@ -139,6 +163,15 @@ @@ -139,6 +163,15 @@
139 } 163 }
140 164
141 165
  166 +.hub #live-posts .post {
  167 + background-color:#fff;
  168 +}
  169 +
  170 +.hub ul#mediation-posts .post{
  171 + background-color:#eee;
  172 + border-color: #fff;
  173 +}
  174 +
142 #content .main-block .hub .live h1{ 175 #content .main-block .hub .live h1{
143 background-color: #f4f4f4; 176 background-color: #f4f4f4;
144 border: 1px solid lightGray 177 border: 1px solid lightGray
@@ -288,3 +321,8 @@ @@ -288,3 +321,8 @@
288 .hub .settings .twitter, .hub .settings .facebook, .hub .settings .general { 321 .hub .settings .twitter, .hub .settings .facebook, .hub .settings .general {
289 /* border: 1px solid red;*/ 322 /* border: 1px solid red;*/
290 } 323 }
  324 +
  325 +textarea#message_body {
  326 + width: auto;
  327 + margin-left: 80px;
  328 +}
291 \ No newline at end of file 329 \ No newline at end of file
plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 37
38 <% total_mediation_comments = mediation.comments.count %> 38 <% total_mediation_comments = mediation.comments.count %>
39 39
40 - <span> 40 + <span class="comment-count">
41 <%= link_to(_( "#{total_mediation_comments} Comments" ) , '#', 41 <%= link_to(_( "#{total_mediation_comments} Comments" ) , '#',
42 :class => 'display-comment-form', 42 :class => 'display-comment-form',
43 :id => 'top-post-comment-button', 43 :id => 'top-post-comment-button',
plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml
@@ -5,8 +5,7 @@ @@ -5,8 +5,7 @@
5 :action => 'new_message', 5 :action => 'new_message',
6 :article_id => mediation.id 6 :article_id => mediation.id
7 } do |f| %> 7 } do |f| %>
8 - <%= f.text_area(:body,  
9 - :style => 'width: 97%;', 8 + <%= f.text_area(:body,
10 :rows => 4, 9 :rows => 4,
11 :placeholder => _('Type your comment here')) %> 10 :placeholder => _('Type your comment here')) %>
12 <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> 11 <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %>
plugins/community_hub/views/community_hub_plugin_public/_post.rhtml
1 <% extend CommunityHubPlugin::HubHelper %> 1 <% extend CommunityHubPlugin::HubHelper %>
2 2
3 -<li id="<%= post.id %>" class="<%=post_css_classes(post.id, latest_post, oldest_post)%>"> 3 +<li id="<%= post.id %>" class="post">
4 <ul> 4 <ul>
5 <li class="time"><%= post_time(post.created_at) %></li> 5 <li class="time"><%= post_time(post.created_at) %></li>
6 - <li class="avatar"><%= image_tag(profile_icon(post.author, :minor)) %></li> 6 + <li class="avatar">
  7 + <% if post.title == 'hub-message-twitter' %>
  8 + <%= image_tag('/designs/themes/default/images/logo_twitter_bird_blue_50x50.png', :alt => "Twitter") %>
  9 + <% elsif post.title == 'hub-message-facebook' %>
  10 + <%= image_tag('/designs/themes/default/images/logo-facebook-50x50.png', :alt => "Facebook") %>
  11 + <% else %>
  12 + <%= image_tag(profile_icon(post.author, :minor)) %>
  13 + <% end %>
  14 + </li>
7 <li class="message"><span class="author"><%= post.author_name %>:</span> <%= post.body %></li> 15 <li class="message"><span class="author"><%= post.author_name %>:</span> <%= post.body %></li>
8 16
9 - <% if mediator?(hub) %> 17 + <% if mediator?(hub) && post.title != 'hub-message-twitter' && post.title != 'hub-message-facebook' %>
10 <li class="mediation-bar"> 18 <li class="mediation-bar">
11 19
12 <ul> 20 <ul>
13 -  
14 <li class="promote"> 21 <li class="promote">
15 <img class="<%= !promoted?(hub, post.author.id) ? "promoted" : "not-promoted" %>" src="/designs/icons/default/outras/16x16/actions/spread.png" /> 22 <img class="<%= !promoted?(hub, post.author.id) ? "promoted" : "not-promoted" %>" src="/designs/icons/default/outras/16x16/actions/spread.png" />
16 </li> 23 </li>
17 - <% end %>  
18 -  
19 - <% if mediator?(hub) %>  
20 <li class="pin"> 24 <li class="pin">
21 <% if !pinned_message?(hub, post.id) %> 25 <% if !pinned_message?(hub, post.id) %>
22 <a id="<%= post.id %>" href="#" onclick="pin_message(<%= post.id %>); return false;"> 26 <a id="<%= post.id %>" href="#" onclick="pin_message(<%= post.id %>); return false;">
@@ -26,7 +30,6 @@ @@ -26,7 +30,6 @@
26 <img class="not-pinned" src="/designs/icons/default/outras/16x16/apps/tags.gif" /> 30 <img class="not-pinned" src="/designs/icons/default/outras/16x16/apps/tags.gif" />
27 <% end %> 31 <% end %>
28 </li> 32 </li>
29 -  
30 </ul> 33 </ul>
31 34
32 </li> 35 </li>
plugins/community_hub/views/content_viewer/hub.rhtml
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 </h1> 17 </h1>
18 <ul id="live-posts"> 18 <ul id="live-posts">
19 </ul> 19 </ul>
20 - <!--span><%= check_box_tag 'auto_scrolling', 'yes', true %><%= _("Auto scrolling") %></span--> 20 + <span><%= check_box_tag 'auto_scrolling', 'yes', true %><%= _("Auto scrolling") %></span>
21 </div> 21 </div>
22 22
23 <div class="mediation"> 23 <div class="mediation">