Commit 2880d86d67c941d514e7ad6aaf1943dc9d80554c

Authored by Evandro Junior
1 parent ad3960a3

Merge with Marcelo's code

plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb
... ... @@ -2,33 +2,177 @@ class CommunityHubPluginPublicController < PublicController
2 2  
3 3 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 4  
5   - #layout false
  5 + layout false
  6 +
6 7  
7 8 def newer_comments
8   - posts = Comment.find(:all)
9   - #render :text => posts_to_json(posts), :content_type => 'text/plain'
10   - render :partial => "post", :collection => posts
  9 + latest_post = params[:latest_post]
  10 + hub = params[:hub]
  11 + posts = Comment.find(:all,
  12 + :order => "id desc",
  13 + :conditions => ["id > ?", latest_post])
  14 +
  15 + if !posts.empty?
  16 + oldest_post = posts.last.id
  17 + latest_post = posts.first.id
  18 + else
  19 + oldest_post = 0
  20 + latest_post = 0
  21 + end
  22 +
  23 + #raise hub.inspect
  24 +
  25 + render :partial => "post",
  26 + :collection => posts,
  27 + :locals => {
  28 + :latest_post => latest_post,
  29 + :oldest_post => oldest_post,
  30 + :hub => hub
  31 + }
11 32 end
12 33  
  34 +
  35 + def newer_articles
  36 + latest_post = params[:latest_post]
  37 + hub = params[:hub]
  38 + posts = Article.find(:all,
  39 + :order => "id desc",
  40 + :conditions => ["id > :id and type = :type and parent_id = :hub", {
  41 + :id => latest_post,
  42 + :type => 'TinyMceArticle',
  43 + :hub => hub
  44 + }])
  45 +
  46 + if !posts.empty?
  47 + oldest_post = posts.last.id
  48 + latest_post = posts.first.id
  49 + else
  50 + oldest_post = 0
  51 + latest_post = 0
  52 + end
  53 +
  54 + render :partial => "post",
  55 + :collection => posts,
  56 + :locals => {
  57 + :latest_post => latest_post,
  58 + :oldest_post => oldest_post,
  59 + :hub => hub
  60 + }
  61 + end
  62 +
  63 +
13 64 def more_comments
14 65 @posts = Comment.find(:all)
15 66 render :partial => "post", :collection => @posts
16 67 end
17 68  
18   - def newer_articles
19   - posts = Article.find(:all, :conditions => {:type => 'TinyMceArticle'}, :limit => 3)
20   - render :partial => "post", :collection => posts
21   - end
  69 +
22 70  
23 71 def settings
24 72 settings_section = params[:id]
25   - #raise settings_section.inspect
26 73 render :partial => "settings/twitter", :layout => true
27 74 end
28 75  
  76 +
  77 + def set_hub_view
  78 + hub = Article.find(params[:hub])
  79 + hub_owner = hub.profile
  80 + role = params[:role]
  81 + render :partial => "post_form", :locals => {:hub => hub, :profile => user, :user_role => role}
  82 + end
  83 +
  84 +
  85 + def check_user_level
  86 + if false
  87 + render :text => {'level' => 0}.to_json, :content_type => 'application/json'
  88 + else
  89 + render :text => {'level' => 1}.to_json, :content_type => 'application/json'
  90 + end
  91 + end
  92 +
  93 +
  94 + def remove_live_post
  95 +
  96 + begin
  97 + post = Comment.find(params[:id])
  98 + rescue
  99 + post = nil
  100 + end
  101 +
  102 + if post && post.destroy
  103 + render :text => {'ok' => true}.to_json, :content_type => 'application/json'
  104 + else
  105 + render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  106 + end
  107 +
  108 + end
  109 +
  110 +
  111 + def promote_live_post
  112 +
  113 + post_id = params[:id]
  114 + user_id = params[:user].to_i
  115 +
  116 + hub = Article.find(params[:hub])
  117 +
  118 + hub.promoted_users += [user_id] unless hub.promoted_users.include?(user_id)
  119 +
  120 + if hub && hub.save
  121 + render :text => {'ok' => true}.to_json, :content_type => 'application/json'
  122 + else
  123 + render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  124 + end
  125 + end
  126 +
  127 +
  128 + def pin_live_post
  129 +
  130 + begin
  131 + post = Comment.find(params[:id])
  132 + rescue
  133 + post = nil
  134 + end
  135 +
  136 + hub = Article.find(params[:hub])
  137 +
  138 + hub.pinned_posts += [post.id] unless hub.pinned_posts.include?(post.id)
  139 +
  140 + if hub && hub.save
  141 + render :text => {'ok' => true}.to_json, :content_type => 'application/json'
  142 + else
  143 + render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  144 + end
  145 + end
  146 +
  147 +
  148 + #
  149 + # to implement..........
  150 + #
  151 + def like_live_post
  152 + if false
  153 + render :text => {'ok' => true}.to_json, :content_type => 'application/json'
  154 + else
  155 + render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  156 + end
  157 + end
  158 +
  159 +
  160 + #
  161 + # to implement..........
  162 + #
  163 + def dislike_live_post
  164 + if false
  165 + render :text => {'ok' => true}.to_json, :content_type => 'application/json'
  166 + else
  167 + render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  168 + end
  169 + end
  170 +
  171 +
