From 49e7109df55b26dae99c31b796296b4c533750d7 Mon Sep 17 00:00:00 2001 From: Francisco Marcelo de Araújo Lima Júnior Date: Fri, 4 Apr 2014 16:36:02 -0300 Subject: [PATCH] #community dashboard - add infra --- app/controllers/public/content_viewer_controller.rb | 2 ++ app/models/article.rb | 4 ++++ plugins/community_hub/controllers/myprofile/community_dashboard_plugin_myprofile_controller.rb | 18 ++++++++++++++++++ plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb | 7 +++++++ plugins/community_hub/lib/community_hub_plugin.rb | 38 ++++++++++++++++++++++++++++++++++++++ plugins/community_hub/lib/community_hub_plugin/hub.rb | 27 +++++++++++++++++++++++++++ plugins/community_hub/lib/community_hub_plugin/hub_stream_post.rb | 7 +++++++ plugins/community_hub/lib/ext/article.rb | 12 ++++++++++++ plugins/community_hub/public/icons/community-hub.png | Bin 0 -> 442 bytes plugins/community_hub/public/javascripts/stream_post_form.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/community_hub/public/style.css | 27 +++++++++++++++++++++++++++ plugins/community_hub/views/content_viewer/_comment.rhtml | 37 +++++++++++++++++++++++++++++++++++++ plugins/community_hub/views/content_viewer/_hub_mediation_item.rhtml | 1 + plugins/community_hub/views/content_viewer/hub.rhtml | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 376 insertions(+), 0 deletions(-) create mode 100644 plugins/community_hub/controllers/myprofile/community_dashboard_plugin_myprofile_controller.rb create mode 100644 plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb create mode 100644 plugins/community_hub/lib/community_hub_plugin.rb create mode 100644 plugins/community_hub/lib/community_hub_plugin/hub.rb create mode 100644 plugins/community_hub/lib/community_hub_plugin/hub_stream_post.rb create mode 100644 plugins/community_hub/lib/ext/article.rb create mode 100644 plugins/community_hub/public/icons/community-hub.png create mode 100644 plugins/community_hub/public/javascripts/stream_post_form.js create mode 100644 plugins/community_hub/public/style.css create mode 100644 plugins/community_hub/views/content_viewer/_comment.rhtml create mode 100644 plugins/community_hub/views/content_viewer/_hub_mediation_item.rhtml create mode 100644 plugins/community_hub/views/content_viewer/hub.rhtml diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 40c8f9e..fc38e0b 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -115,6 +115,8 @@ class ContentViewerController < ApplicationController if params[:slideshow] render :action => 'slideshow', :layout => 'slideshow' end + + render :file => @page.view_page, :layout => true end def article_versions diff --git a/app/models/article.rb b/app/models/article.rb index 1a615ea..4d20a8e 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -730,6 +730,10 @@ class Article < ActiveRecord::Base true end + def view_page + "content_viewer/view_page.rhtml" + end + private def sanitize_tag_list diff --git a/plugins/community_hub/controllers/myprofile/community_dashboard_plugin_myprofile_controller.rb b/plugins/community_hub/controllers/myprofile/community_dashboard_plugin_myprofile_controller.rb new file mode 100644 index 0000000..ad2d85a --- /dev/null +++ b/plugins/community_hub/controllers/myprofile/community_dashboard_plugin_myprofile_controller.rb @@ -0,0 +1,18 @@ +class CommunityDashboardPluginMyprofileController < MyProfileController + + append_view_path File.join(File.dirname(__FILE__) + '/../../views') + + before_filter :allow_edit_dashboard, :only => :save_order + + def save_order + dashboard = profile.articles.find(params[:dashboard]) + redirect_to dashboard.url + end + + protected + + def allow_edit_dashboard + render_access_denied unless profile.articles.find(params[:dashboard]).allow_edit?(user) + end + +end 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 new file mode 100644 index 0000000..b47c7be --- /dev/null +++ b/plugins/community_hub/controllers/public/community_hub_plugin_public_controller.rb @@ -0,0 +1,7 @@ +class CommunityHubPluginPublicController < PublicController + append_view_path File.join(File.dirname(__FILE__) + '/../../views') + + def delete_post + 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 new file mode 100644 index 0000000..2e93944 --- /dev/null +++ b/plugins/community_hub/lib/community_hub_plugin.rb @@ -0,0 +1,38 @@ +class CommunityHubPlugin < Noosfero::Plugin + + def self.plugin_name + 'Community Hub' + end + + def self.plugin_description + _("New kind of content for communities.") + end + + def stylesheet? + true + end + + def js_files + 'javascripts/stream_post_form.js' + end + + def content_types + if context.respond_to?(:params) && context.params + types = [] + parent_id = context.params[:parent_id] + types << CommunityHubPlugin::Hub if context.profile.community? && !parent_id + types + else + [CommunityHubPlugin::Hub] + end + end + + #def self.extra_blocks + # { CommunityHubPlugin::HubBlock => {:position => 1} } + #end + + def content_remove_new(page) + page.kind_of?(CommunityHubPlugin::Hub) + end + +end diff --git a/plugins/community_hub/lib/community_hub_plugin/hub.rb b/plugins/community_hub/lib/community_hub_plugin/hub.rb new file mode 100644 index 0000000..d522f74 --- /dev/null +++ b/plugins/community_hub/lib/community_hub_plugin/hub.rb @@ -0,0 +1,27 @@ +class CommunityHubPlugin::Hub < Folder + + def self.icon_name(article = nil) + 'community-hub' + end + + def self.short_description + _("Hub") + end + + def self.description + _('Defines a hub.') + end + + def view_page + "content_viewer/hub.rhtml" + end + + def bli + "bli" + end + + def accept_comments? + true + end + +end \ No newline at end of file diff --git a/plugins/community_hub/lib/community_hub_plugin/hub_stream_post.rb b/plugins/community_hub/lib/community_hub_plugin/hub_stream_post.rb new file mode 100644 index 0000000..1ab0bbc --- /dev/null +++ b/plugins/community_hub/lib/community_hub_plugin/hub_stream_post.rb @@ -0,0 +1,7 @@ +class CommunityHubPlugin::HubStreamPost < Comment + + def bli + "" + end + +end \ No newline at end of file diff --git a/plugins/community_hub/lib/ext/article.rb b/plugins/community_hub/lib/ext/article.rb new file mode 100644 index 0000000..eceedc0 --- /dev/null +++ b/plugins/community_hub/lib/ext/article.rb @@ -0,0 +1,12 @@ +require_dependency 'article' + +class Article + + #before_create do |article| + # if article.parent.kind_of?(CommunityDashboardPlugin::Hub) + # article.accept_comments = article.parent.accept_comments + # end + # true + #end + +end diff --git a/plugins/community_hub/public/icons/community-hub.png b/plugins/community_hub/public/icons/community-hub.png new file mode 100644 index 0000000..6aadcd0 Binary files /dev/null and b/plugins/community_hub/public/icons/community-hub.png differ diff --git a/plugins/community_hub/public/javascripts/stream_post_form.js b/plugins/community_hub/public/javascripts/stream_post_form.js new file mode 100644 index 0000000..ab8afa5 --- /dev/null +++ b/plugins/community_hub/public/javascripts/stream_post_form.js @@ -0,0 +1,62 @@ +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/plugins/community_hub/public/style.css b/plugins/community_hub/public/style.css new file mode 100644 index 0000000..37049ed --- /dev/null +++ b/plugins/community_hub/public/style.css @@ -0,0 +1,27 @@ +.icon-newcommunity-hub, +.icon-community-hub { + background-image: url(/plugins/community_hub/icons/community-hub.png) +} + +#hub{ + border:1px solid red; +} + +#hub .body{ + border:1px solid green; +} + +#hub .live{ + border:1px solid yellow; + float: left; + width: 50%; +} + +#hub .mediation{ + border:1px solid black; + width: 50%; +} + +#hub-posting-area td { + padding: 0px; +} \ No newline at end of file diff --git a/plugins/community_hub/views/content_viewer/_comment.rhtml b/plugins/community_hub/views/content_viewer/_comment.rhtml new file mode 100644 index 0000000..18c60c8 --- /dev/null +++ b/plugins/community_hub/views/content_viewer/_comment.rhtml @@ -0,0 +1,37 @@ +
  • + + + +
  • diff --git a/plugins/community_hub/views/content_viewer/_hub_mediation_item.rhtml b/plugins/community_hub/views/content_viewer/_hub_mediation_item.rhtml new file mode 100644 index 0000000..323953d --- /dev/null +++ b/plugins/community_hub/views/content_viewer/_hub_mediation_item.rhtml @@ -0,0 +1 @@ +wueyriweuyriweuyriwuery \ 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 new file mode 100644 index 0000000..7d46bf8 --- /dev/null +++ b/plugins/community_hub/views/content_viewer/hub.rhtml @@ -0,0 +1,134 @@ + +
    + + +
    jdhfjdhf
    + + +
    djfhkdhfkdjhfdkhffkdjfhkdjfh
    + +
    + + +
    +
    + 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 %> + +
    + +
    + + +
    +
    + Mediação +
    +
    + <%= render :partial => 'hub_mediation_item' %> +
    +
    + +
    + +
    + + <% + 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 %> + +
    + +
    -- libgit2 0.21.2