From 2e2587aa5d90899b40af75b23579955680db77e8 Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Tue, 8 Apr 2014 11:31:35 -0300 Subject: [PATCH] #community dashboard - add infra --- controllers/public/community_hub_plugin_public_controller.rb | 38 +++++++++++++++++++++++++++++++++++++- lib/community_hub_plugin.rb | 6 +----- lib/community_hub_plugin/hub.rb | 14 ++++++-------- lib/community_hub_plugin/hub_stream_post.rb | 7 ------- lib/ext/article.rb | 6 +++--- public/javascripts/community_hub.js | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/javascripts/stream_post_form.js | 62 -------------------------------------------------------------- public/style.css | 41 ++++++++++++++++++++++++++++------------- views/cms/community_hub_plugin/_hub.rhtml | 17 +++++++++++++++++ views/community_hub_plugin_public/_post.rhtml | 39 +++++++++++++++++++++++++++++++++++++++ views/community_hub_plugin_public/_post_form.rhtml | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ views/community_hub_plugin_public/_settings.rhtml | 12 ++++++++++++ views/content_viewer/_comment.rhtml | 37 ------------------------------------- views/content_viewer/_hub_mediation_item.rhtml | 1 - views/content_viewer/hub.rhtml | 136 +++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------- 15 files changed, 363 insertions(+), 250 deletions(-) delete mode 100644 lib/community_hub_plugin/hub_stream_post.rb create mode 100644 public/javascripts/community_hub.js delete mode 100644 public/javascripts/stream_post_form.js create mode 100644 views/cms/community_hub_plugin/_hub.rhtml create mode 100644 views/community_hub_plugin_public/_post.rhtml create mode 100644 views/community_hub_plugin_public/_post_form.rhtml create mode 100644 views/community_hub_plugin_public/_settings.rhtml delete mode 100644 views/content_viewer/_comment.rhtml delete mode 100644 views/content_viewer/_hub_mediation_item.rhtml 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 @@ +
+ +

<%= _("HUB Settings") %>

+ + <%= required_fields_message %> + +
+ <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> +
+ +
+ <%= required labelled_form_field(_('Description'), text_area(:article, 'body', :style => 'width: 99%;')) %> +
+ + <%= labelled_form_field(_('Hashtags (TWITTER)'), text_field(:article, 'hashtags_twitter')) %> + +
\ No newline at end of file diff --git a/views/community_hub_plugin_public/_post.rhtml b/views/community_hub_plugin_public/_post.rhtml new file mode 100644 index 0000000..8230b58 --- /dev/null +++ b/views/community_hub_plugin_public/_post.rhtml @@ -0,0 +1,39 @@ +
  • + + + +
  • \ No newline at end of file diff --git a/views/community_hub_plugin_public/_post_form.rhtml b/views/community_hub_plugin_public/_post_form.rhtml new file mode 100644 index 0000000..b23b6ea --- /dev/null +++ b/views/community_hub_plugin_public/_post_form.rhtml @@ -0,0 +1,82 @@ + <% if user_role == 'visitor' %> + + <% remote_form_for( :comment, + CommunityHubPlugin::HubStreamPost.new, + :url => { + :profile => profile.identifier, + :controller => 'comment', + :action => 'create', + :id => @page.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 == 'admin' %> + + <%= 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 => @page.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 => @page.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'))%> +
    +
    + + <% end %> + + <% end %> \ No newline at end of file diff --git a/views/community_hub_plugin_public/_settings.rhtml b/views/community_hub_plugin_public/_settings.rhtml new file mode 100644 index 0000000..d63cc0b --- /dev/null +++ b/views/community_hub_plugin_public/_settings.rhtml @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/views/content_viewer/_comment.rhtml b/views/content_viewer/_comment.rhtml deleted file mode 100644 index 18c60c8..0000000 --- a/views/content_viewer/_comment.rhtml +++ /dev/null @@ -1,37 +0,0 @@ -
  • - - - -
  • diff --git a/views/content_viewer/_hub_mediation_item.rhtml b/views/content_viewer/_hub_mediation_item.rhtml deleted file mode 100644 index 323953d..0000000 --- a/views/content_viewer/_hub_mediation_item.rhtml +++ /dev/null @@ -1 +0,0 @@ -wueyriweuyriweuyriwuery \ No newline at end of file diff --git a/views/content_viewer/hub.rhtml b/views/content_viewer/hub.rhtml index 7d46bf8..5d5f19a 100644 --- a/views/content_viewer/hub.rhtml +++ b/views/content_viewer/hub.rhtml @@ -1,134 +1,44 @@ -
    +
    -
    jdhfjdhf
    +
    <%= @page.title %> HUB
    -
    djfhkdhfkdjhfdkhffkdjfhkdjfh
    +
    <%= @page.body %>

    -
    -
    - Nome do Título - AO VIVO -
    -
    -
      - <%= render :partial => 'content_viewer/comment', :collection => @comments %> - <%= pagination_links @comments, :param_name => 'comment_page' %> -
    -
    -
    - -
    - - -
    - - <% remote_form_for( :comment, - CommunityHubPlugin::HubStreamPost.new, - :url => { - :profile => profile.identifier, - :controller => 'comment', - :action => 'create', - :id => @page.id - }, - :html => { :class => 'comment_form' } ) do |f| %> - -
    - <%= _("Streaming") %> -
    -
    - <%= f.text_area(:body, - :style => 'width: 99%;', - :placeholder => _('Type your message here')) %> -
    -
    - <%= submit_button('add', _('Post message'), :onclick => "send_message_for_stream(this); return false;") %> -
    - - <% end %> - +
    +

    + <%= @page.title %><%= _("Live") %> +

    +
      +
    + <%= check_box_tag 'auto_scrolling', 'yes', true %><%= _("Auto scrolling") %>

    -
    -
    - Mediação -
    -
    - <%= render :partial => 'hub_mediation_item' %> -
    +
    +

    + <%= _("Mediation") %>+ +

    +
      +

    -
    - - <% - def mediation_timestamp - - end - %> - - <%= 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 => @page.id, - :back_to => "" - }, - :before => "tinymce.triggerSave()", - :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 => 419 %> - <%= f.hidden_field :name, :value => "hub-mediation-" %> - <%= f.hidden_field :published, :value => true %> - <%= f.hidden_field :license_id, :value => "" %> - <%= hidden_field_tag "article[category_ids][]", "" %> - <%= f.hidden_field :language, :value => "en" %> - -
    -
    - <%= _("Posting for mediation") %> -
    -
    - <%= f.text_area(:body, - :style => 'width: 99%;', - :class => 'mceEditor', - :placeholder => _('Type your message for mediation here')) %> -
    -
    - <%= submit_button('add', _('Save'))%> -
    -
    - - <% end %> + +
    + <%= render :partial => "community_hub_plugin_public/post_form", :locals => {:user_role => 'admin'} %> +
    +
    + <%= render :partial => "community_hub_plugin_public/settings" %>
    -
    +
    \ No newline at end of file -- libgit2 0.21.2