Class: Gluttonberg::Admin::Content::PagesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- BaseController
- Gluttonberg::Admin::Content::PagesController
- Defined in:
- app/controllers/gluttonberg/admin/content/pages_controller.rb
Instance Method Summary collapse
-
#collapse ⇒ Object
Collapse a single page in pages list.
- #collapse_all ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #destroy ⇒ Object
- #duplicate ⇒ Object
-
#expand ⇒ Object
Expand a children of single page in pages list.
- #expand_all ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
-
#pages_list_for_tinymce ⇒ Object
Pages/posts lists for redactor.
- #show ⇒ Object
-
#update_home ⇒ Object
This action is called from configuration in an ajax call for update home page.
Instance Method Details
#collapse ⇒ Object
Collapse a single page in pages list
101 102 103 104 105 106 107 108 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 101 def collapse @page = Page.find(params[:id]) collapse = CollapsedPage.where(:page_id => @page.id, :user_id => current_user.id).first if collapse.blank? CollapsedPage.create(:page_id => @page.id, :user_id => current_user.id) end render :json => {:status => true} end |
#collapse_all ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 116 def collapse_all @pages = Page.all @pages.each do |page| if page.children.count > 0 collapse = CollapsedPage.where(:page_id => page.id, :user_id => current_user.id).first if collapse.blank? CollapsedPage.create(:page_id => page.id, :user_id => current_user.id) end end end render :json => {:status => true} end |
#create ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 36 def create @page = Page.new(params["gluttonberg_page"]) @page.state = "draft" @page.published_at = nil @page.user_id = current_user.id @page.current_user_id = current_user.id if @page.save @page.create_default_template_file flash[:notice] = "The page was successfully created." redirect_to edit_admin_page_page_localization_path( :page_id => @page.id, :id => @page.current_localization.id) else render :new end end |
#delete ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 27 def delete display_delete_confirmation( :title => "Delete “#{@page.current_localization.name}” page?", :url => admin_page_url(@page), :return_url => admin_pages_path , :warning => "Children of this page will also be deleted." ) end |
#destroy ⇒ Object
52 53 54 55 56 57 58 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 52 def destroy generic_destroy(@page, { :name => "page", :success_path => admin_pages_path, :failure_path => admin_pages_path }) end |
#duplicate ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 87 def duplicate @page = Page.find(params[:id]) @duplicated_page = @page.duplicate @duplicated_page.user_id = current_user.id if @duplicated_page flash[:notice] = "The page was successfully duplicated." redirect_to edit_admin_page_page_localization_path( :page_id => @duplicated_page.id, :id => @duplicated_page.current_localization.id) else flash[:error] = "There was an error duplicating the page." redirect_to admin_pages_path end end |
#expand ⇒ Object
Expand a children of single page in pages list
111 112 113 114 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 111 def CollapsedPage.delete_all(:page_id => params[:id], :user_id => current_user.id) render :json => {:status => true} end |
#expand_all ⇒ Object
129 130 131 132 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 129 def CollapsedPage.delete_all(:user_id => current_user.id) render :json => {:status => true} end |
#index ⇒ Object
13 14 15 16 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 13 def index @pages = Page.where(:parent_id => nil).includes(:user, :localizations, :collapsed_pages).order('position').all @pages = @pages.find_all{|page| current_user.can_view_page(page) } end |
#new ⇒ Object
21 22 23 24 25 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 21 def new @page = Page.new(:parent_id => params[:parent_id]) :manage_object, @page @page_localization = PageLocalization.new end |
#pages_list_for_tinymce ⇒ Object
Pages/posts lists for redactor
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 74 def pages_list_for_tinymce @pages = Page.published.count @pages = Page.published.where("not(description_name = 'top_level_page')").order('position' ) @articles_count = 0 if Gluttonberg.constants.include?(:Blog) @articles_count = Gluttonberg::Blog::Article.published.count @blogs = Gluttonberg::Blog::Weblog.published.order("name ASC") end render :layout => false end |
#show ⇒ Object
18 19 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 18 def show end |
#update_home ⇒ Object
This action is called from configuration in an ajax call for update home page
61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/gluttonberg/admin/content/pages_controller.rb', line 61 def update_home @new_home = Page.where(:id => params[:home]).first unless @new_home.blank? @new_home.update_attributes(:home => true) else @old_home = Page.where(:home => true).first @old_home.update_attributes(:home => false) end Gluttonberg::Feed.log(current_user,@new_home,@new_home.name , "set as home") render :text => "Home page is changed" end |