Commit d6a51c5a1a66110364f3f488354ceeae52b4c101
1 parent
271f561a
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
#community dashboard - code refactoring
Showing
16 changed files
with
511 additions
and
574 deletions
Show diff stats
plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb
| ... | ... | @@ -5,9 +5,67 @@ class CommunityHubPluginPublicController < PublicController |
| 5 | 5 | layout false |
| 6 | 6 | |
| 7 | 7 | |
| 8 | + def new_message | |
| 9 | + article = Article.find(params[:article_id]) | |
| 10 | + | |
| 11 | + message_data = {} | |
| 12 | + message_data.merge!(params[:message]) if params[:message] | |
| 13 | + | |
| 14 | + @message = Comment.new(message_data) | |
| 15 | + @message.author = user if logged_in? | |
| 16 | + @message.title = message_timestamp | |
| 17 | + @message.article = article | |
| 18 | + @message.ip_address = request.remote_ip | |
| 19 | + @message.user_agent = request.user_agent | |
| 20 | + @message.referrer = request.referrer | |
| 21 | + | |
| 22 | + if @message && @message.save | |
| 23 | + render :text => {'ok' => true}.to_json, :content_type => 'application/json' | |
| 24 | + else | |
| 25 | + render :text => {'ok' => false}.to_json, :content_type => 'application/json' | |
| 26 | + end | |
| 27 | + end | |
| 28 | + | |
| 29 | + | |
| 30 | + def new_mediation | |
| 31 | + profile = Profile.find(params[:profile_id]) | |
| 32 | + | |
| 33 | + mediation_data = {} | |
| 34 | + mediation_data.merge!(params[:article]) if params[:article] | |
| 35 | + | |
| 36 | + @mediation = TinyMceArticle.new(mediation_data) | |
| 37 | + @mediation.profile = profile | |
| 38 | + @mediation.last_changed_by = user | |
| 39 | + @mediation.name = mediation_timestamp | |
| 40 | + @mediation.notify_comments = false | |
| 41 | + @mediation.type = 'TinyMceArticle' | |
| 42 | + @mediation.advertise = false | |
| 43 | + @mediation.save | |
| 44 | + | |
| 45 | + if @mediation && @mediation.save | |
| 46 | + render :text => {'ok' => true}.to_json, :content_type => 'application/json' | |
| 47 | + else | |
| 48 | + render :text => {'ok' => false}.to_json, :content_type => 'application/json' | |
| 49 | + end | |
| 50 | + end | |
| 51 | + | |
| 52 | + | |
| 53 | + def newer_mediation_comment | |
| 54 | + latest_id = params[:latest_post] | |
| 55 | + mediation = params[:mediation] | |
| 56 | + comments = Comment.find(:all, :conditions => ["id > :id and source_id = :mediation", { | |
| 57 | + :id => latest_id, | |
| 58 | + :mediation => mediation | |
| 59 | + }]) | |
| 60 | + | |
| 61 | + render :partial => "mediation_comment", | |
| 62 | + :collection => comments | |
| 63 | + end | |
| 64 | + | |
| 65 | + | |
| 8 | 66 | def newer_comments |
| 9 | 67 | latest_post = params[:latest_post] |
| 10 | - hub = params[:hub] | |
| 68 | + hub = Article.find(params[:hub]) | |
| 11 | 69 | posts = Comment.find(:all, |
| 12 | 70 | :order => "id desc", |
| 13 | 71 | :conditions => ["id > ?", latest_post]) |
| ... | ... | @@ -20,8 +78,6 @@ class CommunityHubPluginPublicController < PublicController |
| 20 | 78 | latest_post = 0 |
| 21 | 79 | end |
| 22 | 80 | |
| 23 | - #raise hub.inspect | |
| 24 | - | |
| 25 | 81 | render :partial => "post", |
| 26 | 82 | :collection => posts, |
| 27 | 83 | :locals => { |
| ... | ... | @@ -34,13 +90,13 @@ class CommunityHubPluginPublicController < PublicController |
| 34 | 90 | |
| 35 | 91 | def newer_articles |
| 36 | 92 | latest_post = params[:latest_post] |
| 37 | - hub = params[:hub] | |
| 93 | + hub = Article.find(params[:hub]) | |
| 38 | 94 | posts = Article.find(:all, |
| 39 | 95 | :order => "id desc", |
| 40 | 96 | :conditions => ["id > :id and type = :type and parent_id = :hub", { |
| 41 | 97 | :id => latest_post, |
| 42 | 98 | :type => 'TinyMceArticle', |
| 43 | - :hub => hub | |
| 99 | + :hub => hub.id | |
| 44 | 100 | }]) |
| 45 | 101 | |
| 46 | 102 | if !posts.empty? |
| ... | ... | @@ -51,7 +107,7 @@ class CommunityHubPluginPublicController < PublicController |
| 51 | 107 | latest_post = 0 |
| 52 | 108 | end |
| 53 | 109 | |
| 54 | - render :partial => "post", | |
| 110 | + render :partial => "mediation", | |
| 55 | 111 | :collection => posts, |
| 56 | 112 | :locals => { |
| 57 | 113 | :latest_post => latest_post, |
| ... | ... | @@ -91,31 +147,12 @@ class CommunityHubPluginPublicController < PublicController |
| 91 | 147 | end |
| 92 | 148 | |
| 93 | 149 | |
| 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 | |
| 150 | + def promote_user | |
| 151 | + hub = Article.find(params[:hub]) | |
| 112 | 152 | |
| 113 | - post_id = params[:id] | |
| 114 | 153 | user_id = params[:user].to_i |
| 115 | 154 | |
| 116 | - hub = Article.find(params[:hub]) | |
| 117 | - | |
| 118 | - hub.promoted_users += [user_id] unless hub.promoted_users.include?(user_id) | |
| 155 | + hub.mediators += [user_id] unless hub.mediators.include?(user_id) | |
| 119 | 156 | |
| 120 | 157 | if hub && hub.save |
| 121 | 158 | render :text => {'ok' => true}.to_json, :content_type => 'application/json' |
| ... | ... | @@ -125,54 +162,29 @@ class CommunityHubPluginPublicController < PublicController |
| 125 | 162 | end |
| 126 | 163 | |
| 127 | 164 | |
| 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]) | |
| 165 | + def pin_message | |
| 166 | + message = Comment.find(params[:message]) | |
| 167 | + hub = Article.find(params[:hub]) | |
| 168 | + community = Profile.find(params[:community]) | |
| 137 | 169 | |
| 138 | - hub.pinned_posts += [post.id] unless hub.pinned_posts.include?(post.id) | |
| 170 | + mediation = make_mediation_from_message(community, hub, message) | |
| 171 | + mediation.save | |
| 139 | 172 | |
| 140 | - if hub && hub.save | |
| 173 | + if mediation && mediation.save | |
| 174 | + hub.pinned_messages += [message.id] unless hub.pinned_messages.include?(message.id) | |
| 175 | + hub.pinned_mediations += [mediation.id] unless hub.pinned_mediations.include?(mediation.id) | |
| 176 | + hub.save | |
| 141 | 177 | render :text => {'ok' => true}.to_json, :content_type => 'application/json' |
| 142 | 178 | else |
| 143 | 179 | render :text => {'ok' => false}.to_json, :content_type => 'application/json' |
| 144 | - end | |
| 145 | - end | |
| 146 | - | |
| 180 | + end | |
| 147 | 181 | |
| 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 | 182 | end |
| 170 | 183 | |
| 171 | 184 | |
| 172 | 185 | protected |
| 173 | 186 | |
| 174 | 187 | def posts_to_json(list) |
| 175 | - | |
| 176 | 188 | list.map do |item| { |
| 177 | 189 | 'id' => item.id, |
| 178 | 190 | 'created_at' => item.created_at, |
| ... | ... | @@ -182,4 +194,44 @@ class CommunityHubPluginPublicController < PublicController |
| 182 | 194 | end.to_json |
| 183 | 195 | end |
| 184 | 196 | |
| 197 | + | |
| 198 | + def make_mediation_from_message(community, hub, message) | |
| 199 | + begin | |
| 200 | + mediation = Article.new | |
| 201 | + | |
| 202 | + mediation.profile = community | |
| 203 | + mediation.parent = hub | |
| 204 | + mediation.name = mediation_timestamp | |
| 205 | + mediation.body = message.body | |
| 206 | + mediation.abstract = "" | |
| 207 | + mediation.last_changed_by = message.author | |
| 208 | + mediation.type = 'TinyMceArticle' | |
| 209 | + mediation.display_versions = false | |
| 210 | + mediation.moderate_comments = false | |
| 211 | + mediation.translation_of_id = "" | |
| 212 | + mediation.notify_comments = false | |
| 213 | + mediation.accept_comments = true | |
| 214 | + mediation.tag_list = "" | |
| 215 | + mediation.allow_members_to_edit = false | |
| 216 | + mediation.display_hits = false | |
| 217 | + mediation.published = true | |
| 218 | + mediation.license_id = "" | |
| 219 | + mediation.category_ids = [] | |
| 220 | + #mediation.save | |
| 221 | + rescue | |
| 222 | + mediation = nil | |
| 223 | + end | |
| 224 | + | |
| 225 | + mediation | |
| 226 | + end | |
| 227 | + | |
| 228 | + | |
| 229 | + def mediation_timestamp | |
| 230 | + "hub-mediation-#{(Time.now.to_f * 1000).to_i}" | |
| 231 | + end | |
| 232 | + | |
| 233 | + def message_timestamp | |
| 234 | + "hub-message-#{(Time.now.to_f * 1000).to_i}" | |
| 235 | + end | |
| 236 | + | |
| 185 | 237 | end |
| 186 | 238 | \ No newline at end of file | ... | ... |
plugins/community_hub/lib/community_hub_plugin.rb
plugins/community_hub/lib/community_hub_plugin/hub.rb
| 1 | -require File.dirname(__FILE__) + '/../../tweeter_stream/lib/twurl' | |
| 2 | - | |
| 1 | +#require File.dirname(__FILE__) + '/../../tweeter_stream/lib/twurl' | |
| 3 | 2 | |
| 4 | 3 | class CommunityHubPlugin::Hub < Folder |
| 5 | 4 | |
| 6 | 5 | settings_items :hashtags_twitter, :type => :string, :default => "" |
| 7 | - settings_items :promoted_users, :type => Array, :default => [] | |
| 8 | - settings_items :pinned_posts, :type => Array, :default => [] | |
| 6 | + settings_items :twitter_enabled, :type => :boolean, :default => false | |
| 7 | + settings_items :facebook_enabled, :type => :boolean, :default => false | |
| 8 | + settings_items :pinned_messages, :type => Array, :default => [] | |
| 9 | + settings_items :pinned_mediations, :type => Array, :default => [] | |
| 10 | + settings_items :mediators, :type => Array, :default => [] | |
| 11 | + | |
| 12 | + #@@thread_started = false | |
| 13 | + | |
| 14 | + before_create do |hub| | |
| 15 | + hub.mediators = [hub.author.id] | |
| 16 | + end | |
| 9 | 17 | |
| 10 | - @@thread_started = false | |
| 11 | - | |
| 12 | 18 | def self.icon_name(article = nil) |
| 13 | 19 | 'community-hub' |
| 14 | 20 | end |
| ... | ... | @@ -25,13 +31,13 @@ class CommunityHubPlugin::Hub < Folder |
| 25 | 31 | true |
| 26 | 32 | end |
| 27 | 33 | |
| 28 | - def self.start_twitter_service(page) | |
| 34 | +# def self.start_twitter_service(page) | |
| 29 | 35 | |
| 30 | - a = Thread.new { | |
| 31 | - Twurl::Stream.run(page, 'nba', '/root/.twurlrc') | |
| 32 | - } unless @@thread_started | |
| 36 | +# a = Thread.new { | |
| 37 | +# Twurl::Stream.run(page, 'nba', '/root/.twurlrc') | |
| 38 | +# } unless @@thread_started | |
| 33 | 39 | |
| 34 | - @@thread_started = true | |
| 40 | +# @@thread_started = true | |
| 35 | 41 | |
| 36 | 42 | # raise page.inspect |
| 37 | 43 | |
| ... | ... | @@ -44,7 +50,7 @@ class CommunityHubPlugin::Hub < Folder |
| 44 | 50 | |
| 45 | 51 | # raise "Pai #{parent.id}".inspect |
| 46 | 52 | |
| 47 | - end | |
| 53 | +# end | |
| 48 | 54 | |
| 49 | 55 | def view_page |
| 50 | 56 | "content_viewer/hub.rhtml" | ... | ... |
plugins/community_hub/lib/community_hub_plugin/hub_helper.rb
| ... | ... | @@ -15,7 +15,31 @@ module CommunityHubPlugin::HubHelper |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | def mediator?(hub) |
| 18 | - false | |
| 18 | + logged_in? && (hub.author.id == user.id || hub.mediators.include?(user.id)) ? true : false | |
| 19 | + end | |
| 20 | + | |
| 21 | + def promoted?(hub, user_id) | |
| 22 | + logged_in? && (hub.author.id == user_id || hub.mediators.include?(user_id)) ? true : false | |
| 23 | + end | |
| 24 | + | |
| 25 | + def pinned_message?(hub, message_id) | |
| 26 | + hub.pinned_messages.include?(message_id) ? true : false | |
| 27 | + end | |
| 28 | + | |
| 29 | + def pinned_mediation?(hub, mediation_id) | |
| 30 | + hub.pinned_mediations.include?(mediation_id) ? true : false | |
| 31 | + end | |
| 32 | + | |
| 33 | + def post_time(time) | |
| 34 | + if time | |
| 35 | + _('%{hour}:%{minutes}') % { :hour => time.hour, :minutes => time.strftime("%M") } | |
| 36 | + else | |
| 37 | + '' | |
| 38 | + end | |
| 39 | + end | |
| 40 | + | |
| 41 | + def embed_code(hub) | |
| 42 | + "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='#{url_for(hub.url)}'></iframe>" | |
| 19 | 43 | end |
| 20 | 44 | |
| 21 | 45 | end |
| 22 | 46 | \ No newline at end of file | ... | ... |
plugins/community_hub/public/javascripts/community_hub.js
| 1 | -var $ = jQuery; | |
| 2 | 1 | var latest_post_id = 0; |
| 3 | 2 | var oldest_post_id = 0; |
| 4 | 3 | |
| 4 | +function toogle_mediation_comments(mediation) { | |
| 5 | + jQuery("#mediation-comment-list-" + mediation ).toggle(); | |
| 6 | + jQuery("#mediation-comment-form-" + mediation ).toggle(); | |
| 7 | +} | |
| 8 | + | |
| 5 | 9 | |
| 6 | -function hub_open_loading() { | |
| 10 | +function hub_open_loading(button) { | |
| 7 | 11 | var html = '<div id="hub-loading">' + |
| 8 | 12 | '<img src="/images/loading-small.gif" />' + |
| 9 | 13 | '</div>'; |
| 10 | 14 | |
| 11 | - $('.hub .form .submit').after(html); | |
| 12 | - $('#hub-loading').fadeIn('slow'); | |
| 15 | + //$('.hub .form .submit').after(html); | |
| 16 | + jQuery(button).after(html); | |
| 17 | + jQuery('#hub-loading').fadeIn('slow'); | |
| 13 | 18 | } |
| 14 | 19 | |
| 15 | 20 | |
| 16 | 21 | function hub_close_loading() { |
| 17 | - $('#hub-loading').fadeOut('slow', function() { | |
| 18 | - $('#hub-loading').remove(); | |
| 22 | + jQuery('#hub-loading').fadeOut('slow', function() { | |
| 23 | + jQuery('#hub-loading').remove(); | |
| 19 | 24 | }); |
| 20 | 25 | } |
| 21 | 26 | |
| 22 | 27 | |
| 23 | -function send_message_for_stream(button) { | |
| 24 | - | |
| 25 | - var $button = $(button); | |
| 26 | - var form = $button.parents("form"); | |
| 27 | - | |
| 28 | - hub_open_loading(); | |
| 28 | +function new_message(button) { | |
| 29 | + var form = jQuery(button).parents("form"); | |
| 29 | 30 | |
| 30 | - $.post(form.attr("action"), form.serialize(), function(data) { | |
| 31 | - console.log(data); | |
| 32 | - $("#comment_body").val(''); | |
| 33 | - hub_close_loading(); | |
| 31 | + //hub_open_loading(); | |
| 32 | + jQuery.post(form.attr("action"), form.serialize(), function(data) { | |
| 33 | + if (data.ok) { | |
| 34 | + jQuery("#message_body").val(''); | |
| 35 | + } | |
| 36 | + //hub_close_loading(); | |
| 34 | 37 | }, 'json'); |
| 35 | -} | |
| 36 | - | |
| 37 | -function send_post_for_mediation(button) { | |
| 38 | - var $ = jQuery; | |
| 39 | - open_loading(DEFAULT_LOADING_MESSAGE); | |
| 40 | - var $button = $(button); | |
| 41 | - var form = $button.parents("form"); | |
| 42 | - $button.addClass('stream-post-button-loading'); | |
| 43 | - setMediationTimestamp(); | |
| 44 | - $.post(form.attr("action"), form.serialize(), function(data) { | |
| 45 | - tinymce.get('article_body').setContent(''); | |
| 46 | - close_loading(); | |
| 47 | - $button.removeClass('stream-post-button-loading'); | |
| 48 | - $button.enable(); | |
| 49 | - }); | |
| 50 | -} | |
| 51 | - | |
| 52 | -function clearMediationForm(element) { | |
| 53 | - alert(element); | |
| 54 | -} | |
| 55 | 38 | |
| 56 | -function setMediationTimestamp() { | |
| 57 | - var now = new Date().getTime(); | |
| 58 | - var timestamp = 'hub-mediation-' + now.toString(); | |
| 59 | - $("#article_name").val(timestamp); | |
| 60 | - console.log('teste!!!!!!!!!!!'); | |
| 61 | 39 | } |
| 62 | 40 | |
| 63 | -function loadPosts(section) { | |
| 64 | 41 | |
| 65 | - var url; | |
| 66 | - var container; | |
| 42 | +function new_mediation(button) { | |
| 43 | + var form = jQuery(button).parents("form"); | |
| 67 | 44 | |
| 68 | - switch(section) { | |
| 69 | - case 'live': | |
| 70 | - url = '/plugin/community_hub/public/newer_comments'; | |
| 71 | - container = $("#live-posts"); | |
| 72 | - break; | |
| 73 | - case 'mediation': | |
| 74 | - url = '/plugin/community_hub/public/newer_articles'; | |
| 75 | - container = $("#mediation-posts"); | |
| 76 | - break; | |
| 77 | - } | |
| 78 | - | |
| 79 | - $.ajax({ | |
| 80 | - url: url, | |
| 81 | - success: function(data) { | |
| 82 | - container.append(data); | |
| 83 | - }, | |
| 84 | - error: function(ajax, stat, errorThrown) { | |
| 85 | - console.log(stat); | |
| 45 | + //hub_open_loading(); | |
| 46 | + tinymce.triggerSave(); | |
| 47 | + jQuery.post(form.attr("action"), form.serialize(), function(data) { | |
| 48 | + if (data.ok) { | |
| 49 | + tinymce.get('article_body').setContent(''); | |
| 86 | 50 | } |
| 87 | - }); | |
| 88 | - | |
| 89 | -} | |
| 51 | + //hub_close_loading(); | |
| 52 | + }, 'json'); | |
| 90 | 53 | |
| 91 | -function hub() { | |
| 92 | - //checkNewPosts('live'); | |
| 93 | - //checkNewPosts('mediation'); | |
| 94 | 54 | } |
| 95 | 55 | |
| 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 | - | |
| 138 | -} | |
| 139 | 56 | |
| 140 | 57 | function toogleAutoScrolling() { |
| 141 | - alert($("#auto_scrolling").attr('checked')); | |
| 58 | + alert(jQuery("#auto_scrolling").attr('checked')); | |
| 142 | 59 | } |
| 143 | 60 | |
| 144 | -function setHubView(role) { | |
| 145 | 61 | |
| 146 | - var hub_id = $(".hub").attr('id'); | |
| 62 | +function promote_user(user_id) { | |
| 147 | 63 | |
| 148 | - $.ajax({ | |
| 149 | - url: '/plugin/community_hub/public/set_hub_view', | |
| 64 | + var hub_id = jQuery(".hub").attr('id'); | |
| 65 | + | |
| 66 | + jQuery.ajax({ | |
| 67 | + url: '/plugin/community_hub/public/promote_user', | |
| 150 | 68 | type: 'get', |
| 151 | - data: { hub: hub_id, role: role }, | |
| 69 | + dataType: 'json', | |
| 70 | + data: { user: user_id, hub: hub_id }, | |
| 152 | 71 | success: function(data) { |
| 153 | - $(".form").html(data); | |
| 154 | - console.log( data ); | |
| 155 | 72 | }, |
| 156 | 73 | error: function(ajax, stat, errorThrown) { |
| 157 | - console.log( 'ERRO ao processar requisição!'); | |
| 74 | + console.log(stat); | |
| 158 | 75 | } |
| 159 | 76 | }); |
| 160 | 77 | |
| 161 | 78 | } |
| 162 | 79 | |
| 163 | 80 | |
| 164 | -function checkUserLevel() { | |
| 81 | +function pin_message(post_id) { | |
| 165 | 82 | |
| 166 | - var hub_id = $(".hub").attr('id'); | |
| 83 | + var hub_id = jQuery(".hub").attr('id'); | |
| 167 | 84 | |
| 168 | - $.ajax({ | |
| 169 | - url: '/plugin/community_hub/public/check_user_level', | |
| 85 | + jQuery.ajax({ | |
| 86 | + url: '/plugin/community_hub/public/pin_message', | |
| 170 | 87 | type: 'get', |
| 171 | 88 | 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 | - | |
| 89 | + data: { id: post_id, hub: hub_id }, | |
| 90 | + success: function(data) { | |
| 193 | 91 | }, |
| 194 | 92 | error: function(ajax, stat, errorThrown) { |
| 195 | - console.log( 'ERRO ao processar requisição!'); | |
| 93 | + console.log(stat); | |
| 196 | 94 | } |
| 197 | 95 | }); |
| 198 | 96 | |
| 199 | 97 | } |
| 200 | 98 | |
| 201 | -$(document).ready(function(){ | |
| 202 | - | |
| 203 | - $("#auto_scrolling").click(function(){ | |
| 204 | - toogleAutoScrolling(); | |
| 205 | - }); | |
| 206 | - | |
| 207 | - hub(); | |
| 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 | |
| 214 | - | |
| 215 | -}); | |
| 216 | - | |
| 217 | - | |
| 218 | -function checkNewLivePosts() { | |
| 219 | - checkNewPosts('live'); | |
| 220 | -} | |
| 221 | - | |
| 222 | 99 | |
| 223 | -function checkNewMediationPosts() { | |
| 224 | - checkNewPosts('mediation'); | |
| 225 | -} | |
| 100 | +function update_mediation_comments(mediation) { | |
| 101 | + var hub_id = jQuery(".hub").attr('id'); | |
| 226 | 102 | |
| 103 | + if (jQuery("#mediation-comment-list-" + mediation + " li").first().length == 0) { | |
| 104 | + var latest_post_id = 0; | |
| 105 | + } | |
| 106 | + else { | |
| 107 | + var latest_post_id = jQuery("#mediation-comment-list-" + mediation + " li.mediation-comment").last().attr('id'); | |
| 108 | + } | |
| 227 | 109 | |
| 228 | -function removeLivePost(post_id) { | |
| 110 | + //console.log(latest_post_id); | |
| 229 | 111 | |
| 230 | - $.ajax({ | |
| 231 | - url: '/plugin/community_hub/public/remove_live_post', | |
| 112 | + jQuery.ajax({ | |
| 113 | + url: '/plugin/community_hub/public/newer_mediation_comment', | |
| 232 | 114 | type: 'get', |
| 233 | - dataType: 'json', | |
| 234 | - data: { id: post_id }, | |
| 115 | + data: { latest_post: latest_post_id, mediation: mediation }, | |
| 235 | 116 | 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!'); | |
| 117 | + if (data.trim().length > 0) { | |
| 118 | + jQuery("#mediation-comment-list-" + mediation + "").append(data); | |
| 242 | 119 | } |
| 243 | - | |
| 244 | 120 | }, |
| 245 | 121 | error: function(ajax, stat, errorThrown) { |
| 246 | - console.log( 'ERRO ao processar requisição!'); | |
| 122 | + console.log(stat); | |
| 247 | 123 | } |
| 248 | 124 | }); |
| 249 | 125 | |
| 126 | + setTimeout(function() { update_mediation_comments(mediation); }, 5000); | |
| 250 | 127 | } |
| 251 | 128 | |
| 252 | 129 | |
| 253 | -function promoteLivePost(post_id, user_id) { | |
| 130 | +function update_mediations() { | |
| 131 | + var hub_id = jQuery(".hub").attr('id'); | |
| 132 | + | |
| 133 | + if (jQuery("#mediation-posts li").first().length == 0) { | |
| 134 | + var latest_post_id = 0; | |
| 135 | + } | |
| 136 | + else { | |
| 137 | + var latest_post_id = jQuery("#mediation-posts li").first().attr('id'); | |
| 138 | + } | |
| 254 | 139 | |
| 255 | - var hub_id = $(".hub").attr('id'); | |
| 140 | + //console.log(latest_post_id); | |
| 256 | 141 | |
| 257 | - $.ajax({ | |
| 258 | - url: '/plugin/community_hub/public/promote_live_post', | |
| 142 | + jQuery.ajax({ | |
| 143 | + url: '/plugin/community_hub/public/newer_articles', | |
| 259 | 144 | type: 'get', |
| 260 | - dataType: 'json', | |
| 261 | - data: { id: post_id, user: user_id, hub: hub_id }, | |
| 145 | + data: { latest_post: latest_post_id, hub: hub_id }, | |
| 262 | 146 | 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!'); | |
| 147 | + if (data.trim().length > 0) { | |
| 148 | + jQuery("#mediation-posts").prepend(data); | |
| 269 | 149 | } |
| 270 | - | |
| 271 | 150 | }, |
| 272 | 151 | error: function(ajax, stat, errorThrown) { |
| 273 | - console.log( 'ERRO ao processar requisição!'); | |
| 152 | + console.log(stat); | |
| 274 | 153 | } |
| 275 | 154 | }); |
| 276 | 155 | |
| 156 | + setTimeout(update_mediations, 10000); | |
| 277 | 157 | } |
| 278 | 158 | |
| 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 | 159 | |
| 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 | - }); | |
| 160 | +function update_live_stream() { | |
| 161 | + var hub_id = jQuery(".hub").attr('id'); | |
| 302 | 162 | |
| 303 | -} | |
| 163 | + if (jQuery("#live-posts li").first().length == 0) { | |
| 164 | + var latest_post_id = 0; | |
| 165 | + } | |
| 166 | + else { | |
| 167 | + var latest_post_id = jQuery("#live-posts li").first().attr('id'); | |
| 168 | + } | |
| 304 | 169 | |
| 305 | -function likeLivePost(post_id) { | |
| 170 | + //console.log(latest_post_id); | |
| 306 | 171 | |
| 307 | - $.ajax({ | |
| 308 | - url: '/plugin/community_hub/public/like_live_post', | |
| 172 | + jQuery.ajax({ | |
| 173 | + url: '/plugin/community_hub/public/newer_comments', | |
| 309 | 174 | type: 'get', |
| 310 | - dataType: 'json', | |
| 311 | - data: { id: post_id }, | |
| 175 | + data: { latest_post: latest_post_id, hub: hub_id }, | |
| 312 | 176 | 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!'); | |
| 177 | + if (data.trim().length > 0) { | |
| 178 | + jQuery("#live-posts").prepend(data); | |
| 319 | 179 | } |
| 320 | - | |
| 321 | 180 | }, |
| 322 | 181 | error: function(ajax, stat, errorThrown) { |
| 323 | - console.log( 'ERRO ao processar requisição!'); | |
| 182 | + console.log(stat); | |
| 324 | 183 | } |
| 325 | 184 | }); |
| 326 | 185 | |
| 186 | + setTimeout(update_live_stream, 5000); | |
| 327 | 187 | } |
| 328 | 188 | |
| 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 | 189 | |
| 351 | -} | |
| 352 | 190 | \ No newline at end of file |
| 191 | +jQuery(document).ready(function() { | |
| 192 | + setTimeout(update_live_stream, 5000); | |
| 193 | + setTimeout(update_mediations, 10000); | |
| 194 | +}); | |
| 353 | 195 | \ No newline at end of file | ... | ... |
plugins/community_hub/public/style.css
| 1 | 1 | #hub-loading { |
| 2 | - margin-top: 18px; | |
| 2 | + /*margin-top: 18px;*/ | |
| 3 | 3 | float: right; |
| 4 | 4 | } |
| 5 | 5 | |
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | font-size: 14px; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -.hub .post{ | |
| 34 | +.hub .post { | |
| 35 | 35 | border-bottom: 1px solid #ddd !important; |
| 36 | 36 | background: url("images/hub-time-bg.gif") repeat-y left top #fff; |
| 37 | 37 | } |
| ... | ... | @@ -59,21 +59,24 @@ |
| 59 | 59 | width: 70%; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -.hub .mediation-bar{ | |
| 63 | - display: inline-block; | |
| 64 | - margin: 10px 0 10px 104px; | |
| 65 | - width: 70%; | |
| 62 | +.hub .message .author { | |
| 63 | + font-weight: bold; | |
| 64 | +} | |
| 66 | 65 | |
| 66 | +.hub .mediation-bar { | |
| 67 | + display: inline-block; | |
| 68 | + margin: 10px 0 10px 104px; | |
| 69 | + width: 70%; | |
| 67 | 70 | } |
| 68 | 71 | |
| 69 | 72 | .hub .mediation-bar ul {} |
| 70 | 73 | |
| 71 | 74 | .hub .mediation-bar ul li { |
| 72 | - display: inline-block; | |
| 73 | - margin-right: 5px; | |
| 74 | - overflow: hidden; | |
| 75 | - text-indent: -1000px; | |
| 76 | - width: 16px; | |
| 75 | + display: inline-block; | |
| 76 | + /*margin-right: 5px;*/ | |
| 77 | + overflow: hidden; | |
| 78 | + /*text-indent: -1000px;*/ | |
| 79 | + width: 16px; | |
| 77 | 80 | } |
| 78 | 81 | |
| 79 | 82 | .hub .mediation-bar ul li.likes-dislikes{ |
| ... | ... | @@ -93,14 +96,24 @@ |
| 93 | 96 | text-indent: -10000px; |
| 94 | 97 | } |
| 95 | 98 | |
| 96 | -.hub .promote{ | |
| 99 | +.hub .promote { | |
| 97 | 100 | background: url("images/hub-promote-icon.png") no-repeat center center #fff; |
| 98 | 101 | } |
| 99 | 102 | |
| 100 | -.hub .pin{ | |
| 103 | +.hub .promote .not-promoted { | |
| 104 | + opacity: 0.5; | |
| 105 | + filter: alpha(opacity=50); | |
| 106 | +} | |
| 107 | + | |
| 108 | +.hub .pin { | |
| 101 | 109 | background: url("images/hub-pin-icon.png") no-repeat center center #fff; |
| 102 | 110 | } |
| 103 | 111 | |
| 112 | +.hub .pin .not-pinned { | |
| 113 | + opacity: 0.5; | |
| 114 | + filter: alpha(opacity=50); | |
| 115 | +} | |
| 116 | + | |
| 104 | 117 | .hub .mediation-bar ul li.pin { |
| 105 | 118 | float: right; |
| 106 | 119 | } |
| ... | ... | @@ -201,21 +214,56 @@ |
| 201 | 214 | float: left; |
| 202 | 215 | width: 49%; |
| 203 | 216 | } |
| 204 | -.hub .settings { | |
| 205 | - /* border: 1px solid red;*/ | |
| 206 | -} | |
| 207 | 217 | |
| 208 | 218 | .hub div.settings { |
| 209 | 219 | float: right; |
| 210 | 220 | width: 50%; |
| 211 | 221 | } |
| 212 | 222 | |
| 213 | -.hub ul.settings li{ | |
| 223 | +.hub ul.settings li { | |
| 214 | 224 | height: 50px; |
| 215 | 225 | line-height: 50px; |
| 216 | 226 | margin-bottom: 10px; |
| 217 | - padding: 0 10px; | |
| 218 | - /* background: url("images/hub-arrow-right.png") no-repeat 90% top #ed8e01;*/ | |
| 227 | + padding: 0 10px; | |
| 228 | + background: url("images/hub-arrow-right.png") no-repeat 90% top #ed8e01; | |
| 229 | +} | |
| 230 | + | |
| 231 | +.hub ul.settings span.collapse { | |
| 232 | + padding-right: 0.5em; | |
| 233 | + float: right; | |
| 234 | +} | |
| 235 | + | |
| 236 | +.hub div.banner { | |
| 237 | + width: 50%; | |
| 238 | + height: 100px; | |
| 239 | + background-color: #6d6d6d; | |
| 240 | + float: right; | |
| 241 | + text-align: center; | |
| 242 | +} | |
| 243 | + | |
| 244 | +.hub div.banner span { | |
| 245 | + color: white; | |
| 246 | + font-family: Arial Black, arial, sans-serif; | |
| 247 | + font-size: large; | |
| 248 | + font-weight: normal; | |
| 249 | + margin-top: 35px; | |
| 250 | + display: block; | |
| 251 | +} | |
| 252 | + | |
| 253 | +.hub div.embed { | |
| 254 | + margin-top: 10px; | |
| 255 | + padding: 8px; | |
| 256 | + width: 48%; | |
| 257 | + height: 216px; | |
| 258 | + border: 1px solid #c0c0c0; | |
| 259 | + float: right; | |
| 260 | +} | |
| 261 | + | |
| 262 | +.hub div.embed textarea.code { | |
| 263 | + background-color: #f0f0f0; | |
| 264 | + border: 1px solid #f0f0f0; | |
| 265 | + height: 195px; | |
| 266 | + resize: none; | |
| 219 | 267 | } |
| 220 | 268 | |
| 221 | 269 | #content .hub ul.settings li a{ | ... | ... |
plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml
| ... | ... | @@ -12,6 +12,14 @@ |
| 12 | 12 | <%= required labelled_form_field(_('Description'), text_area(:article, 'body', :style => 'width: 99%;')) %> |
| 13 | 13 | </div> |
| 14 | 14 | |
| 15 | + <br /> | |
| 16 | + | |
| 17 | + <%= check_box(:article, :twitter_enabled) %> <span><%= _("Turn on TWITTER") %></span> | |
| 18 | + | |
| 15 | 19 | <span><%= labelled_form_field(_('Hashtags (TWITTER)'), text_field(:article, 'hashtags_twitter')) %></span> |
| 16 | 20 | |
| 21 | + <br /> | |
| 22 | + | |
| 23 | + <%= check_box(:article, :facebook_enabled) %> <span><%= _("Turn on FACEBOOK") %></span> | |
| 24 | + | |
| 17 | 25 | </div> |
| 18 | 26 | \ No newline at end of file | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_banner.rhtml
0 → 100644
plugins/community_hub/views/community_hub_plugin_public/_embed.rhtml
0 → 100644
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | +<% extend CommunityHubPlugin::HubHelper %> | |
| 2 | + | |
| 3 | +<div class="embed"> | |
| 4 | + <span class="label">Embed / <%= _("Embed") %></span> | |
| 5 | + <textarea cols="38" | |
| 6 | + id="comment_body" | |
| 7 | + name="comment[body]" | |
| 8 | + rows="10" | |
| 9 | + class="code" | |
| 10 | + style="width: 99%;"><%= embed_code(@page) %></textarea> | |
| 11 | +</div> | |
| 0 | 12 | \ No newline at end of file | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_mediation.rhtml
0 → 100644
| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | +<% extend CommunityHubPlugin::HubHelper %> | |
| 2 | + | |
| 3 | +<li id="<%= mediation.id %>" class="<%=post_css_classes(mediation.id, latest_post, oldest_post)%>"> | |
| 4 | + | |
| 5 | + <ul> | |
| 6 | + <li class="time"><%= post_time(mediation.created_at) %></li> | |
| 7 | + <li class="avatar"><%= image_tag(profile_icon(mediation.author, :minor)) %></li> | |
| 8 | + <li class="message"><span class="author"><%= mediation.author_name %>:</span> <%= mediation.body %></li> | |
| 9 | + | |
| 10 | + <% if mediator?(hub) %> | |
| 11 | + <li class="mediation-bar"> | |
| 12 | + | |
| 13 | + <ul> | |
| 14 | + | |
| 15 | + <li class="promote"> | |
| 16 | + <% if !promoted?(hub, mediation.author.id) %> | |
| 17 | + <a id="<%= mediation.id %>" href="#" onclick="promote_user(<%= mediation.author.id %>); return false;"> | |
| 18 | + <img class="promoted" src="/designs/icons/default/outras/16x16/actions/spread.png" /> | |
| 19 | + </a> | |
| 20 | + <% else %> | |
| 21 | + <img class="not-promoted" src="/designs/icons/default/outras/16x16/actions/spread.png" /> | |
| 22 | + <% end %> | |
| 23 | + </li> | |
| 24 | + | |
| 25 | + <% if pinned_mediation?(hub, mediation.id) %> | |
| 26 | + <li class="pin"> | |
| 27 | + <img class="pinned" src="/designs/icons/default/outras/16x16/apps/tags.gif" /> | |
| 28 | + </li> | |
| 29 | + <% end %> | |
| 30 | + | |
| 31 | + </ul> | |
| 32 | + | |
| 33 | + </li> | |
| 34 | + <% end %> | |
| 35 | + | |
| 36 | + </ul> | |
| 37 | + | |
| 38 | + <% total_mediation_comments = mediation.comments.count %> | |
| 39 | + | |
| 40 | + <span> | |
| 41 | + <%= link_to(_( "#{total_mediation_comments} Comments" ) , '#', | |
| 42 | + :class => 'display-comment-form', | |
| 43 | + :id => 'top-post-comment-button', | |
| 44 | + :onclick => "toogle_mediation_comments(#{mediation.id}); return false;") %> | |
| 45 | + </span> | |
| 46 | + | |
| 47 | + <script type="text/javascript"> | |
| 48 | + setTimeout(function() { update_mediation_comments('<%= mediation.id %>')}, 5000); | |
| 49 | + </script> | |
| 50 | + | |
| 51 | + <ul id="mediation-comment-list-<%=mediation.id%>" class="mediation-comment-list" style="display:none;"> | |
| 52 | + <% if mediation.accept_comments? && mediation.comments.count > 0 %> | |
| 53 | + <%= render :partial => 'community_hub_plugin_public/mediation_comment', :collection => mediation.comments %> | |
| 54 | + <% end %> | |
| 55 | + </ul> | |
| 56 | + | |
| 57 | + <% if logged_in? && mediation.accept_comments? %> | |
| 58 | + <div id='mediation-comment-form-<%=mediation.id%>' class='mediation-comment-form' style="display:none;"> | |
| 59 | + <%= render :partial => 'community_hub_plugin_public/mediation_comment_form', | |
| 60 | + :locals => { | |
| 61 | + :hub => hub, | |
| 62 | + :mediation => mediation, | |
| 63 | + :comment => Comment.new, | |
| 64 | + :url => { | |
| 65 | + :controller => :comment, | |
| 66 | + :action => :create | |
| 67 | + }, | |
| 68 | + :display_link => true, | |
| 69 | + :cancel_triggers_hide => true | |
| 70 | + } %> | |
| 71 | + </div> | |
| 72 | + <% end %> | |
| 73 | + | |
| 74 | +</li> | |
| 0 | 75 | \ No newline at end of file | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_mediation_comment.rhtml
0 → 100644
| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | +<li id="<%= mediation_comment.id %>" class="mediation-comment"> | |
| 2 | + <ul> | |
| 3 | + <li class="avatar"><%= image_tag(profile_icon(mediation_comment.author, :minor)) %></li> | |
| 4 | + <li class="message"><span class="author"><%= mediation_comment.author_name %>:</span> <%= mediation_comment.body %></li> | |
| 5 | + </ul> | |
| 6 | +</li> | |
| 0 | 7 | \ No newline at end of file | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_mediation_comment_form.rhtml
0 → 100644
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +<% form_for :message, | |
| 2 | + :method => 'post', | |
| 3 | + :url => { | |
| 4 | + :controller => 'community_hub_plugin_public', | |
| 5 | + :action => 'new_message', | |
| 6 | + :article_id => mediation.id | |
| 7 | + } do |f| %> | |
| 8 | + <%= f.text_area(:body, | |
| 9 | + :style => 'width: 97%;', | |
| 10 | + :rows => 4, | |
| 11 | + :placeholder => _('Type your comment here')) %> | |
| 12 | + <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> | |
| 13 | +<% end %> | |
| 0 | 14 | \ No newline at end of file | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_post.rhtml
| 1 | 1 | <% extend CommunityHubPlugin::HubHelper %> |
| 2 | -<li id="<%= post.id %>" class="<%=post_css_classes(post.id, latest_post, oldest_post)%>"> | |
| 3 | - | |
| 4 | - <ul> | |
| 5 | - <li class="time"> | |
| 6 | - <%= show_time(post.created_at) %> | |
| 7 | - </li> | |
| 8 | - <li class="avatar"> | |
| 9 | - | |
| 10 | - <%= link_to image_tag(profile_icon(post.author, :minor)), | |
| 11 | - post.author.url, | |
| 12 | - :class => 'comment-picture1', | |
| 13 | - :title => post.author_name | |
| 14 | - %> | |
| 15 | - | |
| 16 | - </li> | |
| 17 | - <li class="message"> | |
| 18 | - <%= txt2html post.body %> | |
| 19 | - </li> | |
| 20 | - | |
| 21 | - <% if logged_in? %> | |
| 22 | - | |
| 23 | - <li class="mediation-bar"> | |
| 24 | 2 | |
| 25 | - <ul> | |
| 26 | - <% if mediator?(hub) %> | |
| 27 | - <li class="promote"> | |
| 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> | |
| 31 | - </li> | |
| 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> | |
| 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) %> | |
| 46 | - <li class="pin"> | |
| 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> | |
| 50 | - </li> | |
| 3 | +<li id="<%= post.id %>" class="<%=post_css_classes(post.id, latest_post, oldest_post)%>"> | |
| 4 | + <ul> | |
| 5 | + <li class="time"><%= post_time(post.created_at) %></li> | |
| 6 | + <li class="avatar"><%= image_tag(profile_icon(post.author, :minor)) %></li> | |
| 7 | + <li class="message"><span class="author"><%= post.author_name %>:</span> <%= post.body %></li> | |
| 8 | + | |
| 9 | + <% if mediator?(hub) %> | |
| 10 | + <li class="mediation-bar"> | |
| 11 | + | |
| 12 | + <ul> | |
| 13 | + | |
| 14 | + <li class="promote"> | |
| 15 | + <img class="<%= !promoted?(hub, post.author.id) ? "promoted" : "not-promoted" %>" src="/designs/icons/default/outras/16x16/actions/spread.png" /> | |
| 16 | + </li> | |
| 17 | + <% end %> | |
| 18 | + | |
| 19 | + <% if mediator?(hub) %> | |
| 20 | + <li class="pin"> | |
| 21 | + <% if !pinned_message?(hub, post.id) %> | |
| 22 | + <a id="<%= post.id %>" href="#" onclick="pin_message(<%= post.id %>); return false;"> | |
| 23 | + <img class="pinned" src="/designs/icons/default/outras/16x16/apps/tags.gif" /> | |
| 24 | + </a> | |
| 25 | + <% else %> | |
| 26 | + <img class="not-pinned" src="/designs/icons/default/outras/16x16/apps/tags.gif" /> | |
| 51 | 27 | <% end %> |
| 28 | + </li> | |
| 52 | 29 | |
| 53 | - </ul> | |
| 54 | - | |
| 55 | - </li> | |
| 30 | + </ul> | |
| 56 | 31 | |
| 57 | - <% end %> | |
| 58 | - </ul> | |
| 32 | + </li> | |
| 33 | + <% end %> | |
| 59 | 34 | |
| 35 | + </ul> | |
| 60 | 36 | </li> |
| 61 | 37 | \ No newline at end of file | ... | ... |
plugins/community_hub/views/community_hub_plugin_public/_post_form.rhtml
| ... | ... | @@ -1,82 +0,0 @@ |
| 1 | - <% if user_role == 'visitor' %> | |
| 2 | - | |
| 3 | - <% remote_form_for( :comment, | |
| 4 | - Comment.new, | |
| 5 | - :url => { | |
| 6 | - :profile => hub.profile.identifier, | |
| 7 | - :controller => 'comment', | |
| 8 | - :action => 'create', | |
| 9 | - :id => hub.id | |
| 10 | - }, | |
| 11 | - :html => { :class => 'comment_form' } ) do |f| %> | |
| 12 | - | |
| 13 | - <div> | |
| 14 | - <span><%= _("Streaming") %></span> | |
| 15 | - </div> | |
| 16 | - <div> | |
| 17 | - <%= f.text_area(:body, | |
| 18 | - :style => 'width: 99%;', | |
| 19 | - :placeholder => _('Type your message here')) %> | |
| 20 | - </div> | |
| 21 | - <div> | |
| 22 | - <%= submit_button('add', _('Post'), :onclick => "send_message_for_stream(this); return false;") %> | |
| 23 | - </div> | |
| 24 | - | |
| 25 | - <% end %> | |
| 26 | - | |
| 27 | - <% end %> | |
| 28 | - | |
| 29 | - <% if user_role == 'mediator' %> | |
| 30 | - | |
| 31 | - <%= render :file => 'shared/tiny_mce' %> | |
| 32 | - | |
| 33 | - <% category_ids = [] %> | |
| 34 | - | |
| 35 | - <% remote_form_for( :article, | |
| 36 | - TinyMceArticle.new, | |
| 37 | - :url => { | |
| 38 | - :profile => profile.identifier, | |
| 39 | - :controller => 'cms', | |
| 40 | - :action => 'new', | |
| 41 | - :type => 'TinyMceArticle', | |
| 42 | - :success_back_to => "", | |
| 43 | - :q => "", | |
| 44 | - :parent_id => hub.id, | |
| 45 | - :back_to => "" | |
| 46 | - }, | |
| 47 | - :before => "tinymce.triggerSave(); setMediationTimestamp()", | |
| 48 | - :loading => "alert('loading...')", | |
| 49 | - :complete => "tinymce.get('article_body').setContent('')", | |
| 50 | - :html => { :class => 'comment_form' } ) do |f| %> | |
| 51 | - | |
| 52 | - <%= f.hidden_field :moderate_comments, :value => 0 %> | |
| 53 | - <%= f.hidden_field :translation_of_id, :value => "" %> | |
| 54 | - <%= f.hidden_field :notify_comments, :value => 0 %> | |
| 55 | - <%= f.hidden_field :accept_comments, :value => 1 %> | |
| 56 | - <%= f.hidden_field :tag_list, :value => "" %> | |
| 57 | - <%= f.hidden_field :display_versions, :value => 0 %> | |
| 58 | - <%= f.hidden_field :allow_members_to_edit, :value => 0 %> | |
| 59 | - <%= f.hidden_field :abstract, :value => "" %> | |
| 60 | - <%= f.hidden_field :display_hits, :value => 0 %> | |
| 61 | - <%= f.hidden_field :parent_id, :value => hub.id %> | |
| 62 | - <%= f.hidden_field :name %> | |
| 63 | - <%= f.hidden_field :published, :value => true %> | |
| 64 | - <%= f.hidden_field :license_id, :value => "" %> | |
| 65 | - <%= hidden_field_tag "article[category_ids][]", "" %> | |
| 66 | - <%= f.hidden_field :language, :value => "en" %> | |
| 67 | - | |
| 68 | - <div> | |
| 69 | - <div> | |
| 70 | - <%= f.text_area(:body, | |
| 71 | - :style => 'width: 99%;', | |
| 72 | - :class => 'mceEditor', | |
| 73 | - :placeholder => _('Type your message for mediation here')) %> | |
| 74 | - </div> | |
| 75 | - <div> | |
| 76 | - <%= submit_button('add', _('Post'), :onclick => "send_post_for_mediation(this); return false;")%> | |
| 77 | - </div> | |
| 78 | - </div> | |
| 79 | - | |
| 80 | - <% end %> | |
| 81 | - | |
| 82 | - <% end %> | |
| 83 | 0 | \ No newline at end of file |
plugins/community_hub/views/community_hub_plugin_public/_settings.rhtml
| 1 | -<ul class="settings"> | |
| 2 | - <li class="twitter"> | |
| 3 | - <%= link_to _("Twitter settings"), :controller => 'cms', :action => 'edit', :id => @page.id %> | |
| 4 | - <form> | |
| 5 | - <label>#hashtag a ser seguida</label> | |
| 6 | - <input></input><input class="btn-ok" type="submit" value="ok"></input> | |
| 7 | - </form> | |
| 8 | - </li> | |
| 9 | - <li class="general"> | |
| 10 | - <%= link_to _("General settings"), :controller => 'cms', :action => 'edit', :id => @page.id %> | |
| 11 | - </li> | |
| 12 | -</ul> | |
| 1 | +<div class="settings"> | |
| 2 | + <ul class="settings"> | |
| 3 | + <li class="twitter"> | |
| 4 | + <%= link_to _("Twitter settings") + '<span class="collapse">►</span>', :controller => 'cms', :action => 'edit', :id => @page.id %> | |
| 5 | + </li> | |
| 6 | + <li class="facebook"> | |
| 7 | + <%= link_to _("Facebook settings") + '<span class="collapse">►</span>', :controller => 'cms', :action => 'edit', :id => @page.id %> | |
| 8 | + </li> | |
| 9 | + <li class="general"> | |
| 10 | + <%= link_to _("General settings") + '<span class="collapse">►</span>', :controller => 'cms', :action => 'edit', :id => @page.id %> | |
| 11 | + </li> | |
| 12 | + </ul> | |
| 13 | +</div> | |
| 13 | 14 | \ No newline at end of file | ... | ... |
plugins/community_hub/views/content_viewer/hub.rhtml
| 1 | 1 | <% extend CommunityHubPlugin::HubHelper %> |
| 2 | 2 | |
| 3 | -<% CommunityHubPlugin::Hub.start_twitter_service(@page) %> | |
| 4 | - | |
| 5 | 3 | <div id="<%=@page.id%>" class="hub"> |
| 6 | 4 | |
| 7 | 5 | <div class="title"><%= @page.title %> HUB</div> |
| ... | ... | @@ -32,78 +30,36 @@ |
| 32 | 30 | |
| 33 | 31 | <div class="form"> |
| 34 | 32 | |
| 35 | - <% if !mediator?(@page.id) %> | |
| 36 | - | |
| 37 | - <form action="/profile/<%=profile.identifier%>/comment/create/<%=@page.id%>" | |
| 38 | - class="comment_form" | |
| 39 | - method="post"> | |
| 40 | - | |
| 41 | - <div> | |
| 42 | - <span>Streaming</span> | |
| 43 | - </div> | |
| 44 | - <div> | |
| 45 | - <textarea cols="38" | |
| 46 | - id="comment_body" | |
| 47 | - name="comment[body]" | |
| 48 | - placeholder="Type your message here" | |
| 49 | - rows="10" | |
| 50 | - style="width: 99%;"></textarea> | |
| 51 | - </div> | |
| 52 | - <div> | |
| 53 | - <input class="button with-text icon-add submit" | |
| 54 | - name="commit" | |
| 55 | - onclick="send_message_for_stream(this); return false;" | |
| 56 | - type="submit" | |
| 57 | - value="Post"> | |
| 58 | - </div> | |
| 59 | - | |
| 60 | - </form> | |
| 33 | + <% if !mediator?(@page) %> | |
| 61 | 34 | |
| 62 | - <% end %> | |
| 35 | + <% form_for :message, | |
| 36 | + :method => 'post', | |
| 37 | + :url => { | |
| 38 | + :controller => 'community_hub_plugin_public', | |
| 39 | + :action => 'new_message', | |
| 40 | + :article_id => @page.id | |
| 41 | + } do |f| %> | |
| 42 | + <span><%= _("Streaming") %></span> | |
| 43 | + <br /> | |
| 44 | + <%= f.text_area :body, :style => "width: 99%;", :cols => "38", :rows => "10", :placeholder => _("Type your message here") %> | |
| 45 | + <%= submit_button('add', _('Post'), :onclick => 'new_message(this); return false;') %> | |
| 46 | + <% end %> | |
| 63 | 47 | |
| 64 | - <% if mediator?(@page.id) %> | |
| 48 | + <% else %> | |
| 65 | 49 | |
| 66 | 50 | <%= render :file => 'shared/tiny_mce' %> |
| 67 | 51 | |
| 68 | - <% category_ids = [] %> | |
| 69 | - | |
| 70 | - <form action="/myprofile/<%=profile.identifier%>/cms/new?back_to=&parent_id=<%=@page.id%>&q=&success_back_to=&type=TinyMceArticle" | |
| 71 | - class="comment_form" | |
| 72 | - method="post"> | |
| 73 | - | |
| 74 | - <input id="article_moderate_comments" name="article[moderate_comments]" type="hidden" value="0" /> | |
| 75 | - <input id="article_translation_of_id" name="article[translation_of_id]" type="hidden" value="" /> | |
| 76 | - <input id="article_notify_comments" name="article[notify_comments]" type="hidden" value="0" /> | |
| 77 | - <input id="article_accept_comments" name="article[accept_comments]" type="hidden" value="1" /> | |
| 78 | - <input id="article_tag_list" name="article[tag_list]" type="hidden" value="" /> | |
| 79 | - <input id="article_display_versions" name="article[display_versions]" type="hidden" value="0" /> | |
| 80 | - <input id="article_allow_members_to_edit" name="article[allow_members_to_edit]" type="hidden" value="0" /> | |
| 81 | - <input id="article_abstract" name="article[abstract]" type="hidden" value="" /> | |
| 82 | - <input id="article_display_hits" name="article[display_hits]" type="hidden" value="0" /> | |
| 83 | - <input id="article_parent_id" name="article[parent_id]" type="hidden" value="446" /> | |
| 84 | - <input id="article_name" name="article[name]" type="hidden" /> | |
| 85 | - <input id="article_published" name="article[published]" type="hidden" value="true" /> | |
| 86 | - <input id="article_license_id" name="article[license_id]" type="hidden" value="" /> | |
| 87 | - <input id="article_category_ids_" name="article[category_ids][]" type="hidden" value="" /> | |
| 88 | - <input id="article_language" name="article[language]" type="hidden" value="en" /> | |
| 89 | - | |
| 90 | - <textarea class="mceEditor" | |
| 91 | - cols="40" | |
| 92 | - id="article_body" | |
| 93 | - name="article[body]" | |
| 94 | - placeholder="Type your message for mediation here" | |
| 95 | - rows="20" | |
| 96 | - style="width: 99%;" | |
| 97 | - aria-hidden="true"> | |
| 98 | - </textarea> | |
| 99 | - | |
| 100 | - <input class="button with-text icon-add submit" | |
| 101 | - name="commit" | |
| 102 | - onclick="send_post_for_mediation(this); return false;" | |
| 103 | - type="submit" | |
| 104 | - value="Post" /> | |
| 105 | - | |
| 106 | - </form> | |
| 52 | + <% form_for :article, | |
| 53 | + :method => 'post', | |
| 54 | + :url => { | |
| 55 | + :controller => 'community_hub_plugin_public', | |
| 56 | + :action => 'new_mediation', | |
| 57 | + :profile_id => profile.id | |
| 58 | + } do |f| %> | |
| 59 | + <%= f.hidden_field :parent_id, :value => @page.id %> | |
| 60 | + <%= f.text_area :body, :style => "width: 100%;", :class => "mceEditor" %> | |
| 61 | + <%= submit_button('add', _('Post'), :onclick => 'new_mediation(this); return false;') %> | |
| 62 | + <% end %> | |
| 107 | 63 | |
| 108 | 64 | <% end %> |
| 109 | 65 | |
| ... | ... | @@ -111,10 +67,13 @@ |
| 111 | 67 | |
| 112 | 68 | <% end %> |
| 113 | 69 | |
| 114 | - <% if logged_in? %> | |
| 115 | - <div class="settings"> | |
| 70 | + <% if mediator?(@page) %> | |
| 116 | 71 | <%= render :partial => "community_hub_plugin_public/settings" %> |
| 117 | - </div> | |
| 72 | + <% else %> | |
| 73 | + <%= render :partial => "community_hub_plugin_public/banner" %> | |
| 74 | + <%= render :partial => "community_hub_plugin_public/embed" %> | |
| 118 | 75 | <% end %> |
| 119 | 76 | |
| 120 | 77 | </div> |
| 78 | + | |
| 79 | +<%= javascript_include_tag '/plugins/community_hub/javascripts/community_hub.js' %> | ... | ... |