app/api/locomotive/api/resources/page_resource.rb in locomotivecms-3.4.1 vs app/api/locomotive/api/resources/page_resource.rb in locomotivecms-4.0.0.alpha1

- old
+ new

@@ -5,20 +5,28 @@ class PageResource < Grape::API resource :pages do entity_klass = Entities::PageEntity + helpers do + + def url_builder + Locomotive::Steam::Services.build_simple_instance(current_site).url_builder + end + + end + before do setup_resource_methods_for(:pages) authenticate_locomotive_account! end desc 'Index of pages' get '/' do authorize Page, :index? - present pages, with: entity_klass, site: current_site + present pages, with: entity_klass, site: current_site, url_builder: url_builder end desc 'Only full path of pages' get '/fullpaths' do authorize Page, :index? @@ -32,11 +40,11 @@ end route_param :id do get do authorize(page, :show?) - present page, with: entity_klass, site: current_site + present page, with: entity_klass, site: current_site, url_builder: url_builder end end desc 'Create a page (in the default locale)' params do @@ -55,10 +63,12 @@ optional :templatized, type: Boolean optional :content_type, type: String optional :is_layout, type: Boolean optional :allow_layout, type: Boolean optional :editable_elements, type: Array + optional :sections_content, type: String + optional :sections_dropzone_content, type: String optional :cache_enabled optional :seo_title optional :meta_keywords optional :meta_description optional :display_settings @@ -71,11 +81,11 @@ form = form_klass.new(current_site, page_params) persist_from_form(form) - present page, with: entity_klass, site: current_site + present page, with: entity_klass, site: current_site, url_builder: url_builder end desc 'Update a page' params do requires :id, type: String, desc: 'Page ID' @@ -93,10 +103,12 @@ optional :content_type optional :is_layout, type: Boolean optional :allow_layout, type: Boolean optional :template optional :editable_elements, type: Array + optional :sections_content, type: String + optional :sections_dropzone_content, type: String optional :cache_enabled optional :seo_title optional :meta_keywords optional :meta_description optional :display_settings @@ -106,11 +118,11 @@ object_auth :update? form = form_klass.new(current_site, page_params, page) persist_from_form(form) - present page, with: entity_klass, site: current_site + present page, with: entity_klass, site: current_site, url_builder: url_builder end desc 'Delete a page' params do requires :id, type: String, desc: 'Page ID or PATH' @@ -123,10 +135,10 @@ object_auth :destroy? page.destroy - present page, with: entity_klass, site: current_site + present page, with: entity_klass, site: current_site, url_builder: url_builder end end end