diff --git a/controllers/public/community_hub_plugin_public_controller.rb b/controllers/public/community_hub_plugin_public_controller.rb index b47c7be..97dae67 100644 --- a/controllers/public/community_hub_plugin_public_controller.rb +++ b/controllers/public/community_hub_plugin_public_controller.rb @@ -1,7 +1,43 @@ class CommunityHubPluginPublicController < PublicController + append_view_path File.join(File.dirname(__FILE__) + '/../../views') - def delete_post + #layout false + + def newer_comments + posts = Comment.find(:all) + #render :text => posts_to_json(posts), :content_type => 'text/plain' + render :partial => "post", :collection => posts + end + + def more_comments + @posts = Comment.find(:all) + render :partial => "post", :collection => @posts + end + + def newer_articles + posts = Article.find(:all, :conditions => {:type => 'TinyMceArticle'}, :limit => 3) + render :partial => "post", :collection => posts end + def settings + settings_section = params[:id] + #raise settings_section.inspect + render :partial => "settings/twitter", :layout => true + end + + protected + + def posts_to_json(list) + list.map do |item| { + 'id' => item.id, + 'created_at' => item.created_at, + 'body' => item.body, + 'profile' => item.author + } + end.to_json + end + + + end \ No newline at end of file diff --git a/lib/community_hub_plugin.rb b/lib/community_hub_plugin.rb index 2e93944..36c815e 100644 --- a/lib/community_hub_plugin.rb +++ b/lib/community_hub_plugin.rb @@ -13,7 +13,7 @@ class CommunityHubPlugin < Noosfero::Plugin end def js_files - 'javascripts/stream_post_form.js' + 'javascripts/community_hub.js' end def content_types @@ -27,10 +27,6 @@ class CommunityHubPlugin < Noosfero::Plugin end end - #def self.extra_blocks - # { CommunityHubPlugin::HubBlock => {:position => 1} } - #end - def content_remove_new(page) page.kind_of?(CommunityHubPlugin::Hub) end diff --git a/lib/community_hub_plugin/hub.rb b/lib/community_hub_plugin/hub.rb index d522f74..24f10ed 100644 --- a/lib/community_hub_plugin/hub.rb +++ b/lib/community_hub_plugin/hub.rb @@ -1,5 +1,7 @@ class CommunityHubPlugin::Hub < Folder + settings_items :hashtags_twitter, :type => :string, :default => "" + def self.icon_name(article = nil) 'community-hub' end @@ -12,16 +14,12 @@ class CommunityHubPlugin::Hub < Folder _('Defines a hub.') end - def view_page - "content_viewer/hub.rhtml" - end - - def bli - "bli" - end - def accept_comments? true end + def view_page + "content_viewer/hub.rhtml" + end + end \ No newline at end of file diff --git a/lib/community_hub_plugin/hub_stream_post.rb b/lib/community_hub_plugin/hub_stream_post.rb deleted file mode 100644 index 1ab0bbc..0000000 --- a/lib/community_hub_plugin/hub_stream_post.rb +++ /dev/null @@ -1,7 +0,0 @@ -class CommunityHubPlugin::HubStreamPost < Comment - - def bli - "" - end - -end \ No newline at end of file diff --git a/lib/ext/article.rb b/lib/ext/article.rb index eceedc0..a125371 100644 --- a/lib/ext/article.rb +++ b/lib/ext/article.rb @@ -2,11 +2,11 @@ require_dependency 'article' class Article - #before_create do |article| + before_create do |article| # if article.parent.kind_of?(CommunityDashboardPlugin::Hub) # article.accept_comments = article.parent.accept_comments # end - # true - #end + true + end end diff --git a/public/javascripts/community_hub.js b/public/javascripts/community_hub.js new file mode 100644 index 0000000..3b5f0aa --- /dev/null +++ b/public/javascripts/community_hub.js @@ -0,0 +1,115 @@ +var $ = jQuery; + +function send_message_for_stream(button) { + var $ = jQuery; + open_loading(DEFAULT_LOADING_MESSAGE); + var $button = $(button); + var form = $button.parents("form"); + $button.addClass('stream-post-button-loading'); + $.post(form.attr("action"), form.serialize(), function(data) { + if(data.render_target == null) { + } + else if(data.render_target == 'form') { + } + else if($('#' + data.render_target).size() > 0) { + } + else { + form.find("input[type='text']").add('textarea').each(function() { + this.value = ''; + }); + } + + close_loading(); + $button.removeClass('stream-post-button-loading'); + $button.enable(); + }, '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'); + $.post(form.attr("action"), form.serialize(), function(data) { + if(data.render_target == null) { + } + else if(data.render_target == 'form') { + } + else if($('#' + data.render_target).size() > 0) { + } + else { + form.find("input[type='text']").add('textarea').each(function() { + this.value = ''; + }); + } + + 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").value = timestamp; +} + +function loadPosts(section) { + + var url; + var container; + + 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); + } + }); + +} + +function hub() { + loadPosts('live'); + loadPosts('mediation'); +} + +function checkNewPosts() { + var agora = new Date(); + console.log( 'checking news posts...' ); +} + +function toogleAutoScrolling() { + alert($("#auto_scrolling").attr('checked')); +} + +$(document).ready(function(){ + + $("#auto_scrolling").click(function(){ + toogleAutoScrolling(); + }); + + hub(); + checkNewPosts('live'); + +}); + diff --git a/public/javascripts/stream_post_form.js b/public/javascripts/stream_post_form.js deleted file mode 100644 index ab8afa5..0000000 --- a/public/javascripts/stream_post_form.js +++ /dev/null @@ -1,62 +0,0 @@ -function send_message_for_stream(button) { - var $ = jQuery; - open_loading(DEFAULT_LOADING_MESSAGE); - var $button = $(button); - var form = $button.parents("form"); - $button.addClass('stream-post-button-loading'); - $.post(form.attr("action"), form.serialize(), function(data) { - if(data.render_target == null) { - } - else if(data.render_target == 'form') { - } - else if($('#' + data.render_target).size() > 0) { - } - else { - form.find("input[type='text']").add('textarea').each(function() { - this.value = ''; - }); - } - - close_loading(); - $button.removeClass('stream-post-button-loading'); - $button.enable(); - }, 'json'); -} - -function teste() { - alert('teste'); -} - -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'); - $.post(form.attr("action"), form.serialize(), function(data) { - if(data.render_target == null) { - } - else if(data.render_target == 'form') { - } - else if($('#' + data.render_target).size() > 0) { - } - else { - form.find("input[type='text']").add('textarea').each(function() { - this.value = ''; - }); - } - - close_loading(); - $button.removeClass('stream-post-button-loading'); - $button.enable(); - }); -} - -function clearMediationForm(element) { - alert(element); - //var $field = $(field); - //$field.value = ''; -} - - -//setInterval(teste, 2000); diff --git a/public/style.css b/public/style.css index 37049ed..d9e01f5 100644 --- a/public/style.css +++ b/public/style.css @@ -3,25 +3,40 @@ background-image: url(/plugins/community_hub/icons/community-hub.png) } -#hub{ +.hub { border:1px solid red; } -#hub .body{ - border:1px solid green; +.hub .title {} + +.hub .description {} + +.hub .live { + border:1px solid red; } -#hub .live{ - border:1px solid yellow; - float: left; - width: 50%; +.hub .live .title {} + +.hub .live .on-air {} + +.hub .live .off-air {} + +.hub .mediation { + border:1px solid green; } -#hub .mediation{ - border:1px solid black; - width: 50%; +.hub .mediation .title {} + +.hub .mediation .expand {} + +.hub .form {} + +.hub .settings { + border:1px solid red; } -#hub-posting-area td { - padding: 0px; -} \ No newline at end of file +.hub .settings .twitter, +.hub .settings .facebook, +.hub .settings .general { + border:1px solid red; +} diff --git a/views/cms/community_hub_plugin/_hub.rhtml b/views/cms/community_hub_plugin/_hub.rhtml new file mode 100644 index 0000000..18dbcb7 --- /dev/null +++ b/views/cms/community_hub_plugin/_hub.rhtml @@ -0,0 +1,17 @@ +