diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb
index cdd7f82..dcc67e6 100644
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -61,6 +61,9 @@ class CmsController < MyProfileController
@article = profile.articles.find(params[:id])
@parent_id = params[:parent_id]
@type = params[:type]
+ if !@article.nil? && @article.blog? || !@type.nil? && @type == 'Blog'
+ @back_url = url_for(:controller => 'profile_editor', :profile => profile.identifier)
+ end
record_coming_from_public_view
if request.post?
@article.last_changed_by = user
@@ -89,6 +92,10 @@ class CmsController < MyProfileController
@parent_id = params[:parent_id]
render :action => 'select_article_type', :layout => false
return
+ else
+ if @type == 'Blog'
+ @back_url = url_for(:controller => 'profile_editor', :profile => profile.identifier)
+ end
end
raise "Invalid article type #{@type}" unless valid_article_type?(@type)
@@ -175,7 +182,9 @@ class CmsController < MyProfileController
protected
def redirect_back
- if params[:back_to] == 'public_view'
+ if params[:back_to] == 'control_panel'
+ redirect_to :controller => 'profile_editor', :profile => @profile.identifier
+ elsif params[:back_to] == 'public_view'
redirect_to @article.url
elsif @article.parent
redirect_to :action => 'view', :id => @article.parent
diff --git a/app/views/cms/_blog.rhtml b/app/views/cms/_blog.rhtml
index 1e4f6ea..57414ef 100644
--- a/app/views/cms/_blog.rhtml
+++ b/app/views/cms/_blog.rhtml
@@ -15,3 +15,5 @@
<%= labelled_form_field(_('Use as description in RSS Feed:'), feed.select(:feed_item_description, [ [ _('Article abstract'), 'abstract'], [ _('Article body'), 'body']])) %>
<% end %>
+
+<%= javascript_tag "$('back_to').value = 'control_panel'" %>
diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml
index 0f70cf1..61e1070 100644
--- a/app/views/content_viewer/view_page.rhtml
+++ b/app/views/content_viewer/view_page.rhtml
@@ -30,11 +30,13 @@
if ( act ) act.className = ( show ? "show" : "hidden" );
}
- <% if logged_in? && current_user.person.has_permission?('post_content', profile) %>
+ <% if logged_in? && current_user.person.has_permission?('post_content', profile) %>
+ <% unless @page.blog? %>
<%= link_to content_tag( 'span', label_for_edit_article(@page) ),
{ :controller => 'cms', :action => 'edit', :id => @page },
:class => 'button with-text icon-edit' %>
+ <% end %>
<% if !(profile.kind_of?(Enterprise) && environment.enabled?('disable_cms')) %>
<% if @page != profile.home_page %>
<%= link_to content_tag( 'span', _('Delete') ),
diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml
index dfb843d..f7f0a5c 100644
--- a/app/views/profile_editor/index.rhtml
+++ b/app/views/profile_editor/index.rhtml
@@ -25,6 +25,12 @@
<%= file_manager_button(_('Manage Content'), 'icons-app/cms.png', :controller => 'cms') unless environment.enabled?('disable_cms') || profile.community? %>
+ <% if profile.has_blog? %>
+ <%= file_manager_button(_('Config my blog'), 'icons-app/blog.png', :controller => 'cms', :action => 'edit', :id => profile.blog) %>
+ <% else %>
+ <%= file_manager_button(_('Create my blog'), 'icons-app/blog-disabled.png', :controller => 'cms', :action => 'new', :type => 'Blog') %>
+ <% end %>
+
<%= file_manager_button(_('Change Password'), 'icons-app/change-password.png', :controller => 'account', :action => 'change_password') if profile.person? %>
<%= file_manager_button(__('Manage friends'), 'icons-app/friends.png', :controller => 'friends', :action => 'index') if profile.person? %>
diff --git a/public/images/icons-app/README b/public/images/icons-app/README
index 2aa8085..edb5fc1 100644
--- a/public/images/icons-app/README
+++ b/public/images/icons-app/README
@@ -45,6 +45,7 @@ gtk-cancel.png dlg-neu
emblem-important.png dlg-neu
gnome-globe.png gnome
header-and-footer.svg Noosfero team
+livejournal.png dlg-neu
### END OF ICONS LISTING ###
Icons rasterization
diff --git a/public/images/icons-app/blog-disabled.png b/public/images/icons-app/blog-disabled.png
new file mode 100644
index 0000000..46d0dff
Binary files /dev/null and b/public/images/icons-app/blog-disabled.png differ
diff --git a/public/images/icons-app/blog.png b/public/images/icons-app/blog.png
new file mode 120000
index 0000000..08c5686
--- /dev/null
+++ b/public/images/icons-app/blog.png
@@ -0,0 +1 @@
+livejournal.png
\ No newline at end of file
diff --git a/public/images/icons-app/livejournal.png b/public/images/icons-app/livejournal.png
new file mode 100644
index 0000000..69b760b
Binary files /dev/null and b/public/images/icons-app/livejournal.png differ
diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb
index 792d509..28ae3b6 100644
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -758,4 +758,28 @@ class CmsControllerTest < Test::Unit::TestCase
assert :tag => 'input', :attributes => {:name => 'article[notify_comments]', :value => 1}
end
+ should 'back to control panel after create blog' do
+ assert_difference Blog, :count do
+ post :new, :type => Blog.name, :profile => profile.identifier, :article => { :name => 'my-blog' }, :back_to => 'control_panel'
+ assert_redirected_to :controller => 'profile_editor', :profile => profile.identifier
+ end
+ end
+
+ should 'back to control panel after config blog' do
+ profile.articles << Blog.new(:name => 'my-blog', :profile => profile)
+ post :edit, :profile => profile.identifier, :id => profile.blog.id, :back_to => 'control_panel'
+ assert_redirected_to :controller => 'profile_editor', :profile => profile.identifier
+ end
+
+ should 'back to control panel if cancel create blog' do
+ get :new, :profile => profile.identifier, :type => Blog.name
+ assert_tag :tag => 'a', :content => 'Cancel', :attributes => { :href => /\/myprofile\/#{profile.identifier}/ }
+ end
+
+ should 'back to control panel if cancel config blog' do
+ profile.articles << Blog.new(:name => 'my-blog', :profile => profile)
+ get :edit, :profile => profile.identifier, :id => profile.blog.id
+ assert_tag :tag => 'a', :content => 'Cancel', :attributes => { :href => /\/myprofile\/#{profile.identifier}/ }
+ end
+
end
diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb
index d801f1c..5a74622 100644
--- a/test/functional/profile_editor_controller_test.rb
+++ b/test/functional/profile_editor_controller_test.rb
@@ -622,4 +622,15 @@ class ProfileEditorControllerTest < Test::Unit::TestCase
assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/default_user/cms' }
end
+ should 'offer to create blog in control panel' do
+ get :index, :profile => 'default_user'
+ assert_tag :tag => 'a', :attributes => { :href => "/myprofile/default_user/cms/new?type=Blog" }
+ end
+
+ should 'offer to config blog in control panel' do
+ profile.articles << Blog.new(:name => 'My blog', :profile => profile)
+ get :index, :profile => 'default_user'
+ assert_tag :tag => 'a', :attributes => { :href => "/myprofile/default_user/cms/edit/#{profile.blog.id}" }
+ end
+
end
--
libgit2 0.21.2