Class: SedgeApi::PageOptionsController

Inherits:
SedgeCms::ApplicationController
  • Object
show all
Defined in:
app/controllers/sedge_cms/sedge_api/page_options_controller.rb,
app/controllers/sedge/sedge_api/page_options_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/sedge_cms/sedge_api/page_options_controller.rb', line 5

def index
  pages_path = Rails.root.join('app', 'sedge', 'pages')
  page_mustache_file = File.read("#{pages_path}/#{params[:path]}.mustache")
  page_html_fragment = Nokogiri::HTML.fragment(page_mustache_file)
  page_options = template_options(page_html_fragment.search('.//sedge-config'))

  # need a better way to define a schema for page configuration.
  options_schema = {}
  options_schema[:sort_index] = 0
  options_schema[:title] = 'Sedge CMS'
  options_schema[:layout] = 'example_layout'
  options_schema[:belongs_to] = []
  options_schema[:fa_icon] = 'fa-file-code-o'

  render :json => options_schema.merge(page_options)
end