caboose-cms 0.2.23 → 0.2.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzliMTgxODNhNGExNTk4ZmFlNGEwMzdlNDg0ODAxYzAyMzhiOTUwZg==
4
+ YTUxZWUzYzkxNGJiYTJkMmFkNTU0YmVhNGQyNWMxNDQxNTBhNTFkMw==
5
5
  data.tar.gz: !binary |-
6
- ODY5YzhjZWRlNzI2OWVlMTIxZGVkOGRiMDdjNjQ3NjA2MTBiMzFlNQ==
6
+ ODE3OTQxMmZiZmU0YTlhZWQ5Y2NhM2ViMzYwMDcxYzcwNjIwYzQ2Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NGE2MTEwOTUwY2U3Y2NiYjkwNWI1OGZiYTBiOTlhM2E4ZmZkNzlmZDhlMDNm
10
- YTMwODFhYzRiNDhiZjI0OTU4YWE2NWI1YTQyYzgxMDhmMmNmMTEzYWY5ZmNk
11
- OTU4MGExNDM0ZTJmYjYwYThjNjYwYjdjYWM2MTFhNzA5OTU0Mzc=
9
+ ZmMyY2FhYjJlYmQwNzUzNTg4ZWRjYjE3MmZlODk1MjE2ODBjMDIwMjczZTgx
10
+ Y2UwZDUyMDkyNDJkY2QyNDRiMTgwMjYwOTBmMWI0M2M4NThiZTQ1ZmIxOWE1
11
+ YzljNjEwMDVlYWUyOGFkZDY2Mjk4MjM4YTM1ODM0ZGMwYTI3ZDg=
12
12
  data.tar.gz: !binary |-
13
- MWUzMDE4NTNjNDAwNTUzZmQ1NDg3NDEwMDg0MGNhMGNiYjc0YzM3OGFiMTZm
14
- NjNmZTFmNjY4YTkzYWViZWU2MTRjYzg5NDBmODgxMmExZGQ0NzA5ZjRhMTQ0
15
- NTE3ZjhhOTM1ODE4ZTVhNTMyOWJmNmRlNjJmZjUwNWRjZWJiNmQ=
13
+ YWNlMmExZTJkN2Q3YzdkOGU3NWJiNDk4YWEwYmY4MTQ5NWRmZDdiNDdmNzI2
14
+ NzI3MzkwODUyYWEzMWFlMmY2MmI5NGFjN2MyNDlhNDljYTQyMGZlYjJlOTI4
15
+ ZTkzYjY5OTIzZmE1OTBiMmNjOTljMTUzN2U3M2M4YjQyMmUxOTU=
@@ -10,90 +10,106 @@ module Caboose
10
10
  def index
11
11
  end
12
12
 
13
+ def view_formatted_resources(page)
14
+ resources = { js: [], css: [] }
15
+ return resources if page.linked_resources.nil?
16
+ page.linked_resources.each_line do |r|
17
+ r.chomp!
18
+ case r
19
+ when /\.js$/
20
+ resources[:js] += [r]
21
+ when /\.css$/
22
+ resources[:css] += [r]
23
+ end
24
+ end
25
+ return resources
26
+ end
27
+
13
28
  # GET /pages/:id
14
29
  def show
15
30
 
16
31
  # Find the page with an exact URI match
17
32
  page = Page.page_with_uri(request.fullpath, false)
