Class: Spotlight::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Spotlight::PagesController
- Includes:
- Blacklight::Catalog::SearchContext, Base, Catalog::AccessControlsEnforcement
- Defined in:
- app/controllers/spotlight/pages_controller.rb
Direct Known Subclasses
AboutPagesController, FeaturePagesController, HomePagesController
Instance Method Summary collapse
- #_prefixes ⇒ Object
-
#create ⇒ Object
POST /exhibits/1/pages.
-
#destroy ⇒ Object
DELETE /pages/1.
-
#edit ⇒ Object
GET /pages/1/edit.
-
#index ⇒ Object
GET /exhibits/1/pages.
-
#new ⇒ Object
GET /exhibits/1/pages/new.
- #preview ⇒ Object
-
#show ⇒ Object
GET /pages/1.
-
#update ⇒ Object
PATCH/PUT /pages/1.
- #update_all ⇒ Object
Methods included from Base
#autocomplete_json_response, #blacklight_config
Methods included from Config
#exhibit_specific_blacklight_config
Methods included from Controller
#blacklight_config, #current_exhibit, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url
Instance Method Details
#_prefixes ⇒ Object
79 80 81 |
# File 'app/controllers/spotlight/pages_controller.rb', line 79 def _prefixes @_prefixes ||= super + ['catalog'] end |
#create ⇒ Object
POST /exhibits/1/pages
41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/spotlight/pages_controller.rb', line 41 def create @page.attributes = page_params @page.last_edited_by = @page.created_by = current_user if @page.save redirect_to [@page.exhibit, page_collection_name], notice: t(:'helpers.submit.page.created', model: @page.class.model_name.human.downcase) else render action: 'new' end end |
#destroy ⇒ Object
DELETE /pages/1
64 65 66 67 68 |
# File 'app/controllers/spotlight/pages_controller.rb', line 64 def destroy @page.destroy redirect_to [@page.exhibit, page_collection_name], notice: t(:'helpers.submit.page.destroyed', model: @page.class.model_name.human.downcase) end |
#edit ⇒ Object
GET /pages/1/edit
36 37 38 |
# File 'app/controllers/spotlight/pages_controller.rb', line 36 def edit @page.lock! current_user end |
#index ⇒ Object
GET /exhibits/1/pages
13 14 15 16 |
# File 'app/controllers/spotlight/pages_controller.rb', line 13 def index # set up a model the inline "add a new page" form @page = CanCan::ControllerResource.new(self).send(:build_resource) end |
#new ⇒ Object
GET /exhibits/1/pages/new
32 33 |
# File 'app/controllers/spotlight/pages_controller.rb', line 32 def new end |
#preview ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/controllers/spotlight/pages_controller.rb', line 23 def preview @block = SirTrevorRails::Block.from_hash(JSON.parse(params[:block], symbolize_names: true), "block") respond_to do |format| format.html { render 'preview', layout: false } end end |
#show ⇒ Object
GET /pages/1
19 20 21 |
# File 'app/controllers/spotlight/pages_controller.rb', line 19 def show fresh_when([@page.exhibit, @page]) end |
#update ⇒ Object
PATCH/PUT /pages/1
53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/spotlight/pages_controller.rb', line 53 def update @page.lock.delete if @page.lock if @page.update(page_params.merge(last_edited_by: current_user)) redirect_to [@page.exhibit, @page], notice: t(:'helpers.submit.page.updated', model: @page.class.model_name.human.downcase) else render action: 'edit' end end |
#update_all ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'app/controllers/spotlight/pages_controller.rb', line 70 def update_all notice = if @exhibit.update update_all_page_params t(:'helpers.submit.page.batch_updated', model: human_name) else t(:'helpers.submit.page.batch_error', model: human_name) end redirect_to :back, notice: notice end |