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 @@ +