18
-
19
- if (!page)
20
- asset
21
- return
22
- end
23
-
24
- user = logged_in_user
25
- if (!user.is_allowed(page, 'view'))
26
- if (user.id == User.logged_out_user_id)
27
- redirect_to "/login?return_url=" + URI.encode(request.fullpath)
28
- return
29
- else
30
- page.title = 'Access Denied'
31
- page.content = "<p class='note error'>You do not have access to view this page.</p>"
32
- end
33
- end
34
-
35
- if (session['use_redirect_urls'] && !page.redirect_url.nil? && page.redirect_url.strip.length > 0)
36
- redirect_to page.redirect_url
37
- return
38
- end
39
-
40
- page.content = Caboose.plugin_hook('page_content', page.content)
41
- @page = page
42
- @user = user
43
- @editmode = !params['edit'].nil? && user.is_allowed('pages', 'edit') ? true : false
44
- @crumb_trail = Caboose::Page.crumb_trail(@page)
45
- @subnav = Caboose::Page.subnav(@page, session['use_redirect_urls'], @user)
46
-
33
+
34
+ if (!page)
35
+ asset
36
+ return
37
+ end
38
+
39
+ user = logged_in_user
40
+ if (!user.is_allowed(page, 'view'))
41
+ if (user.id == User.logged_out_user_id)
42
+ redirect_to "/login?return_url=" + URI.encode(request.fullpath)
43
+ return
44
+ else
45
+ page.title = 'Access Denied'
46
+ page.content = "<p class='note error'>You do not have access to view this page.</p>"
47
+ end
48
+ end
49
+
50
+ if (session['use_redirect_urls'] && !page.redirect_url.nil? && page.redirect_url.strip.length > 0)
51
+ redirect_to page.redirect_url
52
+ return
53
+ end
54
+
55
+ page.content = Caboose.plugin_hook('page_content', page.content)
56
+ @page = page
57
+ @user = user
58
+ @editmode = !params['edit'].nil? && user.is_allowed('pages', 'edit') ? true : false
59
+ @crumb_trail = Caboose::Page.crumb_trail(@page)
60
+ @subnav = Caboose::Page.subnav(@page, session['use_redirect_urls'], @user)
61
+
47
62
  #@subnav.links = @tasks.collect {|href, task| {'href' => href, 'text' => task, 'is_current' => uri == href}}
63
+
64
+ @resources = view_formatted_resources(@page)
48
65
 
49
66
  end
50
67
 
51
68
  def asset
52
-
53
69
  uri = uri.to_s.gsub(/^(.*?)\?.*?$/, '\1')
54
70
  uri.chop! if uri.end_with?('/')
55
71
  uri[0] = '' if uri.starts_with?('/')
56
-
72
+
57
73
  page = Page.page_with_uri(File.dirname(uri), false)
58
74
  if (page.nil? || !page)
59
75
  render :file => "caboose/extras/error404", :layout => "caboose/error404"
60
76
  return
61
77
  end
62
78
 
63
- asset = Asset.where(:page_id => page.id, :filename => File.basename(uri)).first
64
- if (asset.nil?)
65
- render :file => "caboose/extras/error404", :layout => "caboose/error404"
66
- return
67
- end
68
-
69
- user = logged_in_user
70
- if (!Page.is_allowed(user, asset.page_id, 'view'))
71
- render "caboose/pages/asset_no_permission"
72
- return
73
- end
74
-
75
- #Caboose.log(Caboose::assets_path, 'Caboose::assets_path')
76
- path = Caboose::assets_path.join("#{asset.id}.#{asset.extension}")
77
- #Caboose.log("Sending asset #{path}")
78
- #send_file(path)
79
- #send_file(path, :filename => "your_document.pdf", :type => "application/pdf")
80
-
81
- #
82
- #$path = ASSETS_PATH ."/". $asset->id .".". $asset->extension
83
- #
84
- #$finfo = finfo_open(FILEINFO_MIME_TYPE) // return mime type ala mimetype extension
85
- #$mime = finfo_file($finfo, $path)
86
- #finfo_close($finfo)
79
+ asset = Asset.where(:page_id => page.id, :filename => File.basename(uri)).first
80
+ if (asset.nil?)
81
+ render :file => "caboose/extras/error404", :layout => "caboose/error404"
82
+ return
83
+ end
84
+
85
+ user = logged_in_user
86
+ if (!Page.is_allowed(user, asset.page_id, 'view'))
87
+ render "caboose/pages/asset_no_permission"
88
+ return
89
+ end
90
+
91
+ #Caboose.log(Caboose::assets_path, 'Caboose::assets_path')
92
+ path = Caboose::assets_path.join("#{asset.id}.#{asset.extension}")
93
+ #Caboose.log("Sending asset #{path}")
94
+ #send_file(path)
95
+ #send_file(path, :filename => "your_document.pdf", :type => "application/pdf")
96
+
87
97
  #
88
- #header("X-Sendfile: $path")
89
- #header("Content-Type: $mime")
90
- #header("Content-Disposition: inline filename=\"$asset->filename\"")
98
+ #$path = ASSETS_PATH ."/". $asset->id .".". $asset->extension
99
+ #
100
+ #$finfo = finfo_open(FILEINFO_MIME_TYPE) // return mime type ala mimetype extension
101
+ #$mime = finfo_file($finfo, $path)
102
+ #finfo_close($finfo)
103
+ #
104
+ #header("X-Sendfile: $path")
105
+ #header("Content-Type: $mime")
106
+ #header("Content-Disposition: inline filename=\"$asset->filename\"")
91
107
 
