diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb
index f786266..0400ae8 100644
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -235,25 +235,48 @@ class CmsController < MyProfileController
render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'article' }
end
+ def search_communities_to_publish
+ render :text => find_by_contents(:profiles, user.memberships, params['q'], {:page => 1}, {:fields => ['name']})[:results].map {|community| {:id => community.id, :name => community.name} }.to_json
+ end
+
def publish
@article = profile.articles.find(params[:id])
+ @portal_enabled = environment.portal_community && environment.enabled?('use_portal_community')
record_coming
- @groups = profile.memberships - [profile]
- @marked_groups = []
- groups_ids = profile.memberships.map{|m|m.id.to_s}
- @marked_groups = params[:marked_groups].map do |key, item|
- if groups_ids.include?(item[:group_id])
- item.merge :group => Profile.find(item.delete(:group_id))
+ @failed = {}
+ if request.post?
+ article_name = params[:name]
+ task = ApproveArticle.create!(:article => @article, :name => article_name, :target => user, :requestor => user)
+ begin
+ task.finish
+ rescue Exception => ex
+ @failed[ex.message] ? @failed[ex.message] << item.name : @failed[ex.message] = [item.name]
+ end
+ if @failed.blank?
+ session[:notice] = _("Your publish request was sent successfully")
+ if @back_to
+ redirect_to @back_to
+ else
+ redirect_to @article.view_url
+ end
end
- end.compact unless params[:marked_groups].nil?
+ end
+ end
+
+ def publish_on_communities
if request.post?
+ @back_to = params[:back_to]
+ @article = profile.articles.find(params[:id])
@failed = {}
+ article_name = params[:name]
+ params_marked = params['q'].split(',').select { |marked| user.memberships.map(&:id).include? marked.to_i }
+ @marked_groups = Profile.find(params_marked)
@marked_groups.each do |item|
- task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile)
+ task = ApproveArticle.create!(:article => @article, :name => article_name, :target => item, :requestor => user)
begin
- task.finish unless item[:group].moderated_articles?
+ task.finish unless item.moderated_articles?
rescue Exception => ex
- @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name]
+ @failed[ex.message] ? @failed[ex.message] << item.name : @failed[ex.message] = [item.name]
end
end
if @failed.blank?
@@ -268,9 +291,9 @@ class CmsController < MyProfileController
end
def publish_on_portal_community
- @article = profile.articles.find(params[:id])
if request.post?
- if environment.portal_community
+ @article = profile.articles.find(params[:id])
+ if environment.portal_community && environment.enabled?('use_portal_community')
task = ApproveArticle.create!(:article => @article, :name => params[:name], :target => environment.portal_community, :requestor => user)
begin
task.finish unless environment.portal_community.moderated_articles?
diff --git a/app/helpers/cms_helper.rb b/app/helpers/cms_helper.rb
index ac9c6e0..a3ef064 100644
--- a/app/helpers/cms_helper.rb
+++ b/app/helpers/cms_helper.rb
@@ -40,11 +40,9 @@ module CmsHelper
end
end
- def display_spread_button(profile, article)
- if profile.person?
- expirable_button article, :spread, _('Spread this'), :action => 'publish', :id => article.id
- elsif profile.community? && environment.portal_community
- expirable_button article, :spread, _('Spread this'), :action => 'publish_on_portal_community', :id => article.id
+ def display_spread_button(article)
+ if article.public?
+ expirable_button article, :spread, _('Spread this'), {:action => 'publish', :id => article.id}, {:class => 'colorbox'}
end
end
diff --git a/app/helpers/token_helper.rb b/app/helpers/token_helper.rb
index bb601b8..6d995ec 100644
--- a/app/helpers/token_helper.rb
+++ b/app/helpers/token_helper.rb
@@ -12,6 +12,7 @@ module TokenHelper
options[:search_delay] ||= 1000
options[:prevent_duplicates] ||= true
options[:backspace_delete_item] ||= false
+ options[:zindex] ||= 999
options[:focus] ||= false
options[:avoid_enter] ||= true
options[:on_result] ||= 'null'
@@ -30,6 +31,7 @@ module TokenHelper
searchDelay: #{options[:search_delay].to_json},
preventDuplicates: #{options[:prevent_duplicates].to_json},
backspaceDeleteItem: #{options[:backspace_delete_item].to_json},
+ zindex: #{options[:zindex].to_json},
queryParam: #{name.to_json},
tokenLimit: #{options[:token_limit].to_json},
onResult: #{options[:on_result]},
@@ -48,4 +50,4 @@ module TokenHelper
result
end
-end
\ No newline at end of file
+end
diff --git a/app/views/cms/publish.html.erb b/app/views/cms/publish.html.erb
index 5e6c115..2c4e476 100644
--- a/app/views/cms/publish.html.erb
+++ b/app/views/cms/publish.html.erb
@@ -1,4 +1,19 @@
-
<%= _('Select the groups where you want to publish your article') %>
+
+
+
+
<%= _('Where do you want to publish this article?') %>
<% if !@failed.blank? %>
@@ -14,15 +29,57 @@
<% end %>
-<%= form_tag do%>
- <%= hidden_field_tag :back_to, @back_to %>
- <% @groups.each do |group| %>
- <%= labelled_check_box group.name, "marked_groups[#{group.id}][group_id]", group.id, @marked_groups.include?(group) %>
- <%= labelled_text_field _('Title') + ': ', "marked_groups[#{group.id}][name]", @article.name, :style => 'width: 100%' %>
-
- <% end %>
+
+ -
+ <%= _("Publish this article on your profile") %>
+
<%= _('You can publish this article on your profile where your friends and followers will see.') %>
+ <%= form_tag do %>
+ <%= hidden_field_tag :back_to, @back_to %>
+
+ <%= labelled_text_field _('Title'), 'name', @article.name %>
+
- <% button_bar do %>
- <%= submit_button 'spread', _('Spread this'), :cancel => @back_to %>
+ <% button_bar do %>
+ <%= submit_button 'spread', _('Spread this') %>
+ <% end %>
+ <% end %>
+
+
+ -
+ <%= _("Publish this article on communities you are part of") %>
+
<%= _('You can submit this article to one or more communities you are a member of, just search for the community below.') %>
+ <%= form_tag :action => 'publish_on_communities', :id => @article.id do %>
+ <%= hidden_field_tag :back_to, @back_to %>
+ <% search_action = url_for(:action => 'search_communities_to_publish') %>
+ <%= token_input_field_tag(:q, 'search-communities-to-publish', search_action, { :hint_text => _('Type in a search for your community'), :zindex => 10000, :focus => false }) %>
+
+
+ <%= labelled_text_field _('Title'), 'name', @article.name %>
+
+ <% button_bar do %>
+ <%= submit_button 'spread', _('Spread this') %>
+ <% end %>
+ <% end %>
+
+
+
+<% if @portal_enabled %>
+ -
+ <%= _("Publish your article on portal community") %>
+
<%= _('You can suggest this article to the portal community, where it can show up on the homepage.') %>
+
+ <%= form_tag :action => 'publish_on_portal_community', :id => @article.id do %>
+ <%= hidden_field_tag :back_to, @back_to %>
+
+ <%= labelled_text_field _('Title'), :name, @article.name %>
+
+
+ <% button_bar do %>
+ <%= submit_button 'spread', _('Spread this') %>
+ <% end %>
<% end %>
+
<% end %>
+
+
+
diff --git a/app/views/cms/view.html.erb b/app/views/cms/view.html.erb
index adba5fa..1403ecd 100644
--- a/app/views/cms/view.html.erb
+++ b/app/views/cms/view.html.erb
@@ -66,7 +66,7 @@
<%= expirable_button article, :edit, _('Edit'), {:action => 'edit', :id => article.id} if !remove_content_button(:edit) %>
<%= button_without_text :eyes, _('Public view'), article.view_url %>
- <%= display_spread_button(profile, article) unless article.folder? || remove_content_button(:spread)%>
+ <%= display_spread_button(article) unless article.folder? || remove_content_button(:spread)%>
<% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %>
<% if profile.home_page != article %>
<%= expirable_button article, :home, _('Use as homepage'), { :action => 'set_home_page', :id => article.id }, :method => :post %>
diff --git a/app/views/content_viewer/_article_toolbar.html.erb b/app/views/content_viewer/_article_toolbar.html.erb
index b371e22..5c1c2d4 100644
--- a/app/views/content_viewer/_article_toolbar.html.erb
+++ b/app/views/content_viewer/_article_toolbar.html.erb
@@ -15,15 +15,9 @@
<%= expirable_button @page, :delete, content, url, options %>
<% end %>
- <% if !@page.folder? && @page.allow_spread?(user) && !remove_content_button(:spread) %>
- <% content = content_tag( 'span', _('Spread this') ) %>
- <% url = nil %>
- <% if profile.kind_of?(Person) %>
- <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %>
- <% elsif profile.kind_of?(Community) && environment.portal_community %>
- <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish_on_portal_community', :id => @page.id }) %>
- <% end %>
- <%= expirable_button @page, :spread, content, url if url %>
+ <% if !@page.folder? && @page.public? && !remove_content_button(:spread) %>
+ <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'publish', :id => @page.id }) %>
+ <%= expirable_button @page, :spread, content_tag( 'span', _('Spread this') ), url, {:class => 'colorbox'} if url %>
<% end %>
<% if !@page.gallery? && (@page.allow_create?(user) || (@page.parent && @page.parent.allow_create?(user))) %>
diff --git a/public/javascripts/jquery.tokeninput.js b/public/javascripts/jquery.tokeninput.js
index 3abba0a..f463ac7 100644
--- a/public/javascripts/jquery.tokeninput.js
+++ b/public/javascripts/jquery.tokeninput.js
@@ -35,6 +35,7 @@ var DEFAULT_SETTINGS = {
onAdd: null,
onDelete: null,
idPrefix: "token-input-",
+ zindex: 999,
backspaceDeleteItem: true
};
@@ -628,7 +629,7 @@ $.TokenList = function (input, url_or_data, options) {
position: "absolute",
top: $(token_list).offset().top + $(token_list).outerHeight(),
left: $(token_list).offset().left,
- zindex: 999
+ 'z-index': settings.zindex
}).show();
else
dropdown.css({
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 1a84d34..d17182f 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -2137,7 +2137,7 @@ a.button.disabled, input.disabled {
.recent-documents-block .block-footer-content a:hover {
text-decoration: underline;
}
-/* ==> blocks/disabled-enterprise-message-block.css <<= */
+/* ==> blocks/disabled-enterprise-message-block.css <<= */
.disabled-enterprise-message-block {
@@ -2153,12 +2153,12 @@ a.button.disabled, input.disabled {
font-size: 80%;
background: #ffffa9;
}
-/* ==> blocks/article-block.css <<= */
+/* ==> blocks/article-block.css <<= */
.article-block {
overflow: hidden;
}
-/* ==> blocks/main-block.css <<= */
+/* ==> blocks/main-block.css <<= */
/*
Use article.css for article related css
@@ -2179,7 +2179,7 @@ div#activation_enterprise {
div#activation_enterprise label, div#activation_enterprise input, div#activation_enterprise div {
display: inline
}
-/* ==> blocks/slideshow-block.css <<= */
+/* ==> blocks/slideshow-block.css <<= */
.slideshow-block .slideshow-container {
margin-bottom: 10px;
@@ -2244,7 +2244,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
display: inline-block;
width: 16px;
}
-/* ==> blocks/products-block.css <<= */
+/* ==> blocks/products-block.css <<= */
.products-block ul {
margin: 0px;
@@ -2277,7 +2277,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
#content .products-block li a:hover {
color: #fff;
}
-/* ==> blocks/blog-archives-block.css <<= */
+/* ==> blocks/blog-archives-block.css <<= */
#content .blog-archives-block {
padding: 10px 0px 10px 10px;
@@ -2297,7 +2297,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
padding: 5px 0px 10px 10px;
font-size: 12px;
}
-/* ==> blocks/profile-info-block.css <<= */
+/* ==> blocks/profile-info-block.css <<= */
.profile-info-block h2 {
@@ -2400,7 +2400,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
margin: 0px 0px 5px 0px;
padding: 2px;
}
-/* ==> blocks/location-block.css <<= */
+/* ==> blocks/location-block.css <<= */
.location-block {
text-align: center;
@@ -2413,7 +2413,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
background: #FFF;
border: 1px solid #888;
}
-/* ==> blocks/profile-image-block.css <<= */
+/* ==> blocks/profile-image-block.css <<= */
.profile-image-block {
@@ -2448,7 +2448,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
list-style: none;
margin-bottom: 8px;
}
-/* ==> blocks/sellers-search-block.css <<= */
+/* ==> blocks/sellers-search-block.css <<= */
#content .sellers-search-block {
@@ -2507,7 +2507,7 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
margin: 0px;
float: none;
}
-/* ==> blocks/feed-reader-block.css <<= */
+/* ==> blocks/feed-reader-block.css <<= */
#content .feed-reader-block {
padding: 10px 0px 10px 10px;
@@ -3266,6 +3266,52 @@ table.cms-articles .icon:hover {
background-color: transparent;
}
+.select-publish-target {
+ margin: 10px 10px 0px 10px;
+}
+
+.publish-targets {
+ padding: 10px;
+ margin: 0px;
+}
+
+.publish-targets>li {
+ list-style: none;
+ padding: 10px 20px 5px 10px;
+}
+
+.publish-targets li.mouseover {
+ background-color: #eeeeec;
+}
+
+.publish-targets div.publish-article-title, .publish-targets .description {
+ width: 384px;
+ margin-top: 2px;
+}
+
+.publish-targets div.publish-article-title .collapsed {
+ background-image: url("../images/icons-task/closed-arrow-hover.png");
+ background-repeat: no-repeat;
+ background-position: 3px 0;
+}
+
+.publish-targets div.publish-article-title .expanded {
+ background-image: url("../images/icons-task/opened-arrow-hover.png");
+ background-repeat: no-repeat;
+ background-position: 3px 0;
+}
+
+.publish-targets div.publish-article-title label {
+ padding-left: 20px;
+}
+
+.publish-targets div.publish-article-title input {
+ width: 100%;
+ border: 1px solid #999;
+ padding: 3px 8px;
+ margin-bottom: 2px;
+}
+
.select-article-type {
padding: 5px 20px;
width: 455px;
@@ -6514,7 +6560,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img {
/* AutoComplete*/
.formfield input.ui-autocomplete-loading { background: url('/images/loading-small.gif') right center no-repeat, url("../images/input-bg.gif") no-repeat left top; }
-
+
.ui-autocomplete-category {
font-weight: bold;
padding: .2em .4em;
diff --git a/test/unit/cms_helper_test.rb b/test/unit/cms_helper_test.rb
index ff1a4e8..c35e9e2 100644
--- a/test/unit/cms_helper_test.rb
+++ b/test/unit/cms_helper_test.rb
@@ -48,41 +48,22 @@ class CmsHelperTest < ActionView::TestCase
result = link_to_article(file)
end
- should 'display spread button when profile is a person' do
+ should 'display spread button when content is public' do
plugins.stubs(:dispatch).returns([])
profile = fast_create(Person)
article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil)
- result = display_spread_button(profile, article)
+ result = display_spread_button(article)
end
- should 'display spread button when profile is a community and env has portal_community' do
+ should 'not display spread button when content is not public' do
plugins.stubs(:dispatch).returns([])
- env = fast_create(Environment)
- env.expects(:portal_community).returns(true)
- profile = fast_create(Community, :environment_id => env.id)
- expects(:environment).returns(env)
-
- article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
-
- expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil)
-
- result = display_spread_button(profile, article)
- end
-
- should 'not display spread button when profile is a community and env has not portal_community' do
- plugins.stubs(:dispatch).returns([])
- env = fast_create(Environment)
- env.expects(:portal_community).returns(nil)
- profile = fast_create(Community, :environment_id => env.id)
- expects(:environment).returns(env)
-
- article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id)
-
- expects(:link_to).with('Spread this', {:action => 'publish_on_portal_community', :id => article.id}, :class => 'button with-text icon-spread', :title => nil).never
+ profile = fast_create(Person)
+ article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id, :published => false)
+ expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil).never
- result = display_spread_button(profile, article)
+ result = display_spread_button(article)
end
should 'display delete_button to folder' do
--
libgit2 0.21.2 |