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 53 def newer_mediation_comment
54 54 latest_id = params[:latest_post]
55 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 63 render :partial => "mediation_comment",
62 64 :collection => comments
... ... @@ -67,8 +69,12 @@ class CommunityHubPluginPublicController < PublicController
67 69 latest_post = params[:latest_post]
68 70 hub = Article.find(params[:hub])
69 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 79 if !posts.empty?
74 80 oldest_post = posts.last.id
... ... @@ -93,6 +99,7 @@ class CommunityHubPluginPublicController < PublicController
93 99 hub = Article.find(params[:hub])
94 100 posts = Article.find(:all,
95 101 :order => "id desc",
  102 + :limit => 100,
96 103 :conditions => ["id > :id and type = :type and parent_id = :hub", {
97 104 :id => latest_post,
98 105 :type => 'TinyMceArticle',
... ... @@ -117,13 +124,6 @@ class CommunityHubPluginPublicController < PublicController
117 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 127 def settings
128 128 settings_section = params[:id]
129 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 60 def view_page
61 61 "content_viewer/hub.rhtml"
62 62 end
63   -end
64 63 \ No newline at end of file
  64 +end
... ...
plugins/community_hub/public/javascripts/community_hub.js
1 1 var latest_post_id = 0;
2 2 var oldest_post_id = 0;
  3 +live_scroll_position = 0;
3 4  
4 5 function toogle_mediation_comments(mediation) {
5 6 jQuery("#mediation-comment-list-" + mediation ).toggle();
... ... @@ -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 177 success: function(data) {
177 178 if (data.trim().length > 0) {
178 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 188 error: function(ajax, stat, errorThrown) {
... ... @@ -188,6 +195,10 @@ function update_live_stream() {
188 195  
189 196  
190 197 jQuery(document).ready(function() {
  198 + jQuery("#live-posts").scroll(function() {
  199 + live_scroll_position = jQuery("#live-posts").scrollTop();
  200 + });
  201 +
191 202 setTimeout(update_live_stream, 5000);
192   - setTimeout(update_mediations, 10000);
  203 + setTimeout(update_mediations, 7000);
193 204 });
194 205 \ No newline at end of file
... ...
plugins/community_hub/public/style.css
... ... @@ -32,10 +32,12 @@
32 32 }
33 33  
34 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 41 .hub .time{
40 42 display: inline-block;
41 43 font-size: 8px;
... ... @@ -52,6 +54,12 @@
52 54 margin: 0 10px;
53 55 vertical-align: top;
54 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 65 .hub .message{
... ... @@ -60,7 +68,11 @@
60 68 }
61 69  
62 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 78 .hub .mediation-bar {
... ... @@ -118,6 +130,18 @@
118 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 147 .hub .live {
... ... @@ -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 175 #content .main-block .hub .live h1{
143 176 background-color: #f4f4f4;
144 177 border: 1px solid lightGray
... ... @@ -288,3 +321,8 @@
288 321 .hub .settings .twitter, .hub .settings .facebook, .hub .settings .general {
289 322 /* border: 1px solid red;*/
290 323 }
  324 +
  325 +textarea#message_body {
  326 + width: auto;
  327 + margin-left: 80px;
  328 +}
291 329 \ No newline at end of file
... ...
plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml
... ... @@ -37,7 +37,7 @@
37 37  
38 38 <% total_mediation_comments = mediation.comments.count %>
39 39  
40   - <span>
  40 + <span class="comment-count">
41 41 <%= link_to(_( "#{total_mediation_comments} Comments" ) , '#',
42 42 :class => 'display-comment-form',
43 43 :id => 'top-post-comment-button',
... ...
plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml
... ... @@ -5,8 +5,7 @@
5 5 :action => 'new_message',
6 6 :article_id => mediation.id
7 7 } do |f| %>
8   - <%= f.text_area(:body,
9   - :style => 'width: 97%;',
  8 + <%= f.text_area(:body,
10 9 :rows => 4,
11 10 :placeholder => _('Type your comment here')) %>
12 11 <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %>
... ...
plugins/community_hub/views/community_hub_plugin_public/_post.rhtml
1 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 4 <ul>
5 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 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 18 <li class="mediation-bar">
11 19  
12 20 <ul>
13   -
14 21 <li class="promote">
15 22 <img class="<%= !promoted?(hub, post.author.id) ? "promoted" : "not-promoted" %>" src="/designs/icons/default/outras/16x16/actions/spread.png" />
16 23 </li>
17   - <% end %>
18   -
19   - <% if mediator?(hub) %>
20 24 <li class="pin">
21 25 <% if !pinned_message?(hub, post.id) %>
22 26 <a id="<%= post.id %>" href="#" onclick="pin_message(<%= post.id %>); return false;">
... ... @@ -26,7 +30,6 @@
26 30 <img class="not-pinned" src="/designs/icons/default/outras/16x16/apps/tags.gif" />
27 31 <% end %>
28 32 </li>
29   -
30 33 </ul>
31 34  
32 35 </li>
... ...
plugins/community_hub/views/content_viewer/hub.rhtml
... ... @@ -17,7 +17,7 @@
17 17 </h1>
18 18 <ul id="live-posts">
19 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 21 </div>
22 22  
23 23 <div class="mediation">
... ...