92
108
  end
93
109
 
94
110
  # GET /pages/new
95
111
  def new
96
- return if !user_is_allowed('pages', 'add')
112
+ return unless user_is_allowed('pages', 'add')
97
113
  @parent_id = params[:parent_id].nil? ? params[:parent_id] : 1
98
114
  @parent = Page.find(@parent_id)
99
115
  render :layout => 'caboose/modal'
@@ -107,64 +123,72 @@ module Caboose
107
123
 
108
124
  # GET /pages/1/edit
109
125
  def edit
110
- return if !user_is_allowed('pages', 'edit')
126
+ return unless user_is_allowed('pages', 'edit')
111
127
  @page = Page.find(params[:id])
128
+ @resources = view_formatted_resources(@page)
112
129
  end
113
130
 
114
131
  # GET /pages/1/edit-title
115
132
  def edit_title
116
- return if !user_is_allowed('pages', 'edit')
133
+ return unless user_is_allowed('pages', 'edit')
117
134
  @page = Page.find(params[:id])
118
135
  render :layout => 'caboose/modal'
119
136
  end
120
137
 
121
138
  # GET /pages/1/edit-content
122
139
  def edit_content
123
- return if !user_is_allowed('pages', 'edit')
140
+ return unless user_is_allowed('pages', 'edit')
124
141
  @page = Page.find(params[:id])
125
142
  render :layout => 'caboose/modal'
126
143
  end
127
144
 
128
145
  # GET /pages/1/edit-settings
129
146
  def edit_settings
130
- return if !user_is_allowed('pages', 'edit')
147
+ return unless user_is_allowed('pages', 'edit')
131
148
  @page = Page.find(params[:id])
132
149
  render :layout => 'caboose/modal'
133
150
  end
134
151
 
135
152
  # GET /pages/1/edit-css
136
153
  def edit_css
137
- return if !user_is_allowed('pages', 'edit')
154
+ return unless user_is_allowed('pages', 'edit')
138
155
  @page = Page.find(params[:id])
139
156
  render :layout => 'caboose/modal'
140
157
  end
141
158
 
142
159
  # GET /pages/1/edit-js
143
160
  def edit_js
144
- return if !user_is_allowed('pages', 'edit')
161
+ return unless user_is_allowed('pages', 'edit')
145
162
  @page = Page.find(params[:id])
146
163
  render :layout => 'caboose/modal'
147
164
  end
148
165
 
149
166
  # GET /pages/1/edit-seo
150
167
  def edit_seo
151
- return if !user_is_allowed('pages', 'edit')
168
+ return unless user_is_allowed('pages', 'edit')
169
+ @page = Page.find(params[:id])
170
+ render :layout => 'caboose/modal'
171
+ end
172
+
173
+ # GET /pages/1/edit-resources
174
+ def edit_resources
175
+ return unless user_is_allowed('pages', 'edit')
152
176
  @page = Page.find(params[:id])
153
177
  render :layout => 'caboose/modal'
154
178
  end
155
179
 
156
180
  # POST /pages
157
181
  def create
158
- return if !user_is_allowed('pages', 'add')
159
-
182
+ return unless user_is_allowed('pages', 'add')
183
+
160
184
  resp = Caboose::StdClass.new({
161
185
  'error' => nil,
162
186
  'redirect' => nil
163
187
  })
164
-
188
+
165
189
  parent_id = params[:parent_id]
166
190
  title = params[:title]
167
-
191
+
168
192
  if (title.strip.length == 0)
169
193
  resp.error = "A page title is required."
