Skip to content

Commit

Permalink
Added page delete functionality, added permanent page functionality (…
Browse files Browse the repository at this point in the history
…permanent pages cant be un-published or deleted)
  • Loading branch information
jamesbrooks committed Aug 25, 2008
1 parent 9f0e9c8 commit ea517a0
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
1 change: 1 addition & 0 deletions generators/hush_cms/templates/hush_cms_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def self.up
t.string :title, :slug
t.text :content
t.datetime :published_at
t.boolean :permanent, :default => false
t.timestamps
end

Expand Down
Binary file added install/images/page_delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added install/images/shield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion install/stylesheets/hush_cms_admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ ul#navigation li#nav-comments a {
#sidebar a#sidebar-publish,
#sidebar a#sidebar-unpublish,
#sidebar a#sidebar-edit-page,
#sidebar a#sidebar-delete-page,
#sidebar a#sidebar-new-category,
#sidebar a#sidebar-edit-category,
#sidebar a#sidebar-new-post,
#sidebar a#sidebar-edit-post,
#sidebar a#sidebar-delete-post,
#sidebar a#sidebar-new-snippet {
#sidebar a#sidebar-new-snippet,
#sidebar a#sidebar-permanent {
display: block;
font-size: 0.8em;
color: #278FD5;
Expand All @@ -118,6 +120,7 @@ ul#navigation li#nav-comments a {
#sidebar a#sidebar-publish:hover,
#sidebar a#sidebar-unpublish:hover,
#sidebar a#sidebar-edit-page:hover,
#sidebar a#sidebar-delete-page:hover,
#sidebar a#sidebar-new-category:hover,
#sidebar a#sidebar-edit-category:hover,
#sidebar a#sidebar-new-post:hover,
Expand All @@ -138,6 +141,9 @@ ul#navigation li#nav-comments a {
#sidebar a#sidebar-edit-page {
background-image: url(../images/hush_cms/page_edit.png);
}
#sidebar a#sidebar-delete-page {
background-image: url(../images/hush_cms/page_delete.png);
}
#sidebar a#sidebar-new-category,
#sidebar a#sidebar-new-post {
background-image: url(../images/hush_cms/newspaper_add.png);
Expand All @@ -152,6 +158,10 @@ ul#navigation li#nav-comments a {
#sidebar a#sidebar-delete-post {
background-image: url(../images/hush_cms/newspaper_delete.png);
}
#sidebar a#sidebar-permanent {
color: #B1A656;
background-image: url(../images/hush_cms/shield.png);
}

#content {
float: left;
Expand Down
10 changes: 8 additions & 2 deletions lib/controllers/hush_cms_admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,21 @@ def update
end

def destroy
if @page.permanent?
redirect_to :back
else
@page.destroy
redirect_to @page.parent ? hush_cms_admin_page_url(@page.parent) : hush_cms_admin_pages_url
end
end

def publish
@page.publish!
@page.publish! if @page.permanent?
redirect_to hush_cms_admin_page_url(@page)
end

def unpublish
@page.unpublish!
@page.unpublish! if @page.permanent?
redirect_to hush_cms_admin_page_url(@page)
end

Expand Down
8 changes: 8 additions & 0 deletions lib/models/hush_cms/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def unpublish!
update_attribute :published_at, nil
end

def make_permanent!
update_attribute :permanent, true
end

def make_unpermanent!
update_attribute :permanent, false
end

def breadcrumbs
parent ? parent.breadcrumbs << self : [self]
end
Expand Down
15 changes: 10 additions & 5 deletions lib/views/hush_cms_admin/pages/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
- add_link hush_cms_page_url(@page.path)

- content_for :sidebar do
- if @page.published?
= link_to 'Un-publish Page', unpublish_hush_cms_admin_page_path(@page), :method => :put, :id => 'sidebar-publish'
- if @page.permanent?
= link_to_function 'Permanent Page', 'alert("This page is permanent and cannot be deleted or un-published")', :id => 'sidebar-permanent'
- else
= link_to 'Publish Page', publish_hush_cms_admin_page_path(@page), :method => :put, :id => 'sidebar-unpublish'

= link_to 'Edit Page', edit_hush_cms_admin_page_path(@page), :id => 'sidebar-edit-page'
- if @page.published?
= link_to 'Un-publish Page', unpublish_hush_cms_admin_page_path(@page), :method => :put, :id => 'sidebar-publish'
- else
= link_to 'Publish Page', publish_hush_cms_admin_page_path(@page), :method => :put, :id => 'sidebar-unpublish'

= link_to 'Delete Page', hush_cms_admin_page_path(@page), :method => :delete, :confirm => 'Are you sure?', :id => 'sidebar-delete-page'

= link_to 'Edit Page', edit_hush_cms_admin_page_path(@page), :id => 'sidebar-edit-page'
= link_to 'New Sub-page', new_hush_cms_admin_page_path(:parent => @page.id), :id => 'sidebar-new-page'

= render :partial => 'pages', :object => @page.children
Expand Down

0 comments on commit ea517a0

Please sign in to comment.