diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb
index c508387..bd3dc23 100644
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -142,12 +142,20 @@ class CmsController < MyProfileController
render :action => 'edit'
end
+ def home_page
+ profile.home_page
+ end
+
post_only :set_home_page
def set_home_page
- @article = profile.articles.find(params[:id])
+ @article = params[:id] != nil ? profile.articles.find(params[:id]) : nil
profile.home_page = @article
profile.save(false)
- session[:notice] = _('"%s" configured as home page.') % @article.name
+ if @article != nil
+ session[:notice] = _('"%s" configured as home page.') % @article.name
+ else
+ session[:notice] = _('home page reseted.')
+ end
redirect_to (request.referer || profile.url)
end
diff --git a/app/views/cms/view.rhtml b/app/views/cms/view.rhtml
index 0fc9454..8c33eb8 100644
--- a/app/views/cms/view.rhtml
+++ b/app/views/cms/view.rhtml
@@ -2,6 +2,18 @@
<%= _('Content management') %>
+<% if !environment.enabled?('cant_change_homepage') && !remove_content_button(:home) %>
+
+ Homepage:
+ <% if profile.home_page %>
+ <%= link_to_article(profile.home_page) %>
+ <%= button_without_text(:'home-not', _('Reset homepage'), { :action => 'set_home_page', :id => nil }, :method => :post) %>
+ <% else %>
+ <%= _('Profile Information') %>
+ <% end %>
+
+<% end %>
+
<% button_bar(:style => 'margin-bottom: 1em;') do %>
<% parent_id = ((@article && @article.allow_children?) ? @article : nil) %>
@@ -56,7 +68,11 @@
<%= button_without_text :eyes, _('Public view'), article.view_url %>
<%= display_spread_button(profile, 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 %>
+ <% else %>
+ <%= button_without_text(:'home-not', _('Reset homepage'), { :action => 'set_home_page', :id => nil }, :method => :post) %>
+ <% end%>
<% end %>
<%= display_delete_button(article) if !remove_content_button(:delete) %>
diff --git a/public/designs/icons/tango/mod/16x16/actions/go-home-not.png b/public/designs/icons/tango/mod/16x16/actions/go-home-not.png
new file mode 100644
index 0000000..f059dae
Binary files /dev/null and b/public/designs/icons/tango/mod/16x16/actions/go-home-not.png differ
diff --git a/public/designs/icons/tango/mod/scalable/actions/go-home-not.svg b/public/designs/icons/tango/mod/scalable/actions/go-home-not.svg
new file mode 100644
index 0000000..391629b
--- /dev/null
+++ b/public/designs/icons/tango/mod/scalable/actions/go-home-not.svg
@@ -0,0 +1,1112 @@
+
+
\ No newline at end of file
diff --git a/public/designs/icons/tango/style.css b/public/designs/icons/tango/style.css
index 4929280..e396ea6 100644
--- a/public/designs/icons/tango/style.css
+++ b/public/designs/icons/tango/style.css
@@ -1,6 +1,7 @@
/******************SMALL ICONS********************/
.icon-edit { background-image: url(Tango/16x16/apps/text-editor.png) }
-.icon-home { background-image: url(Tango/16x16/actions/go-home.png) }
+.icon-home { background-image: url(Tango/16x16/actions/go-home.png) }
+.icon-home-not { background-image: url(mod/16x16/actions/go-home-not.png) }
.icon-new,
.icon-suggest { background-image: url(Tango/16x16/actions/filenew.png) }
.icon-close { background-image: url(Tango/16x16/actions/gtk-cancel.png) }
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 2daf771..03fa7b4 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -3137,7 +3137,7 @@ table.cms-articles a.icon {
text-overflow: ellipsis;
}
-table.cms-articles a.icon, table.cms-articles a.icon-parent-folder {
+table.cms-articles a.icon, table.cms-articles a.icon-parent-folder, .cms-homepage a.icon {
padding: 0px 0px 3px 20px;
background-repeat: no-repeat;
}
diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb
index e82ff3f..af64bbe 100644
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -154,6 +154,36 @@ class CmsControllerTest < ActionController::TestCase
assert_redirected_to profile.url
end
+ should 'be able to reset home page' do
+ a = profile.articles.build(:name => 'my new home page')
+ a.save!
+
+ profile.home_page = a
+ profile.save!
+
+ post :set_home_page, :profile => profile.identifier, :id => nil
+
+ profile.reload
+ assert_equal nil, profile.home_page
+ end
+
+ should 'display default home page' do
+ profile.home_page = nil
+ profile.save!
+ get :index, :profile => profile.identifier
+ assert_tag :tag => 'div', :attributes => { :class => "cms-homepage" }, :descendant => { :tag => "span", :content => /Profile Information/ }
+ end
+
+ should 'display article as home page' do
+ a = profile.articles.build(:name => 'my new home page')
+ a.save!
+ profile.home_page = a
+ profile.save!
+ Article.stubs(:short_description).returns('short description')
+ get :index, :profile => profile.identifier
+ assert_tag :tag => 'div', :attributes => { :class => "cms-homepage" }, :descendant => { :tag => "a", :content => /my new home page/ }
+ end
+
should 'set last_changed_by when creating article' do
login_as(profile.identifier)
--
libgit2 0.21.2