From d6a51c5a1a66110364f3f488354ceeae52b4c101 Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Mon, 14 Apr 2014 10:44:37 -0300 Subject: [PATCH] #community dashboard - code refactoring --- plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------- plugins/community_hub/lib/community_hub_plugin.rb | 4 ---- plugins/community_hub/lib/community_hub_plugin/hub.rb | 30 ++++++++++++++++++------------ plugins/community_hub/lib/community_hub_plugin/hub_helper.rb | 26 +++++++++++++++++++++++++- plugins/community_hub/public/javascripts/community_hub.js | 352 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- plugins/community_hub/public/style.css | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml | 8 ++++++++ plugins/community_hub/views/community_hub_plugin_public/_banner.rhtml | 3 +++ plugins/community_hub/views/community_hub_plugin_public/_embed.rhtml | 11 +++++++++++ plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/community_hub/views/community_hub_plugin_public/_mediation_comment.rhtml | 6 ++++++ plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml | 13 +++++++++++++ plugins/community_hub/views/community_hub_plugin_public/_post.rhtml | 82 +++++++++++++++++++++++++++++----------------------------------------------------- plugins/community_hub/views/community_hub_plugin_public/_post_form.rhtml | 82 ---------------------------------------------------------------------------------- plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml | 25 +++++++++++++------------ plugins/community_hub/views/content_viewer/hub.rhtml | 103 +++++++++++++++++++++++++++++++------------------------------------------------------------------------ 16 files changed, 511 insertions(+), 574 deletions(-) create mode 100644 plugins/community_hub/views/community_hub_plugin_public/_banner.rhtml create mode 100644 plugins/community_hub/views/community_hub_plugin_public/_embed.rhtml create mode 100644 plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml create mode 100644 plugins/community_hub/views/community_hub_plugin_public/_mediation_comment.rhtml create mode 100644 plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml delete mode 100644 plugins/community_hub/views/community_hub_plugin_public/_post_form.rhtml diff --git a/plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb b/plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb index 870a13b..48b0168 100644 --- a/plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb +++ b/plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb @@ -5,9 +5,67 @@ class CommunityHubPluginPublicController < PublicController layout false + def new_message + article = Article.find(params[:article_id]) + + message_data = {} + message_data.merge!(params[:message]) if params[:message] + + @message = Comment.new(message_data) + @message.author = user if logged_in? + @message.title = message_timestamp + @message.article = article + @message.ip_address = request.remote_ip + @message.user_agent = request.user_agent + @message.referrer = request.referrer + + if @message && @message.save + render :text => {'ok' => true}.to_json, :content_type => 'application/json' + else + render :text => {'ok' => false}.to_json, :content_type => 'application/json' + end + end + + + def new_mediation + profile = Profile.find(params[:profile_id]) + + mediation_data = {} + mediation_data.merge!(params[:article]) if params[:article] + + @mediation = TinyMceArticle.new(mediation_data) + @mediation.profile = profile + @mediation.last_changed_by = user + @mediation.name = mediation_timestamp + @mediation.notify_comments = false + @mediation.type = 'TinyMceArticle' + @mediation.advertise = false + @mediation.save + + if @mediation && @mediation.save + render :text => {'ok' => true}.to_json, :content_type => 'application/json' + else + render :text => {'ok' => false}.to_json, :content_type => 'application/json' + end + end + + + def newer_mediation_comment + latest_id = params[:latest_post] + mediation = params[:mediation] + comments = Comment.find(:all, :conditions => ["id > :id and source_id = :mediation", { + :id => latest_id, + :mediation => mediation + }]) + + render :partial => "mediation_comment", + :collection => comments + end + + def newer_comments latest_post = params[:latest_post] - hub = params[:hub] + hub = Article.find(params[:hub]) posts = Comment.find(:all, :order => "id desc", :conditions => ["id > ?", latest_post]) @@ -20,8 +78,6 @@ class CommunityHubPluginPublicController < PublicController latest_post = 0 end - #raise hub.inspect - render :partial => "post", :collection => posts, :locals => { @@ -34,13 +90,13 @@ class CommunityHubPluginPublicController < PublicController def newer_articles latest_post = params[:latest_post] - hub = params[:hub] + hub = Article.find(params[:hub]) posts = Article.find(:all, :order => "id desc", :conditions => ["id > :id and type = :type and parent_id = :hub", { :id => latest_post, :type => 'TinyMceArticle', - :hub => hub + :hub => hub.id }]) if !posts.empty? @@ -51,7 +107,7 @@ class CommunityHubPluginPublicController < PublicController latest_post = 0 end - render :partial => "post", + render :partial => "mediation", :collection => posts, :locals => { :latest_post => latest_post, @@ -91,31 +147,12 @@ class CommunityHubPluginPublicController < PublicController end - def remove_live_post - - begin - post = Comment.find(params[:id]) - rescue - post = nil - end - - if post && post.destroy - render :text => {'ok' => true}.to_json, :content_type => 'application/json' - else - render :text => {'ok' => false}.to_json, :content_type => 'application/json' - end - - end - - - def promote_live_post + def promote_user + hub = Article.find(params[:hub]) - post_id = params[:id] user_id = params[:user].to_i - hub = Article.find(params[:hub]) - - hub.promoted_users += [user_id] unless hub.promoted_users.include?(user_id) + hub.mediators += [user_id] unless hub.mediators.include?(user_id) if hub && hub.save render :text => {'ok' => true}.to_json, :content_type => 'application/json' @@ -125,54 +162,29 @@ class CommunityHubPluginPublicController < PublicController end - def pin_live_post - - begin - post = Comment.find(params[:id]) - rescue - post = nil - end - - hub = Article.find(params[:hub]) + def pin_message + message = Comment.find(params[:message]) + hub = Article.find(params[:hub]) + community = Profile.find(params[:community]) - hub.pinned_posts += [post.id] unless hub.pinned_posts.include?(post.id) + mediation = make_mediation_from_message(community, hub, message) + mediation.save - if hub && hub.save + if mediation && mediation.save + hub.pinned_messages += [message.id] unless hub.pinned_messages.include?(message.id) + hub.pinned_mediations += [mediation.id] unless hub.pinned_mediations.include?(mediation.id) + hub.save render :text => {'ok' => true}.to_json, :content_type => 'application/json' else render :text => {'ok' => false}.to_json, :content_type => 'application/json' - end - end - + end - # - # to implement.......... - # - def like_live_post - if false - render :text => {'ok' => true}.to_json, :content_type => 'application/json' - else - render :text => {'ok' => false}.to_json, :content_type => 'application/json' - end - end - - - # - # to implement.......... - # - def dislike_live_post - if false - render :text => {'ok' => true}.to_json, :content_type => 'application/json' - else - render :text => {'ok' => false}.to_json, :content_type => 'application/json' - end end protected def posts_to_json(list) - list.map do |item| { 'id' => item.id, 'created_at' => item.created_at, @@ -182,4 +194,44 @@ class CommunityHubPluginPublicController < PublicController end.to_json end + + def make_mediation_from_message(community, hub, message) + begin + mediation = Article.new + + mediation.profile = community + mediation.parent = hub + mediation.name = mediation_timestamp + mediation.body = message.body + mediation.abstract = "" + mediation.last_changed_by = message.author + mediation.type = 'TinyMceArticle' + mediation.display_versions = false + mediation.moderate_comments = false + mediation.translation_of_id = "" + mediation.notify_comments = false + mediation.accept_comments = true + mediation.tag_list = "" + mediation.allow_members_to_edit = false + mediation.display_hits = false + mediation.published = true + mediation.license_id = "" + mediation.category_ids = [] + #mediation.save + rescue + mediation = nil + end + + mediation + end + + + def mediation_timestamp + "hub-mediation-#{(Time.now.to_f * 1000).to_i}" + end + + def message_timestamp + "hub-message-#{(Time.now.to_f * 1000).to_i}" + end + end \ No newline at end of file diff --git a/plugins/community_hub/lib/community_hub_plugin.rb b/plugins/community_hub/lib/community_hub_plugin.rb index 36c815e..d3e6777 100644 --- a/plugins/community_hub/lib/community_hub_plugin.rb +++ b/plugins/community_hub/lib/community_hub_plugin.rb @@ -12,10 +12,6 @@ class CommunityHubPlugin < Noosfero::Plugin true end - def js_files - 'javascripts/community_hub.js' - end - def content_types if context.respond_to?(:params) && context.params types = [] diff --git a/plugins/community_hub/lib/community_hub_plugin/hub.rb b/plugins/community_hub/lib/community_hub_plugin/hub.rb index d021e3c..94f1d45 100644 --- a/plugins/community_hub/lib/community_hub_plugin/hub.rb +++ b/plugins/community_hub/lib/community_hub_plugin/hub.rb @@ -1,14 +1,20 @@ -require File.dirname(__FILE__) + '/../../tweeter_stream/lib/twurl' - +#require File.dirname(__FILE__) + '/../../tweeter_stream/lib/twurl' class CommunityHubPlugin::Hub < Folder settings_items :hashtags_twitter, :type => :string, :default => "" - settings_items :promoted_users, :type => Array, :default => [] - settings_items :pinned_posts, :type => Array, :default => [] + settings_items :twitter_enabled, :type => :boolean, :default => false + settings_items :facebook_enabled, :type => :boolean, :default => false + settings_items :pinned_messages, :type => Array, :default => [] + settings_items :pinned_mediations, :type => Array, :default => [] + settings_items :mediators, :type => Array, :default => [] + + #@@thread_started = false + + before_create do |hub| + hub.mediators = [hub.author.id] + end - @@thread_started = false - def self.icon_name(article = nil) 'community-hub' end @@ -25,13 +31,13 @@ class CommunityHubPlugin::Hub < Folder true end - def self.start_twitter_service(page) +# def self.start_twitter_service(page) - a = Thread.new { - Twurl::Stream.run(page, 'nba', '/root/.twurlrc') - } unless @@thread_started +# a = Thread.new { +# Twurl::Stream.run(page, 'nba', '/root/.twurlrc') +# } unless @@thread_started - @@thread_started = true +# @@thread_started = true # raise page.inspect @@ -44,7 +50,7 @@ class CommunityHubPlugin::Hub < Folder # raise "Pai #{parent.id}".inspect - end +# end def view_page "content_viewer/hub.rhtml" diff --git a/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb b/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb index 002b696..0e78365 100644 --- a/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb +++ b/plugins/community_hub/lib/community_hub_plugin/hub_helper.rb @@ -15,7 +15,31 @@ module CommunityHubPlugin::HubHelper end def mediator?(hub) - false + logged_in? && (hub.author.id == user.id || hub.mediators.include?(user.id)) ? true : false + end + + def promoted?(hub, user_id) + logged_in? && (hub.author.id == user_id || hub.mediators.include?(user_id)) ? true : false + end + + def pinned_message?(hub, message_id) + hub.pinned_messages.include?(message_id) ? true : false + end + + def pinned_mediation?(hub, mediation_id) + hub.pinned_mediations.include?(mediation_id) ? true : false + end + + def post_time(time) + if time + _('%{hour}:%{minutes}') % { :hour => time.hour, :minutes => time.strftime("%M") } + else + '' + end + end + + def embed_code(hub) + "" end end \ No newline at end of file diff --git a/plugins/community_hub/public/javascripts/community_hub.js b/plugins/community_hub/public/javascripts/community_hub.js index b4a8706..59b9272 100644 --- a/plugins/community_hub/public/javascripts/community_hub.js +++ b/plugins/community_hub/public/javascripts/community_hub.js @@ -1,351 +1,193 @@ -var $ = jQuery; var latest_post_id = 0; var oldest_post_id = 0; +function toogle_mediation_comments(mediation) { + jQuery("#mediation-comment-list-" + mediation ).toggle(); + jQuery("#mediation-comment-form-" + mediation ).toggle(); +} + -function hub_open_loading() { +function hub_open_loading(button) { var html = '
' + '' + '
'; - $('.hub .form .submit').after(html); - $('#hub-loading').fadeIn('slow'); + //$('.hub .form .submit').after(html); + jQuery(button).after(html); + jQuery('#hub-loading').fadeIn('slow'); } function hub_close_loading() { - $('#hub-loading').fadeOut('slow', function() { - $('#hub-loading').remove(); + jQuery('#hub-loading').fadeOut('slow', function() { + jQuery('#hub-loading').remove(); }); } -function send_message_for_stream(button) { - - var $button = $(button); - var form = $button.parents("form"); - - hub_open_loading(); +function new_message(button) { + var form = jQuery(button).parents("form"); - $.post(form.attr("action"), form.serialize(), function(data) { - console.log(data); - $("#comment_body").val(''); - hub_close_loading(); + //hub_open_loading(); + jQuery.post(form.attr("action"), form.serialize(), function(data) { + if (data.ok) { + jQuery("#message_body").val(''); + } + //hub_close_loading(); }, 'json'); -} - -function send_post_for_mediation(button) { - var $ = jQuery; - open_loading(DEFAULT_LOADING_MESSAGE); - var $button = $(button); - var form = $button.parents("form"); - $button.addClass('stream-post-button-loading'); - setMediationTimestamp(); - $.post(form.attr("action"), form.serialize(), function(data) { - tinymce.get('article_body').setContent(''); - close_loading(); - $button.removeClass('stream-post-button-loading'); - $button.enable(); - }); -} - -function clearMediationForm(element) { - alert(element); -} -function setMediationTimestamp() { - var now = new Date().getTime(); - var timestamp = 'hub-mediation-' + now.toString(); - $("#article_name").val(timestamp); - console.log('teste!!!!!!!!!!!'); } -function loadPosts(section) { - var url; - var container; +function new_mediation(button) { + var form = jQuery(button).parents("form"); - switch(section) { - case 'live': - url = '/plugin/community_hub/public/newer_comments'; - container = $("#live-posts"); - break; - case 'mediation': - url = '/plugin/community_hub/public/newer_articles'; - container = $("#mediation-posts"); - break; - } - - $.ajax({ - url: url, - success: function(data) { - container.append(data); - }, - error: function(ajax, stat, errorThrown) { - console.log(stat); + //hub_open_loading(); + tinymce.triggerSave(); + jQuery.post(form.attr("action"), form.serialize(), function(data) { + if (data.ok) { + tinymce.get('article_body').setContent(''); } - }); - -} + //hub_close_loading(); + }, 'json'); -function hub() { - //checkNewPosts('live'); - //checkNewPosts('mediation'); } -function checkNewPosts(postType) { - - var url = ''; - var container; - - console.log(postType); - - switch (postType) { - case 'live': - url = '/plugin/community_hub/public/newer_comments'; - container = $("#live-posts"); - break; - case 'mediation': - url = '/plugin/community_hub/public/newer_articles'; - container = $("#mediation-posts"); - break; - } - - var hub_id = $(".hub").attr('id'); - var now = new Date(); - - $.ajax({ - url: url, - type: 'get', - data: { latest_post: latest_post_id, hub: hub_id }, - success: function(data) { - - if (data.trim().length > 0) { - container.prepend(data); - latest_post_id = $(".latest").attr("id"); - - } - else { - console.log('No more live posts!'); - } - - }, - error: function(ajax, stat, errorThrown) { - console.log(stat); - } - }); - -} function toogleAutoScrolling() { - alert($("#auto_scrolling").attr('checked')); + alert(jQuery("#auto_scrolling").attr('checked')); } -function setHubView(role) { - var hub_id = $(".hub").attr('id'); +function promote_user(user_id) { - $.ajax({ - url: '/plugin/community_hub/public/set_hub_view', + var hub_id = jQuery(".hub").attr('id'); + + jQuery.ajax({ + url: '/plugin/community_hub/public/promote_user', type: 'get', - data: { hub: hub_id, role: role }, + dataType: 'json', + data: { user: user_id, hub: hub_id }, success: function(data) { - $(".form").html(data); - console.log( data ); }, error: function(ajax, stat, errorThrown) { - console.log( 'ERRO ao processar requisição!'); + console.log(stat); } }); } -function checkUserLevel() { +function pin_message(post_id) { - var hub_id = $(".hub").attr('id'); + var hub_id = jQuery(".hub").attr('id'); - $.ajax({ - url: '/plugin/community_hub/public/check_user_level', + jQuery.ajax({ + url: '/plugin/community_hub/public/pin_message', type: 'get', dataType: 'json', - data: { hub: hub_id }, - success: function(data) { - - - switch (data.level) { - - case -1: - console.log( 'usuário não logado...' ); - setHubView('guest'); - break; - case 0: - console.log( 'usuário logado, visitante...'); - setHubView('visitor'); - break; - case 1: - console.log( 'usuário logado, mediador...'); - setHubView('mediator'); - break; - } - - + data: { id: post_id, hub: hub_id }, + success: function(data) { }, error: function(ajax, stat, errorThrown) { - console.log( 'ERRO ao processar requisição!'); + console.log(stat); } }); } -$(document).ready(function(){ - - $("#auto_scrolling").click(function(){ - toogleAutoScrolling(); - }); - - hub(); - - //checkUserLevel(); - - setInterval(checkNewLivePosts, 10000); //10 seconds interval - //setInterval(checkNewMediationPosts, 10000); //10 seconds interval - //setInterval(checkUserLevel, 10000); //10 seconds interval - -}); - - -function checkNewLivePosts() { - checkNewPosts('live'); -} - -function checkNewMediationPosts() { - checkNewPosts('mediation'); -} +function update_mediation_comments(mediation) { + var hub_id = jQuery(".hub").attr('id'); + if (jQuery("#mediation-comment-list-" + mediation + " li").first().length == 0) { + var latest_post_id = 0; + } + else { + var latest_post_id = jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").last().attr('id'); + } -function removeLivePost(post_id) { + //console.log(latest_post_id); - $.ajax({ - url: '/plugin/community_hub/public/remove_live_post', + jQuery.ajax({ + url: '/plugin/community_hub/public/newer_mediation_comment', type: 'get', - dataType: 'json', - data: { id: post_id }, + data: { latest_post: latest_post_id, mediation: mediation }, success: function(data) { - - if (data.ok) { - console.log( 'OK - Post removido!'); - } - else { - console.log( 'NOT OK - Post NÃO removido!'); + if (data.trim().length > 0) { + jQuery("#mediation-comment-list-" + mediation + "").append(data); } - }, error: function(ajax, stat, errorThrown) { - console.log( 'ERRO ao processar requisição!'); + console.log(stat); } }); + setTimeout(function() { update_mediation_comments(mediation); }, 5000); } -function promoteLivePost(post_id, user_id) { +function update_mediations() { + var hub_id = jQuery(".hub").attr('id'); + + if (jQuery("#mediation-posts li").first().length == 0) { + var latest_post_id = 0; + } + else { + var latest_post_id = jQuery("#mediation-posts li").first().attr('id'); + } - var hub_id = $(".hub").attr('id'); + //console.log(latest_post_id); - $.ajax({ - url: '/plugin/community_hub/public/promote_live_post', + jQuery.ajax({ + url: '/plugin/community_hub/public/newer_articles', type: 'get', - dataType: 'json', - data: { id: post_id, user: user_id, hub: hub_id }, + data: { latest_post: latest_post_id, hub: hub_id }, success: function(data) { - - if (data.ok) { - console.log( 'OK - Post promovido!'); - } - else { - console.log( 'NOT OK - Post NÃO promovido!'); + if (data.trim().length > 0) { + jQuery("#mediation-posts").prepend(data); } - }, error: function(ajax, stat, errorThrown) { - console.log( 'ERRO ao processar requisição!'); + console.log(stat); } }); + setTimeout(update_mediations, 10000); } -function pinLivePost(post_id) { - - var hub_id = $(".hub").attr('id'); - - $.ajax({ - url: '/plugin/community_hub/public/pin_live_post', - type: 'get', - dataType: 'json', - data: { id: post_id, hub: hub_id }, - success: function(data) { - if (data.ok) { - console.log( 'OK - Post fixado!'); - } - else { - console.log( 'NOT OK - Post NÃO fixado!'); - } - - }, - error: function(ajax, stat, errorThrown) { - console.log( 'ERRO ao processar requisição!'); - } - }); +function update_live_stream() { + var hub_id = jQuery(".hub").attr('id'); -} + if (jQuery("#live-posts li").first().length == 0) { + var latest_post_id = 0; + } + else { + var latest_post_id = jQuery("#live-posts li").first().attr('id'); + } -function likeLivePost(post_id) { + //console.log(latest_post_id); - $.ajax({ - url: '/plugin/community_hub/public/like_live_post', + jQuery.ajax({ + url: '/plugin/community_hub/public/newer_comments', type: 'get', - dataType: 'json', - data: { id: post_id }, + data: { latest_post: latest_post_id, hub: hub_id }, success: function(data) { - - if (data.ok) { - console.log( 'OK - Post curtido!'); - } - else { - console.log( 'NOT OK - Post NÃO curtido!'); + if (data.trim().length > 0) { + jQuery("#live-posts").prepend(data); } - }, error: function(ajax, stat, errorThrown) { - console.log( 'ERRO ao processar requisição!'); + console.log(stat); } }); + setTimeout(update_live_stream, 5000); } -function dislikeLivePost(post_id) { - - $.ajax({ - url: '/plugin/community_hub/public/dislike_live_post', - type: 'get', - dataType: 'json', - data: { id: post_id }, - success: function(data) { - - if (data.ok) { - console.log( 'OK - Post descurtido!'); - } - else { - console.log( 'NOT OK - Post NÃO descurtido!'); - } - - }, - error: function(ajax, stat, errorThrown) { - console.log( 'ERRO ao processar requisição!'); - } - }); -} \ No newline at end of file +jQuery(document).ready(function() { + setTimeout(update_live_stream, 5000); + setTimeout(update_mediations, 10000); +}); \ No newline at end of file diff --git a/plugins/community_hub/public/style.css b/plugins/community_hub/public/style.css index 29b0d57..ed1cd2f 100644 --- a/plugins/community_hub/public/style.css +++ b/plugins/community_hub/public/style.css @@ -1,5 +1,5 @@ #hub-loading { - margin-top: 18px; + /*margin-top: 18px;*/ float: right; } @@ -31,7 +31,7 @@ font-size: 14px; } -.hub .post{ +.hub .post { border-bottom: 1px solid #ddd !important; background: url("images/hub-time-bg.gif") repeat-y left top #fff; } @@ -59,21 +59,24 @@ width: 70%; } -.hub .mediation-bar{ - display: inline-block; - margin: 10px 0 10px 104px; - width: 70%; +.hub .message .author { + font-weight: bold; +} +.hub .mediation-bar { + display: inline-block; + margin: 10px 0 10px 104px; + width: 70%; } .hub .mediation-bar ul {} .hub .mediation-bar ul li { - display: inline-block; - margin-right: 5px; - overflow: hidden; - text-indent: -1000px; - width: 16px; + display: inline-block; + /*margin-right: 5px;*/ + overflow: hidden; + /*text-indent: -1000px;*/ + width: 16px; } .hub .mediation-bar ul li.likes-dislikes{ @@ -93,14 +96,24 @@ text-indent: -10000px; } -.hub .promote{ +.hub .promote { background: url("images/hub-promote-icon.png") no-repeat center center #fff; } -.hub .pin{ +.hub .promote .not-promoted { + opacity: 0.5; + filter: alpha(opacity=50); +} + +.hub .pin { background: url("images/hub-pin-icon.png") no-repeat center center #fff; } +.hub .pin .not-pinned { + opacity: 0.5; + filter: alpha(opacity=50); +} + .hub .mediation-bar ul li.pin { float: right; } @@ -201,21 +214,56 @@ float: left; width: 49%; } -.hub .settings { - /* border: 1px solid red;*/ -} .hub div.settings { float: right; width: 50%; } -.hub ul.settings li{ +.hub ul.settings li { height: 50px; line-height: 50px; margin-bottom: 10px; - padding: 0 10px; - /* background: url("images/hub-arrow-right.png") no-repeat 90% top #ed8e01;*/ + padding: 0 10px; + background: url("images/hub-arrow-right.png") no-repeat 90% top #ed8e01; +} + +.hub ul.settings span.collapse { + padding-right: 0.5em; + float: right; +} + +.hub div.banner { + width: 50%; + height: 100px; + background-color: #6d6d6d; + float: right; + text-align: center; +} + +.hub div.banner span { + color: white; + font-family: Arial Black, arial, sans-serif; + font-size: large; + font-weight: normal; + margin-top: 35px; + display: block; +} + +.hub div.embed { + margin-top: 10px; + padding: 8px; + width: 48%; + height: 216px; + border: 1px solid #c0c0c0; + float: right; +} + +.hub div.embed textarea.code { + background-color: #f0f0f0; + border: 1px solid #f0f0f0; + height: 195px; + resize: none; } #content .hub ul.settings li a{ diff --git a/plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml b/plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml index 18dbcb7..e89b592 100644 --- a/plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml +++ b/plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml @@ -12,6 +12,14 @@ <%= required labelled_form_field(_('Description'), text_area(:article, 'body', :style => 'width: 99%;')) %> +
+ + <%= check_box(:article, :twitter_enabled) %> <%= _("Turn on TWITTER") %> + <%= labelled_form_field(_('Hashtags (TWITTER)'), text_field(:article, 'hashtags_twitter')) %> +
+ + <%= check_box(:article, :facebook_enabled) %> <%= _("Turn on FACEBOOK") %> + \ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_banner.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_banner.rhtml new file mode 100644 index 0000000..4453ecc --- /dev/null +++ b/plugins/community_hub/views/community_hub_plugin_public/_banner.rhtml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_embed.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_embed.rhtml new file mode 100644 index 0000000..dc69d6a --- /dev/null +++ b/plugins/community_hub/views/community_hub_plugin_public/_embed.rhtml @@ -0,0 +1,11 @@ +<% extend CommunityHubPlugin::HubHelper %> + +
+ Embed / <%= _("Embed") %> + +
\ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml new file mode 100644 index 0000000..42f4896 --- /dev/null +++ b/plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml @@ -0,0 +1,74 @@ +<% extend CommunityHubPlugin::HubHelper %> + +
  • + + + + <% total_mediation_comments = mediation.comments.count %> + + + <%= link_to(_( "#{total_mediation_comments} Comments" ) , '#', + :class => 'display-comment-form', + :id => 'top-post-comment-button', + :onclick => "toogle_mediation_comments(#{mediation.id}); return false;") %> + + + + + + + <% if logged_in? && mediation.accept_comments? %> + + <% end %> + +
  • \ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment.rhtml new file mode 100644 index 0000000..5219927 --- /dev/null +++ b/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment.rhtml @@ -0,0 +1,6 @@ +
  • + +
  • \ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml new file mode 100644 index 0000000..f216bd1 --- /dev/null +++ b/plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml @@ -0,0 +1,13 @@ +<% form_for :message, + :method => 'post', + :url => { + :controller => 'community_hub_plugin_public', + :action => 'new_message', + :article_id => mediation.id + } do |f| %> + <%= f.text_area(:body, + :style => 'width: 97%;', + :rows => 4, + :placeholder => _('Type your comment here')) %> + <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> +<% end %> \ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_post.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_post.rhtml index 370ab20..ca76075 100644 --- a/plugins/community_hub/views/community_hub_plugin_public/_post.rhtml +++ b/plugins/community_hub/views/community_hub_plugin_public/_post.rhtml @@ -1,60 +1,36 @@ <% extend CommunityHubPlugin::HubHelper %> -
  • - -
  • \ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_post_form.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_post_form.rhtml deleted file mode 100644 index 665e68d..0000000 --- a/plugins/community_hub/views/community_hub_plugin_public/_post_form.rhtml +++ /dev/null @@ -1,82 +0,0 @@ - <% if user_role == 'visitor' %> - - <% remote_form_for( :comment, - Comment.new, - :url => { - :profile => hub.profile.identifier, - :controller => 'comment', - :action => 'create', - :id => hub.id - }, - :html => { :class => 'comment_form' } ) do |f| %> - -
    - <%= _("Streaming") %> -
    -
    - <%= f.text_area(:body, - :style => 'width: 99%;', - :placeholder => _('Type your message here')) %> -
    -
    - <%= submit_button('add', _('Post'), :onclick => "send_message_for_stream(this); return false;") %> -
    - - <% end %> - - <% end %> - - <% if user_role == 'mediator' %> - - <%= render :file => 'shared/tiny_mce' %> - - <% category_ids = [] %> - - <% remote_form_for( :article, - TinyMceArticle.new, - :url => { - :profile => profile.identifier, - :controller => 'cms', - :action => 'new', - :type => 'TinyMceArticle', - :success_back_to => "", - :q => "", - :parent_id => hub.id, - :back_to => "" - }, - :before => "tinymce.triggerSave(); setMediationTimestamp()", - :loading => "alert('loading...')", - :complete => "tinymce.get('article_body').setContent('')", - :html => { :class => 'comment_form' } ) do |f| %> - - <%= f.hidden_field :moderate_comments, :value => 0 %> - <%= f.hidden_field :translation_of_id, :value => "" %> - <%= f.hidden_field :notify_comments, :value => 0 %> - <%= f.hidden_field :accept_comments, :value => 1 %> - <%= f.hidden_field :tag_list, :value => "" %> - <%= f.hidden_field :display_versions, :value => 0 %> - <%= f.hidden_field :allow_members_to_edit, :value => 0 %> - <%= f.hidden_field :abstract, :value => "" %> - <%= f.hidden_field :display_hits, :value => 0 %> - <%= f.hidden_field :parent_id, :value => hub.id %> - <%= f.hidden_field :name %> - <%= f.hidden_field :published, :value => true %> - <%= f.hidden_field :license_id, :value => "" %> - <%= hidden_field_tag "article[category_ids][]", "" %> - <%= f.hidden_field :language, :value => "en" %> - -
    -
    - <%= f.text_area(:body, - :style => 'width: 99%;', - :class => 'mceEditor', - :placeholder => _('Type your message for mediation here')) %> -
    -
    - <%= submit_button('add', _('Post'), :onclick => "send_post_for_mediation(this); return false;")%> -
    -
    - - <% end %> - - <% end %> \ No newline at end of file diff --git a/plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml b/plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml index 485a463..4289db2 100644 --- a/plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml +++ b/plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml @@ -1,12 +1,13 @@ - +
    + +
    \ No newline at end of file diff --git a/plugins/community_hub/views/content_viewer/hub.rhtml b/plugins/community_hub/views/content_viewer/hub.rhtml index 44d95cc..dfc54ac 100644 --- a/plugins/community_hub/views/content_viewer/hub.rhtml +++ b/plugins/community_hub/views/content_viewer/hub.rhtml @@ -1,7 +1,5 @@ <% extend CommunityHubPlugin::HubHelper %> -<% CommunityHubPlugin::Hub.start_twitter_service(@page) %> -
    <%= @page.title %> HUB
    @@ -32,78 +30,36 @@
    - <% if !mediator?(@page.id) %> - -
    - -
    - Streaming -
    -
    - -
    -
    - -
    - -
    + <% if !mediator?(@page) %> - <% end %> + <% form_for :message, + :method => 'post', + :url => { + :controller => 'community_hub_plugin_public', + :action => 'new_message', + :article_id => @page.id + } do |f| %> + <%= _("Streaming") %> +
    + <%= f.text_area :body, :style => "width: 99%;", :cols => "38", :rows => "10", :placeholder => _("Type your message here") %> + <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> + <% end %> - <% if mediator?(@page.id) %> + <% else %> <%= render :file => 'shared/tiny_mce' %> - <% category_ids = [] %> - -
    - - - - - - - - - - - - - - - - - - - - - -
    + <% form_for :article, + :method => 'post', + :url => { + :controller => 'community_hub_plugin_public', + :action => 'new_mediation', + :profile_id => profile.id + } do |f| %> + <%= f.hidden_field :parent_id, :value => @page.id %> + <%= f.text_area :body, :style => "width: 100%;", :class => "mceEditor" %> + <%= submit_button('add', _('Post'), :onclick => 'new_mediation(this); return false;') %> + <% end %> <% end %> @@ -111,10 +67,13 @@ <% end %> - <% if logged_in? %> -
    + <% if mediator?(@page) %> <%= render :partial => "community_hub_plugin_public/settings" %> -
    + <% else %> + <%= render :partial => "community_hub_plugin_public/banner" %> + <%= render :partial => "community_hub_plugin_public/embed" %> <% end %>
    + +<%= javascript_include_tag '/plugins/community_hub/javascripts/community_hub.js' %> -- libgit2 0.21.2