29 172 protected
30 173  
31 174 def posts_to_json(list)
  175 +
32 176 list.map do |item| {
33 177 'id' => item.id,
34 178 'created_at' => item.created_at,
... ... @@ -38,6 +182,4 @@ class CommunityHubPluginPublicController < PublicController
38 182 end.to_json
39 183 end
40 184  
41   -
42   -
43 185 end
44 186 \ No newline at end of file
... ...
plugins/community_hub/lib/community_hub_plugin/hub.rb
  1 +require File.dirname(__FILE__) + '/../../tweeter_stream/lib/twurl'
  2 +
1 3 class CommunityHubPlugin::Hub < Folder
2 4  
3 5 settings_items :hashtags_twitter, :type => :string, :default => ""
  6 + settings_items :promoted_users, :type => Array, :default => []
  7 + settings_items :pinned_posts, :type => Array, :default => []
4 8  
  9 + def initialize(my_var)
  10 + raise "ola".inspect
  11 + end
  12 +
5 13 def self.icon_name(article = nil)
6 14 'community-hub'
7 15 end
... ...
plugins/community_hub/lib/community_hub_plugin/hub_helper.rb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +module CommunityHubPlugin::HubHelper
  2 +
  3 + def post_css_classes(post_id, latest_post_id, oldest_post_id)
  4 + classes = "post"
  5 +
  6 + if post_id == latest_post_id
  7 + classes += " latest"
  8 + end
  9 +
  10 + if post_id == oldest_post_id
  11 + classes += " oldest"
  12 + end
  13 +
  14 + classes
  15 + end
  16 +
  17 + def mediator?(hub)
  18 + true
  19 + end
  20 +
  21 +end
0 22 \ No newline at end of file
... ...
plugins/community_hub/public/javascripts/community_hub.js
1 1 var $ = jQuery;
  2 +var latest_post_id = 0;
  3 +var oldest_post_id = 0;
  4 +
  5 +
  6 +function hub_open_loading() {
  7 + var html = '<div id="hub-loading">' +
  8 + '<img src="/images/loading-small.gif" />' +
  9 + '</div>';
  10 +
  11 + $('.hub .form .submit').after(html);
  12 + $('#hub-loading').fadeIn('slow');
  13 +}
  14 +
  15 +
  16 +function hub_close_loading() {
  17 + $('#hub-loading').fadeOut('slow', function() {
  18 + $('#hub-loading').remove();
  19 + });
  20 +}
  21 +
2 22  
3 23 function send_message_for_stream(button) {
4   - var $ = jQuery;
5   - open_loading(DEFAULT_LOADING_MESSAGE);
  24 +
6 25 var $button = $(button);
7 26 var form = $button.parents("form");
8   - $button.addClass('stream-post-button-loading');
9   - $.post(form.attr("action"), form.serialize(), function(data) {
10   - if(data.render_target == null) {
11   - }
12   - else if(data.render_target == 'form') {
13   - }
14   - else if($('#' + data.render_target).size() > 0) {
15   - }
16   - else {
17   - form.find("input[type='text']").add('textarea').each(function() {
18   - this.value = '';
19   - });
20   - }
21 27  
22   - close_loading();
23   - $button.removeClass('stream-post-button-loading');
24   - $button.enable();
  28 + hub_open_loading();
  29 +
  30 + $.post(form.attr("action"), form.serialize(), function(data) {
  31 + console.log(data);
  32 + $("#comment_body").val('');
  33 + hub_close_loading();
25 34 }, 'json');
26 35 }
27 36  
... ... @@ -31,19 +40,9 @@ function send_post_for_mediation(button) {
31 40 var $button = $(button);
32 41 var form = $button.parents("form");
33 42 $button.addClass('stream-post-button-loading');
  43 + setMediationTimestamp();
34 44 $.post(form.attr("action"), form.serialize(), function(data) {
35   - if(data.render_target == null) {
36   - }
37   - else if(data.render_target == 'form') {
38   - }
39   - else if($('#' + data.render_target).size() > 0) {
40   - }
41   - else {
42   - form.find("input[type='text']").add('textarea').each(function() {
43   - this.value = '';
44   - });
45   - }
46   -
  45 + tinymce.get('article_body').setContent('');
47 46 close_loading();
48 47 $button.removeClass('stream-post-button-loading');
49 48 $button.enable();
... ... @@ -57,7 +56,8 @@ function clearMediationForm(element) {
57 56 function setMediationTimestamp() {
58 57 var now = new Date().getTime();
59 58 var timestamp = 'hub-mediation-' + now.toString();
60   - $("article_name").value = timestamp;
  59 + $("#article_name").val(timestamp);
  60 + console.log('teste!!!!!!!!!!!');
61 61 }
62 62  
63 63 function loadPosts(section) {
... ... @@ -89,19 +89,115 @@ function loadPosts(section) {
89 89 }
90 90  
91 91 function hub() {
92   - loadPosts('live');
93   - loadPosts('mediation');
  92 + //checkNewPosts('live');
  93 + //checkNewPosts('mediation');
94 94 }
95 95  
96   -function checkNewPosts() {
97   - var agora = new Date();
98   - console.log( 'checking news posts...' );
  96 +function checkNewPosts(postType) {
  97 +
  98 + var url = '';
  99 + var container;
  100 +
  101 + console.log(postType);
  102 +
  103 + switch (postType) {
  104 + case 'live':
  105 + url = '/plugin/community_hub/public/newer_comments';
  106 + container = $("#live-posts");
  107 + break;
  108 + case 'mediation':
  109 + url = '/plugin/community_hub/public/newer_articles';
  110 + container = $("#mediation-posts");
  111 + break;
  112 + }
  113 +
  114 + var hub_id = $(".hub").attr('id');
  115 + var now = new Date();
  116 +
  117 + $.ajax({
  118 + url: url,
  119 + type: 'get',
  120 + data: { latest_post: latest_post_id, hub: hub_id },
  121 + success: function(data) {
  122 +
  123 + if (data.trim().length > 0) {
  124 + container.prepend(data);
  125 + latest_post_id = $(".latest").attr("id");
  126 +
  127 + }
  128 + else {
  129 + console.log('No more live posts!');
  130 + }
  131 +
  132 + },
  133 + error: function(ajax, stat, errorThrown) {
  134 + console.log(stat);
  135 + }
  136 + });
  137 +
99 138 }
100 139  
101 140 function toogleAutoScrolling() {
102 141 alert($("#auto_scrolling").attr('checked'));
103 142 }
104 143  
  144 +function setHubView(role) {
  145 +
  146 + var hub_id = $(".hub").attr('id');
  147 +
  148 + $.ajax({
  149 + url: '/plugin/community_hub/public/set_hub_view',
  150 + type: 'get',
  151 + data: { hub: hub_id, role: role },
  152 + success: function(data) {
  153 + $(".form").html(data);
  154 + console.log( data );
  155 + },
  156 + error: function(ajax, stat, errorThrown) {
  157 + console.log( 'ERRO ao processar requisição!');
  158 + }
  159 + });
  160 +
  161 +}
  162 +
  163 +
  164 +function checkUserLevel() {
  165 +
  166 + var hub_id = $(".hub").attr('id');
  167 +
  168 + $.ajax({
  169 + url: '/plugin/community_hub/public/check_user_level',
  170 + type: 'get',
  171 + dataType: 'json',
  172 + data: { hub: hub_id },
  173 + success: function(data) {
  174 +
  175 +
  176 + switch (data.level) {
  177 +
  178 + case -1:
  179 + console.log( 'usuário não logado...' );
  180 + setHubView('guest');
  181 + break;
  182 + case 0:
  183 + console.log( 'usuário logado, visitante...');
  184 + setHubView('visitor');
  185 + break;
  186 + case 1:
  187 + console.log( 'usuário logado, mediador...');
  188 + setHubView('mediator');
  189 + break;
  190 + }
  191 +
  192 +
  193 + },
  194 + error: function(ajax, stat, errorThrown) {
  195 + console.log( 'ERRO ao processar requisição!');
  196 + }
  197 + });
  198 +
  199 +}
  200 +
105 201 $(document).ready(function(){
106 202  
107 203 $("#auto_scrolling").click(function(){
... ... @@ -109,7 +205,147 @@ $(document).ready(function(){
109 205 });
110 206  
111 207 hub();
112   - checkNewPosts('live');
  208 +
  209 + //checkUserLevel();
  210 +
  211 + //setInterval(checkNewLivePosts, 10000); //10 seconds interval
  212 + setInterval(checkNewMediationPosts, 10000); //10 seconds interval
  213 + //setInterval(checkUserLevel, 10000); //10 seconds interval
113 214  
114 215 });
115 216  
  217 +
  218 +function checkNewLivePosts() {
  219 + checkNewPosts('live');
  220 +}
  221 +
  222 +
  223 +function checkNewMediationPosts() {
  224 + checkNewPosts('mediation');
  225 +}
  226 +
  227 +
  228 +function removeLivePost(post_id) {
  229 +
  230 + $.ajax({
  231 + url: '/plugin/community_hub/public/remove_live_post',
  232 + type: 'get',
  233 + dataType: 'json',
  234 + data: { id: post_id },
  235 + success: function(data) {
  236 +
  237 + if (data.ok) {
  238 + console.log( 'OK - Post removido!');
  239 + }
  240 + else {
  241 + console.log( 'NOT OK - Post NÃO removido!');
  242 + }
  243 +
  244 + },
  245 + error: function(ajax, stat, errorThrown) {
  246 + console.log( 'ERRO ao processar requisição!');
  247 + }
  248 + });
  249 +
  250 +}
  251 +
  252 +
  253 +function promoteLivePost(post_id, user_id) {
  254 +
  255 + var hub_id = $(".hub").attr('id');
  256 +
  257 + $.ajax({
  258 + url: '/plugin/community_hub/public/promote_live_post',
  259 + type: 'get',
  260 + dataType: 'json',
  261 + data: { id: post_id, user: user_id, hub: hub_id },
  262 + success: function(data) {
  263 +
  264 + if (data.ok) {
  265 + console.log( 'OK - Post promovido!');
  266 + }
  267 + else {
  268 + console.log( 'NOT OK - Post NÃO promovido!');
  269 + }
  270 +
  271 + },
  272 + error: function(ajax, stat, errorThrown) {
  273 + console.log( 'ERRO ao processar requisição!');
  274 + }
  275 + });
  276 +
  277 +}
  278 +
  279 +function pinLivePost(post_id) {
  280 +
  281 + var hub_id = $(".hub").attr('id');
  282 +
  283 + $.ajax({
  284 + url: '/plugin/community_hub/public/pin_live_post',
  285 + type: 'get',
  286 + dataType: 'json',
  287 + data: { id: post_id, hub: hub_id },
  288 + success: function(data) {
  289 +
  290 + if (data.ok) {
  291 + console.log( 'OK - Post fixado!');
  292 + }
  293 + else {
  294 + console.log( 'NOT OK - Post NÃO fixado!');
  295 + }
  296 +
  297 + },
  298 + error: function(ajax, stat, errorThrown) {
  299 + console.log( 'ERRO ao processar requisição!');
  300 + }
  301 + });
  302 +
  303 +}
  304 +
  305 +function likeLivePost(post_id) {
  306 +
  307 + $.ajax({
  308 + url: '/plugin/community_hub/public/like_live_post',
  309 + type: 'get',
  310 + dataType: 'json',
  311 + data: { id: post_id },
  312 + success: function(data) {
  313 +
  314 + if (data.ok) {
  315 + console.log( 'OK - Post curtido!');
  316 + }
  317 + else {
  318 + console.log( 'NOT OK - Post NÃO curtido!');
  319 + }
  320 +
  321 + },
  322 + error: function(ajax, stat, errorThrown) {
  323 + console.log( 'ERRO ao processar requisição!');
  324 + }
  325 + });
  326 +
  327 +}
  328 +
  329 +function dislikeLivePost(post_id) {
  330 +
  331 + $.ajax({
  332 + url: '/plugin/community_hub/public/dislike_live_post',
  333 + type: 'get',
  334 + dataType: 'json',
  335 + data: { id: post_id },
  336 + success: function(data) {
  337 +
  338 + if (data.ok) {
  339 + console.log( 'OK - Post descurtido!');
  340 + }
  341 + else {
  342 + console.log( 'NOT OK - Post NÃO descurtido!');
  343 + }
  344 +
  345 + },
  346 + error: function(ajax, stat, errorThrown) {
  347 + console.log( 'ERRO ao processar requisição!');
  348 + }
  349 + });
  350 +
  351 +}
116 352 \ No newline at end of file
... ...
plugins/community_hub/public/style.css
  1 +#hub-loading {
  2 + margin-top: 18px;
  3 + float: right;
  4 +}
  5 +
1 6 .icon-newcommunity-hub,
2 7 .icon-community-hub {
3 8 background-image: url(/plugins/community_hub/icons/community-hub.png)
... ...
plugins/community_hub/tweeter_stream/lib/twurl/newjson.json 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +{
  2 + "name": "root"
  3 +}
... ...
plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb
... ... @@ -13,8 +13,15 @@ module Twurl
13 13  
14 14 def perform_request
15 15 client.perform_request_from_options(options) { |response|
16   - response.read_body { |chunk| parsed = JSON.parse(chunk)
17   - print parsed["text"] + "\n"
  16 + response.read_body { |chunk|
  17 +# print "#{chunk}\n"
  18 + #unless chunk.to_i.length = 0
  19 + begin
  20 + parsed = JSON.parse(chunk)
  21 + print "@#{parsed["user"]["name"]} said: #{parsed["text"]} \n"
  22 + rescue
  23 + end
  24 + #end
18 25 }
19 26 }
20 27 rescue URI::InvalidURIError
... ...
plugins/community_hub/tweeter_stream/lib/twurl/stream.rb
... ... @@ -20,9 +20,7 @@ module Twurl
20 20 Twurl.options.command = 'request' # Not necessary anymore
21 21 Twurl.options.data = {"track"=>tags}
22 22 # Twurl.options.proxy = 'http://161.148.1.167:312' # Use for production mode at SERPRO
23   - if !proxy.nil?
24   - Twurl.options.proxy = proxy
25   - end
  23 + Twurl.options.proxy = proxy unless proxy.nil?
26 24 Twurl.options.trace = false
27 25 Twurl.options.headers = {}
28 26 Twurl.options.subcommands=[]
... ...
plugins/community_hub/tweeter_stream/nbproject/private/private.xml 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
  3 + <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
  4 +</project-private>
... ...
plugins/community_hub/tweeter_stream/noosfero.rb
1 1 #!/usr/bin/env ruby
  2 +require 'rubygems' # if you use RubyGems
  3 +
2 4 require File.dirname(__FILE__) + '/lib/twurl'
3 5  
4   -Twurl::Stream.run('nba', '/root/.twurlrc')
  6 +Twurl::Stream.run('popcorntime,time4popcorn', '/root/.twurlrc')
... ...
plugins/community_hub/views/community_hub_plugin_public/_post.rhtml
1   -<li class="post" style="border:1px solid black;">
  1 +<% extend CommunityHubPlugin::HubHelper %>
  2 +<li id="<%= post.id %>" class="<%=post_css_classes(post.id, latest_post, oldest_post)%>">
2 3  
3   - <ul style="border:1px solid red;">
4   - <li class="time" style="border:1px solid red;">
  4 + <ul>
  5 + <li class="time">
5 6 <%= show_time(post.created_at) %>
6 7 </li>
7   - <li class="avatar" style="border:1px solid red;">
  8 + <li class="avatar">
8 9  
9   - <% if false %>
10   - <%= image_tag(profile_icon(post.author, :minor)) %>
11   - <% end %>
12   -
13   - image
  10 + <%= link_to image_tag(profile_icon(post.author, :minor)),
  11 + post.author.url,
  12 + :class => 'comment-picture1',
  13 + :title => post.author_name
  14 + %>
14 15  
15 16 </li>
16   - <li class="message" style="border:1px solid red;">
  17 + <li class="message">
17 18 <%= txt2html post.body %>
18 19 </li>
19   - <li class="mediation-bar" style="border:1px solid red;">
20 20  
21   - <ul style="border:1px solid red;">
22   - <li class="remove">
23   - <%= link_to 'excluir', :controller => 'community_hub_plugin_public', :action => 'destroy', :id => post.id %>
24   - </li>
  21 + <% if logged_in? %>
  22 +
  23 + <li class="mediation-bar">
  24 +
  25 + <ul>
  26 + <% if mediator?(hub) %>
25 27 <li class="promote">
26   - <%= link_to 'promover', :controller => 'community_hub_plugin_public', :action => 'destroy', :id => post.id %>
  28 + <a id="<%= post.id %>" href="#" onclick="promoteLivePost(<%= post.id %>,<%= user.id %>); return false;">
  29 + <img src="/designs/icons/default/outras/16x16/actions/spread.png" />
  30 + </a>
27 31 </li>
28   - <li class="likes-dislikes">
29   - <%= link_to 'gostei', :controller => 'community_hub_plugin_public', :action => 'destroy', :id => post.id %> | <%= link_to 'não gostei', :controller => 'community_hub_plugin_public', :action => 'destroy', :id => post.id %>
  32 + <% end %>
  33 +
  34 + <li class="like">
  35 + <a id="<%= post.id %>" href="#" onclick="likeLivePost(<%= post.id %>); return false;">
  36 + <img src="/designs/icons/default/outras/16x16/actions/positive-hand.png" />
  37 + </a>
30 38 </li>
  39 + <li class="dislike">
  40 + <a id="<%= post.id %>" href="#" onclick="dislikeLivePost(<%= post.id %>); return false;">
  41 + <img src="/designs/icons/default/outras/16x16/actions/negative-hand.png" />
  42 + </a>
  43 + </li>
  44 +
  45 + <% if mediator?(hub) %>
31 46 <li class="pin">
32   - <%= link_to 'fixar', :controller => 'community_hub_plugin_public', :action => 'destroy', :id => post.id %>
  47 + <a id="<%= post.id %>" href="#" onclick="pinLivePost(<%= post.id %>); return false;">
  48 + <img src="/designs/icons/default/outras/16x16/apps/tags.gif" />
  49 + </a>
33 50 </li>
  51 + <% end %>
  52 +
34 53 </ul>
35 54  
36 55 </li>
  56 +
  57 + <% end %>
37 58 </ul>
38 59  
39 60 </li>
40 61 \ No newline at end of file
... ...
plugins/community_hub/views/community_hub_plugin_public/_post_form.rhtml
1 1 <% if user_role == 'visitor' %>
2 2  
3 3 <% remote_form_for( :comment,
4   - CommunityHubPlugin::HubStreamPost.new,
  4 + Comment.new,
5 5 :url => {
6   - :profile => profile.identifier,
  6 + :profile => hub.profile.identifier,
7 7 :controller => 'comment',
8 8 :action => 'create',
9   - :id => @page.id
  9 + :id => hub.id
10 10 },
11 11 :html => { :class => 'comment_form' } ) do |f| %>
12 12  
... ... @@ -26,7 +26,7 @@
26 26  
27 27 <% end %>
28 28  
29   - <% if user_role == 'admin' %>
  29 + <% if user_role == 'mediator' %>
30 30  
31 31 <%= render :file => 'shared/tiny_mce' %>
32 32  
... ... @@ -41,7 +41,7 @@
41 41 :type => 'TinyMceArticle',
42 42 :success_back_to => "",
43 43 :q => "",
44   - :parent_id => @page.id,
  44 + :parent_id => hub.id,
45 45 :back_to => ""
46 46 },
47 47 :before => "tinymce.triggerSave(); setMediationTimestamp()",
... ... @@ -58,7 +58,7 @@
58 58 <%= f.hidden_field :allow_members_to_edit, :value => 0 %>
59 59 <%= f.hidden_field :abstract, :value => "" %>
60 60 <%= f.hidden_field :display_hits, :value => 0 %>
61   - <%= f.hidden_field :parent_id, :value => @page.id %>
  61 + <%= f.hidden_field :parent_id, :value => hub.id %>
62 62 <%= f.hidden_field :name %>
63 63 <%= f.hidden_field :published, :value => true %>
64 64 <%= f.hidden_field :license_id, :value => "" %>
... ... @@ -73,7 +73,7 @@
73 73 :placeholder => _('Type your message for mediation here')) %>
74 74 </div>
75 75 <div>
76   - <%= submit_button('add', _('Post'))%>
  76 + <%= submit_button('add', _('Post'), :onclick => "send_post_for_mediation(this); return false;")%>
77 77 </div>
78 78 </div>
79 79  
... ...
plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml
... ... @@ -2,10 +2,6 @@
2 2 <li class="twitter">
3 3 <%= link_to _("Twitter settings"), :controller => 'cms', :action => 'edit', :id => @page.id %>
4 4 </li>
5   - <li class="facebook">
6   - <%= link_to _("Facebook settings"), :controller => 'cms', :action => 'edit', :id => @page.id %>
7   - </li>
8   -
9 5 <li class="general">
10 6 <%= link_to _("General settings"), :controller => 'cms', :action => 'edit', :id => @page.id %>
11 7 </li>
... ...
plugins/community_hub/views/content_viewer/hub.rhtml
1   -<!-- HUB -->
2   -<div class="hub">
  1 +<% extend CommunityHubPlugin::HubHelper %>
  2 +
  3 +<%# CommunityHubPlugin::Hub.start_service %>
  4 +
  5 +<div id="<%=@page.id%>" class="hub">
3 6  
4   - <!-- HUB title -->
5 7 <div class="title"><%= @page.title %> HUB</div>
6 8  
7   - <!-- HUB description -->
8 9 <div class="description"><%= @page.body %></div>
9 10  
10 11 <br />
11 12  
12   - <!-- HUB live section -->
13 13 <div class="live">
14 14 <h1>
15 15 <span class="title"><%= @page.title %></span><span class="on-air"><%= _("Live") %></span>
16 16 </h1>
17 17 <ul id="live-posts">
18 18 </ul>
19   - <span><%= check_box_tag 'auto_scrolling', 'yes', true %><%= _("Auto scrolling") %></span>
  19 + <!--span><%= check_box_tag 'auto_scrolling', 'yes', true %><%= _("Auto scrolling") %></span-->
20 20 </div>
21 21  
22   - <br />
23   -
24   - <!-- HUB mediation section -->
25 22 <div class="mediation">
26 23 <h1>
27   - <span class="title"><%= _("Mediation") %><span class="expand">&#43;</span></span>
  24 + <span class="title"><%= _("Mediation") %><span class="expand">&#9660;</span></span>
28 25 </h1>
29 26 <ul id="mediation-posts">
30 27 </ul>
... ... @@ -32,13 +29,93 @@
32 29  
33 30 <br />
34 31  
35   - <!-- HUB post form (guest user) & (admin user) -->
  32 + <% if logged_in? %>
  33 +
36 34 <div class="form">
37   - <%= render :partial => "community_hub_plugin_public/post_form", :locals => {:user_role => 'admin'} %>
  35 +
  36 + <% if !mediator?(@page.id) %>
  37 +
  38 + <form action="/profile/<%=profile.identifier%>/comment/create/<%=@page.id%>"
  39 + class="comment_form"
  40 + method="post">
  41 +
  42 + <div>
  43 + <span>Streaming</span>
  44 + </div>
  45 + <div>
  46 + <textarea cols="38"
  47 + id="comment_body"
  48 + name="comment[body]"
  49 + placeholder="Type your message here"
  50 + rows="10"
  51 + style="width: 99%;"></textarea>
  52 + </div>
  53 + <div>
  54 + <input class="button with-text icon-add submit"
  55 + name="commit"
  56 + onclick="send_message_for_stream(this); return false;"
  57 + type="submit"
  58 + value="Post">
  59 + </div>
  60 +
  61 + </form>
  62 +
  63 + <% end %>
  64 +
  65 + <% if mediator?(@page.id) %>
  66 +
  67 + <%= render :file => 'shared/tiny_mce' %>
  68 +
  69 + <% category_ids = [] %>
  70 +
  71 + <form action="/myprofile/<%=profile.identifier%>/cms/new?back_to=&parent_id=<%=@page.id%>&q=&success_back_to=&type=TinyMceArticle"
  72 + class="comment_form"
  73 + method="post">
  74 +
  75 + <input id="article_moderate_comments" name="article[moderate_comments]" type="hidden" value="0" />
  76 + <input id="article_translation_of_id" name="article[translation_of_id]" type="hidden" value="" />
  77 + <input id="article_notify_comments" name="article[notify_comments]" type="hidden" value="0" />
  78 + <input id="article_accept_comments" name="article[accept_comments]" type="hidden" value="1" />
  79 + <input id="article_tag_list" name="article[tag_list]" type="hidden" value="" />
  80 + <input id="article_display_versions" name="article[display_versions]" type="hidden" value="0" />
  81 + <input id="article_allow_members_to_edit" name="article[allow_members_to_edit]" type="hidden" value="0" />
  82 + <input id="article_abstract" name="article[abstract]" type="hidden" value="" />
  83 + <input id="article_display_hits" name="article[display_hits]" type="hidden" value="0" />
  84 + <input id="article_parent_id" name="article[parent_id]" type="hidden" value="446" />
  85 + <input id="article_name" name="article[name]" type="hidden" />
  86 + <input id="article_published" name="article[published]" type="hidden" value="true" />
  87 + <input id="article_license_id" name="article[license_id]" type="hidden" value="" />
  88 + <input id="article_category_ids_" name="article[category_ids][]" type="hidden" value="" />
  89 + <input id="article_language" name="article[language]" type="hidden" value="en" />
  90 +
  91 + <textarea class="mceEditor"
  92 + cols="40"
  93 + id="article_body"
  94 + name="article[body]"
  95 + placeholder="Type your message for mediation here"
  96 + rows="20"
  97 + style="width: 99%;"
  98 + aria-hidden="true">
  99 + </textarea>
  100 +
  101 + <input class="button with-text icon-add submit"
  102 + name="commit"
  103 + onclick="send_post_for_mediation(this); return false;"
  104 + type="submit"
  105 + value="Post" />
  106 +
  107 + </form>
  108 +
  109 + <% end %>
  110 +
38 111 </div>
39 112  
  113 + <% end %>
  114 +
  115 + <% if logged_in? %>
40 116 <div class="settings">
41 117 <%= render :partial => "community_hub_plugin_public/settings" %>
42 118 </div>
  119 + <% end %>
43 120  
44 121 </div>
45 122 \ No newline at end of file
... ...