170
194
  elsif (!logged_in_user.is_allowed('all', 'all') &&
@@ -176,119 +200,155 @@ module Caboose
176
200
  render json: resp
177
201
  return
178
202
  end
179
-
180
- parent = Caboose::Page.find(parent_id)
181
-
182
- page = Caboose::Page.new
183
- page.title = title
184
- page.parent_id = parent_id
185
- page.hide = true
186
- page.content_format = Caboose::Page::CONTENT_FORMAT_HTML
187
-
188
- i = 0
189
- begin
190
- page.slug = Page.slug(page.title + (i > 0 ? " #{i}" : ""))
191
- page.uri = parent.parent_id == -1 ? page.slug : "#{parent.uri}/#{page.slug}"
192
- i = i+1
193
- end while (Page.where(:uri => page.uri).count > 0 && i < 10)
194
-
195
- page.save
196
-
197
- # Set the new page's permissions
198
- viewers = Caboose::PagePermission.where({ :page_id => parent.id, :action => 'view' }).pluck(:role_id)
199
- editors = Caboose::PagePermission.where({ :page_id => parent.id, :action => 'edit' }).pluck(:role_id)
200
- Caboose::Page.update_authorized_for_action(page.id, 'view', viewers)
201
- Caboose::Page.update_authorized_for_action(page.id, 'edit', editors)
202
-
203
- # Send back the response
204
- resp.redirect = "/pages/#{page.id}/edit"
203
+
204
+ parent = Caboose::Page.find(parent_id)
205
+
206
+ page = Caboose::Page.new
207
+ page.title = title
208
+ page.parent_id = parent_id
209
+ page.hide = true
210
+ page.content_format = Caboose::Page::CONTENT_FORMAT_HTML
211
+
212
+ i = 0
213
+ begin
214
+ page.slug = Page.slug(page.title + (i > 0 ? " #{i}" : ""))
215
+ page.uri = parent.parent_id == -1 ? page.slug : "#{parent.uri}/#{page.slug}"
216
+ i = i+1
217
+ end while (Page.where(:uri => page.uri).count > 0 && i < 10)
218
+
219
+ page.save
220
+
221
+ # Set the new page's permissions
222
+ viewers = Caboose::PagePermission.where({ :page_id => parent.id, :action => 'view' }).pluck(:role_id)
223
+ editors = Caboose::PagePermission.where({ :page_id => parent.id, :action => 'edit' }).pluck(:role_id)
224
+ Caboose::Page.update_authorized_for_action(page.id, 'view', viewers)
225
+ Caboose::Page.update_authorized_for_action(page.id, 'edit', editors)
226
+
227
+ # Send back the response
228
+ resp.redirect = "/pages/#{page.id}/edit"
205
229
  render json: resp
206
230
  end
207
231
 
208
232
  # PUT /pages/1
209
233
  def update
210
- return if !user_is_allowed('pages', 'edit')
234
+ return unless user_is_allowed('pages', 'edit')
211
235
 
212
236
  resp = StdClass.new({'attributes' => {}})
213
237
  page = Page.find(params[:id])
214
238
 
215
239
  save = true
216
240
  user = logged_in_user
217
- params.each do |name,value|
218
- case name
219
- when 'parent_id'
220
- if (page.id == value)
221
- resp.error = "The page's parent cannot be itself."
222
- elsif (Page.is_child(page.id, value))
223
- resp.error = "You can't set the current page's parent to be one of its child pages."
224
- elsif (value != page.parent_id)
225
- p = Page.find(value)
226
- if (!user.is_allowed(p, 'edit'))
227
- resp.error = "You don't have access to put the current page there."
228
- end
229
- end
230
- if (resp.error.length > 0)
231
- save = false
232
- else
233
- parent = Page.find(value)
234
- Page.update_parent(page.id, value)
235
- resp.attributes['parent_id'] = { 'text' => parent.title }
236
- end
237
-
238
- when 'title', 'menu_title', 'alias', 'hide',
239
- 'custom_css', 'custom_js', 'layout', 'redirect_url',
240
- 'seo_title', 'meta_description', 'fb_description', 'gp_description', 'canonical_url'
241
-
242
- page[name.to_sym] = value
243
-
244
- when 'content_format'
245
- page.content_format = value
246
- resp.attributes['content_format'] = { 'text' => value }
247
-
248
- when 'meta_robots'
249
- if (value.include?('index') && value.include?('noindex'))
250
- resp.error = "You can't have both index and noindex"
251
- save = false
252
- elsif (value.include?('follow') && value.include?('nofollow'))
253
- resp.error = "You can't have both follow and nofollow"
254
- save = false
255
- else
256
- page.meta_robots = value.join(', ')
257
- resp.attributes['meta_robots'] = { 'text' => page.meta_robots }
258
- end
259
-
260
- when 'content'
261
- page.content = value.strip.gsub(/<meta.*?>/, '').gsub(/<link.*?>/, '').gsub(/\<\!--[\S\s]*?--\>/, '')
262
-
263
- when 'slug'
264
- page.slug = Page.slug(value.strip.length > 0 ? value : page.title)
265
- resp.attributes['slug'] = { 'value' => page.slug }
266
-
267
- when 'custom_sort_children'
268
- if (value == 0)
269
- page.children.each do |p|
270
- p.sort_order = 1
271
- p.save
272
- end
273
- end
274
- page.custom_sort_children = value
275
-
276
- when 'viewers'
277
- Page.update_authorized_for_action(page.id, 'view', value)
278
- when 'editors'
279
- Page.update_authorized_for_action(page.id, 'edit', value)
280
- when 'approvers'
281
- Page.update_authorized_for_action(page.id, 'approve', value)
282
- end
283
- end
284
-
285
- resp.success = save && page.save
286
- render json: resp
241
+ params.each do |name, value|
242
+ case name
243
+ when 'parent_id'
244
+ if (page.id == value)
245
+ resp.error = "The page's parent cannot be itself."
246
+ elsif (Page.is_child(page.id, value))
247
+ resp.error = "You can't set the current page's parent to be one of its child pages."
248
+ elsif (value != page.parent_id)
249
+ p = Page.find(value)
250
+ if (!user.is_allowed(p, 'edit'))
251
+ resp.error = "You don't have access to put the current page there."
252
+ end
253
+ end
254
+ if (resp.error.length > 0)
255
+ save = false
256
+ else
257
+ parent = Page.find(value)
258
+ Page.update_parent(page.id, value)
259
+ resp.attributes['parent_id'] = { 'text' => parent.title }
260
+ end
261
+
262
+ when 'custom_css', 'custom_js'
263
+ value.strip!
264
+ page[name.to_sym] = value
265
+
266
+ when 'title', 'menu_title', 'alias', 'hide', 'layout', 'redirect_url',
267
+ 'seo_title', 'meta_description', 'fb_description', 'gp_description', 'canonical_url'
268
+ page[name.to_sym] = value
269
+
270
+ when 'linked_resources'
271
+ result = ''
272
+ value.each_line do |line|
273
+
274
+ line.strip!
275
+ next if line.empty?
276
+
277
+ comps = line.split('.')
278
+ if comps.length < 2
279
+ resp.error = "Resource '#{line}' has an unspecified file type. (e.g. given 'myScript.js', '.js' would specify a javascript file type.)"
280
+ save = false
281
+ next
282
+ end
283
+
284
+ case comps.last
285
+ when 'js', 'css'
286
+ if value =~ URI::regexp()
287
+ uri = URI.parse(value)
288
+ if !(uri =~ URI::HTTP || uri =~ URI::HTTPS)
289
+ resp.error = "Resource '#{line}' is an unrecognized URI format."
290
+ save = false
291
+ end
292
+ end
293
+ else
294
+ resp.error = "Resource '#{line}' has an unsupported file type ('#{comps.last}')."
295
+ save = false
296
+ next
297
+ end
298
+
299
+ result += "\n" unless result.empty?
300
+ result += line
301
+ end
302
+ page.linked_resources = result
303
+
304
+ when 'content_format'
305
+ page.content_format = value
306
+ resp.attributes['content_format'] = { 'text' => value }
307
+
308
+ when 'meta_robots'
309
+ if (value.include?('index') && value.include?('noindex'))
310
+ resp.error = "You can't have both index and noindex"
311
+ save = false
312
+ elsif (value.include?('follow') && value.include?('nofollow'))
313
+ resp.error = "You can't have both follow and nofollow"
314
+ save = false
315
+ else
316
+ page.meta_robots = value.join(', ')
317
+ resp.attributes['meta_robots'] = { 'text' => page.meta_robots }
318
+ end
319
+
320
+ when 'content'
321
+ page.content = value.strip.gsub(/<meta.*?>/, '').gsub(/<link.*?>/, '').gsub(/\<\!--[\S\s]*?--\>/, '')
322
+
323
+ when 'slug'
324
+ page.slug = Page.slug(value.strip.length > 0 ? value : page.title)
325
+ resp.attributes['slug'] = { 'value' => page.slug }
326
+
327
+ when 'custom_sort_children'
328
+ if (value == 0)
329
+ page.children.each do |p|
330
+ p.sort_order = 1
331
+ p.save
332
+ end
333
+ end
334
+ page.custom_sort_children = value
335
+
336
+ when 'viewers'
337
+ Page.update_authorized_for_action(page.id, 'view', value)
338
+ when 'editors'
339
+ Page.update_authorized_for_action(page.id, 'edit', value)
340
+ when 'approvers'
341
+ Page.update_authorized_for_action(page.id, 'approve', value)
342
+ end
343
+ end
344
+
345
+ resp.success = save && page.save
346
+ render json: resp
287
347
  end
288
348
 
289
349
  # DELETE /pages/1
290
350
  def destroy
291
- return if !user_is_allowed('pages', 'delete')
351
+ return unless user_is_allowed('pages', 'delete')
292
352
  user = Page.find(params[:id])
293
353
  user.destroy
294
354
 
@@ -300,58 +360,58 @@ module Caboose
300
360
 
301
361
  def sitemap
302
362
  parent_id = params[:parent_id]
303
- top_page = Page.index_page
304
- p = !parent_id.nil? ? Page.find(parent_id) : top_page
305
- options = []
306
- sitemap_helper2(top_page, options)
307
- @options = options
363
+ top_page = Page.index_page
364
+ p = !parent_id.nil? ? Page.find(parent_id) : top_page
365
+ options = []
366
+ sitemap_helper2(top_page, options)
367
+ @options = options
308
368
  end
309
-
369
+
310
370
  def sitemap_helper2(page, options, prefix = '')
311
- options << { 'value' => page.id, 'text' => prefix + page.title }
312
- page.children.each do |kid|
313
- sitemap_helper(kid, options, prefix + ' - ')
314
- end
315
- end
316
-
371
+ options << { 'value' => page.id, 'text' => prefix + page.title }
372
+ page.children.each do |kid|
373
+ sitemap_helper(kid, options, prefix + ' - ')
374
+ end
375
+ end
376
+
317
377
  def sitemap_options
318
- parent_id = params[:parent_id]
319
- top_page = Page.index_page
320
- p = !parent_id.nil? ? Page.find(parent_id) : top_page
321
- options = []
322
- sitemap_helper(top_page, options)
323
-
324
- render json: options
325
- end
326
-
327
- def sitemap_helper(page, options, prefix = '')
328
- options << { 'value' => page.id, 'text' => prefix + page.title }
329
- page.children.each do |kid|
330
- sitemap_helper(kid, options, prefix + ' - ')
331
- end
332
- end
333
-
334
- def robots_options
335
- options = [
336
- { 'value' => 'index' , 'text' => 'index' },
337
- { 'value' => 'noindex' , 'text' => 'noindex' },
338
- { 'value' => 'follow' , 'text' => 'follow' },
339
- { 'value' => 'nofollow' , 'text' => 'nofollow' },
340
- { 'value' => 'nosnippet' , 'text' => 'nosnippet' },
341
- { 'value' => 'noodp' , 'text' => 'noodp' },
342
- { 'value' => 'noarchive' , 'text' => 'noarchive' }
343
- ]
344
- render json: options
345
- end
346
-
347
- def content_format_options
348
- options = [
349
- { 'value' => 'html', 'text' => 'html' },
350
- { 'value' => 'text', 'text' => 'text' },
351
- { 'value' => 'ruby', 'text' => 'ruby' }
352
- ]
353
- render json: options
354
- end
378
+ parent_id = params[:parent_id]
379
+ top_page = Page.index_page
380
+ p = !parent_id.nil? ? Page.find(parent_id) : top_page
381
+ options = []
382
+ sitemap_helper(top_page, options)
383
+
384
+ render json: options
385
+ end
386
+
387
+ def sitemap_helper(page, options, prefix = '')
388
+ options << { 'value' => page.id, 'text' => prefix + page.title }
389
+ page.children.each do |kid|
390
+ sitemap_helper(kid, options, prefix + ' - ')
391
+ end
392
+ end
393
+
394
+ def robots_options
395
+ options = [
396
+ { 'value' => 'index' , 'text' => 'index' },
397
+ { 'value' => 'noindex' , 'text' => 'noindex' },
398
+ { 'value' => 'follow' , 'text' => 'follow' },
399
+ { 'value' => 'nofollow' , 'text' => 'nofollow' },
400
+ { 'value' => 'nosnippet' , 'text' => 'nosnippet' },
401
+ { 'value' => 'noodp' , 'text' => 'noodp' },
402
+ { 'value' => 'noarchive' , 'text' => 'noarchive' }
403
+ ]
404
+ render json: options
405
+ end
406
+
407
+ def content_format_options
408
+ options = [
409
+ { 'value' => 'html', 'text' => 'html' },
410
+ { 'value' => 'text', 'text' => 'text' },
411
+ { 'value' => 'ruby', 'text' => 'ruby' }
412
+ ]
413
+ render json: options
414
+ end
355
415
 
356
416
  end
357
417
  end