radiant-templates-extension 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/HELP_designer.textile +79 -0
  2. data/README.textile +123 -0
  3. data/Rakefile +136 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/admin/part_types_controller.rb +8 -0
  6. data/app/controllers/admin/templates_controller.rb +38 -0
  7. data/app/helpers/admin/part_types_helper.rb +26 -0
  8. data/app/helpers/admin/templates_helper.rb +108 -0
  9. data/app/models/part_type.rb +14 -0
  10. data/app/models/template.rb +80 -0
  11. data/app/models/template_part.rb +21 -0
  12. data/app/views/admin/pages/_edit_template.html.haml +32 -0
  13. data/app/views/admin/pages/_edit_template_part.html.haml +20 -0
  14. data/app/views/admin/pages/_switch_templates.html.haml +23 -0
  15. data/app/views/admin/pages/_template_column.html.haml +3 -0
  16. data/app/views/admin/pages/_template_column_header.html.haml +1 -0
  17. data/app/views/admin/part_types/_form.html.haml +36 -0
  18. data/app/views/admin/part_types/_list.html.haml +23 -0
  19. data/app/views/admin/part_types/edit.html.haml +5 -0
  20. data/app/views/admin/part_types/index.html.haml +7 -0
  21. data/app/views/admin/part_types/new.html.haml +2 -0
  22. data/app/views/admin/part_types/remove.html.haml +15 -0
  23. data/app/views/admin/templates/_form.html.haml +65 -0
  24. data/app/views/admin/templates/_template_part.html.haml +21 -0
  25. data/app/views/admin/templates/_templates_css.html.haml +12 -0
  26. data/app/views/admin/templates/edit.html.haml +10 -0
  27. data/app/views/admin/templates/index.html.haml +47 -0
  28. data/app/views/admin/templates/new.html.haml +9 -0
  29. data/app/views/admin/templates/remove.html.haml +15 -0
  30. data/config/initializers/radiant_config.rb +3 -0
  31. data/config/locales/en.yml +32 -0
  32. data/config/routes.rb +7 -0
  33. data/db/migrate/001_create_templates.rb +17 -0
  34. data/db/migrate/002_create_template_parts.rb +15 -0
  35. data/db/migrate/003_rename_sublayout_column.rb +9 -0
  36. data/db/migrate/004_add_position_to_templates.rb +13 -0
  37. data/db/migrate/005_create_part_types.rb +17 -0
  38. data/db/migrate/006_add_description_to_template_parts.rb +9 -0
  39. data/db/migrate/007_add_page_class_name_to_templates.rb +9 -0
  40. data/db/migrate/008_add_index_to_templates.rb +9 -0
  41. data/db/migrate/009_create_default_part_types.rb +23 -0
  42. data/db/migrate/010_update_boolean_part_type.rb +9 -0
  43. data/db/migrate/011_add_timestamps.rb +19 -0
  44. data/lib/file_system/model/part_type_extensions.rb +19 -0
  45. data/lib/file_system/model/template_extensions.rb +52 -0
  46. data/lib/tasks/templates_extension_tasks.rake +28 -0
  47. data/lib/templates/associations.rb +7 -0
  48. data/lib/templates/controller_extensions.rb +20 -0
  49. data/lib/templates/helper.rb +75 -0
  50. data/lib/templates/page_extensions.rb +43 -0
  51. data/lib/templates/tags.rb +43 -0
  52. data/public/images/admin/menu_arrow.png +0 -0
  53. data/public/images/admin/move_higher.png +0 -0
  54. data/public/images/admin/move_lower.png +0 -0
  55. data/public/images/admin/move_to_bottom.png +0 -0
  56. data/public/images/admin/move_to_top.png +0 -0
  57. data/public/images/admin/part_type.png +0 -0
  58. data/public/images/admin/template.png +0 -0
  59. data/spec/controllers/admin_page_controller_extensions_spec.rb +61 -0
  60. data/spec/controllers/part_types_controller_spec.rb +89 -0
  61. data/spec/controllers/templates_controller_spec.rb +322 -0
  62. data/spec/datasets/part_types_dataset.rb +15 -0
  63. data/spec/datasets/templates_dataset.rb +34 -0
  64. data/spec/helpers/templates_helper_spec.rb +56 -0
  65. data/spec/models/page_extensions_spec.rb +9 -0
  66. data/spec/models/part_type_spec.rb +28 -0
  67. data/spec/models/tags_spec.rb +44 -0
  68. data/spec/models/template_part_spec.rb +37 -0
  69. data/spec/models/template_spec.rb +88 -0
  70. data/spec/spec.opts +6 -0
  71. data/spec/spec_helper.rb +39 -0
  72. data/templates_extension.rb +83 -0
  73. data/vendor/plugins/acts_as_list/README +23 -0
  74. data/vendor/plugins/acts_as_list/init.rb +3 -0
  75. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  76. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  77. data/vendor/plugins/make_resourceful/DEFAULTS +148 -0
  78. data/vendor/plugins/make_resourceful/LICENSE +7 -0
  79. data/vendor/plugins/make_resourceful/README +239 -0
  80. data/vendor/plugins/make_resourceful/Rakefile +42 -0
  81. data/vendor/plugins/make_resourceful/VERSION +1 -0
  82. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb +87 -0
  83. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/controller.rb +5 -0
  84. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/fixtures.yml +10 -0
  85. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/functional_test.rb +57 -0
  86. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/helper.rb +2 -0
  87. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/migration.rb +13 -0
  88. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/model.rb +2 -0
  89. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/unit_test.rb +7 -0
  90. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view__form.haml +5 -0
  91. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_edit.haml +11 -0
  92. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_index.haml +5 -0
  93. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_new.haml +9 -0
  94. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_partial.haml +12 -0
  95. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_show.haml +14 -0
  96. data/vendor/plugins/make_resourceful/init.rb +3 -0
  97. data/vendor/plugins/make_resourceful/lib/resourceful/base.rb +52 -0
  98. data/vendor/plugins/make_resourceful/lib/resourceful/builder.rb +354 -0
  99. data/vendor/plugins/make_resourceful/lib/resourceful/default/accessors.rb +346 -0
  100. data/vendor/plugins/make_resourceful/lib/resourceful/default/actions.rb +92 -0
  101. data/vendor/plugins/make_resourceful/lib/resourceful/default/callbacks.rb +51 -0
  102. data/vendor/plugins/make_resourceful/lib/resourceful/default/responses.rb +118 -0
  103. data/vendor/plugins/make_resourceful/lib/resourceful/default/urls.rb +137 -0
  104. data/vendor/plugins/make_resourceful/lib/resourceful/maker.rb +83 -0
  105. data/vendor/plugins/make_resourceful/lib/resourceful/response.rb +33 -0
  106. data/vendor/plugins/make_resourceful/lib/resourceful/serialize.rb +181 -0
  107. data/vendor/plugins/make_resourceful/spec/accessors_spec.rb +473 -0
  108. data/vendor/plugins/make_resourceful/spec/actions_spec.rb +283 -0
  109. data/vendor/plugins/make_resourceful/spec/base_spec.rb +12 -0
  110. data/vendor/plugins/make_resourceful/spec/builder_spec.rb +332 -0
  111. data/vendor/plugins/make_resourceful/spec/callbacks_spec.rb +71 -0
  112. data/vendor/plugins/make_resourceful/spec/integration_spec.rb +396 -0
  113. data/vendor/plugins/make_resourceful/spec/maker_spec.rb +91 -0
  114. data/vendor/plugins/make_resourceful/spec/response_spec.rb +37 -0
  115. data/vendor/plugins/make_resourceful/spec/responses_spec.rb +314 -0
  116. data/vendor/plugins/make_resourceful/spec/rspec_on_rails/LICENSE +35 -0
  117. data/vendor/plugins/make_resourceful/spec/rspec_on_rails/redirect_to.rb +81 -0
  118. data/vendor/plugins/make_resourceful/spec/rspec_on_rails/render_template.rb +28 -0
  119. data/vendor/plugins/make_resourceful/spec/serialize_spec.rb +133 -0
  120. data/vendor/plugins/make_resourceful/spec/spec_helper.rb +279 -0
  121. data/vendor/plugins/make_resourceful/spec/urls_spec.rb +276 -0
  122. metadata +214 -0
@@ -0,0 +1,9 @@
1
+ - render_region :main do |main|
2
+ - main.edit_header do
3
+ %h1= t('new_template')
4
+ - main.edit_form do
5
+ - form_for :template, current_object, :url => admin_templates_path, :html => {'data-onsubmit_status' => onsubmit_status(current_object)} do |f|
6
+ = render :partial => 'form', :locals => {:f => f}
7
+
8
+ - content_for 'page_scripts', template_edit_javascripts
9
+
@@ -0,0 +1,15 @@
1
+ %h1= t('remove_template')
2
+ %p= t('text.templates.remove_warning')
3
+
4
+ %table.index#templates
5
+ %tbody
6
+ %tr.node.level_1
7
+ %td.template
8
+ = image('template', :alt => "")
9
+ %span.title= current_object.name
10
+
11
+ - form_for [:admin, current_object], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing template…"} do
12
+ %p.buttons
13
+ %input.button{:type=>"submit", :value => t('delete_template')}/
14
+ = t('or')
15
+ = link_to t('cancel'), admin_templates_url
@@ -0,0 +1,3 @@
1
+ Radiant.config do |config|
2
+ # config.define "setting.name", :default => 'value', :select_from => ['foo', 'bar']
3
+ end
@@ -0,0 +1,32 @@
1
+ ---
2
+ en:
3
+ blank_page: "Blank Page"
4
+ delete_part_type: "Delete Part Type"
5
+ delete_template: "Delete Template"
6
+ edit_template: "Edit Template"
7
+ edit_part_type: "Edit Part Type"
8
+ edit_part_types: "Edit Part Types"
9
+ existing_part_types: "Existing Part Types"
10
+ field_class: "Field Class"
11
+ field_styles: "Field Styles"
12
+ field_type: "Field Type"
13
+ new_part_type: "New Part Type"
14
+ new_template: "New Template"
15
+ no_part_types: "No Part Types"
16
+ no_templates: "No Templates"
17
+ order: "Order"
18
+ template: "Template"
19
+ templates: "Templates"
20
+ parttype: "Part Type"
21
+ part_type: "Part Type"
22
+ part_types: "Part Types"
23
+ parts: "Parts"
24
+ remove_part_type: "Remove Part Type"
25
+ remove_template: "Remove Template"
26
+ reorder: "Reorder"
27
+ structure: "Structure"
28
+ text:
29
+ templates:
30
+ remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following template?'
31
+ part_types:
32
+ remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following template part type?<br/><h1><strong class="warning">This will break any existing templates which use this type</strong></h1>'
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.namespace :admin do |admin|
3
+ admin.resources :templates, :member => { :move_higher => :post, :move_lower => :post,
4
+ :move_to_top => :post, :move_to_bottom => :post, :remove => :get}
5
+ admin.resources :part_types, :member => { :remove => :get }
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ class CreateTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :templates do |t|
4
+ t.column :name, :string
5
+ t.column :sublayout, :text
6
+ t.column :layout_id, :integer
7
+ end
8
+ add_index :templates, :name
9
+
10
+ add_column :pages, :template_id, :integer
11
+ end
12
+
13
+ def self.down
14
+ drop_table :templates
15
+ remove_column :pages, :template_id
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ class CreateTemplateParts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :template_parts do |t|
4
+ t.column :template_id, :integer
5
+ t.column :name, :string
6
+ t.column :filter_id, :string
7
+ end
8
+
9
+ add_index :template_parts, :template_id, :name => 'template_parts_on_template_id'
10
+ end
11
+
12
+ def self.down
13
+ drop_table :template_parts
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ class RenameSublayoutColumn < ActiveRecord::Migration
2
+ def self.up
3
+ rename_column :templates, :sublayout, :content
4
+ end
5
+
6
+ def self.down
7
+ rename_column :templates, :content, :sublayout
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class AddPositionToTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :templates, :position, :integer
4
+ Template.reset_column_information
5
+ Template.find(:all).each_with_index do |t, i|
6
+ t.update_attribute(:position => i + 1)
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ remove_column :templates, :position
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ class CreatePartTypes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :part_types do |t|
4
+ t.column :name, :string
5
+ t.column :field_type, :string
6
+ t.column :field_class, :string
7
+ t.column :field_styles, :string
8
+ end
9
+
10
+ add_column :template_parts, :part_type_id, :integer
11
+ end
12
+
13
+ def self.down
14
+ drop_table :part_types
15
+ remove_column :template_parts, :part_type_id
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ class AddDescriptionToTemplateParts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :template_parts, :description, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :template_parts, :description
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddPageClassNameToTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :templates, :page_class_name, :string, :default => nil
4
+ end
5
+
6
+ def self.down
7
+ remove_column :templates, :page_class_name
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddIndexToTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ add_index :templates, :position
4
+ end
5
+
6
+ def self.down
7
+ remove_index :templates, :position
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ class CreateDefaultPartTypes < ActiveRecord::Migration
2
+ def self.defaults
3
+ [
4
+ {:name => "One-line", :field_type => "text_field", :field_class => "text"},
5
+ {:name => "Plain textarea", :field_type => "text_area", :field_class => "textarea"},
6
+ {:name => "Boolean", :field_type => "check_box"},
7
+ {:name => "Predefined", :field_type => "predefined"}
8
+ ]
9
+ end
10
+
11
+ def self.up
12
+ self.defaults.each do |a|
13
+ PartType.create(a)
14
+ end
15
+ end
16
+
17
+ def self.down
18
+ self.defaults.each do |a|
19
+ pt = PartType.find_by_name(a[:name])
20
+ pt.destroy unless pt.nil?
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ class UpdateBooleanPartType < ActiveRecord::Migration
2
+ def self.up
3
+ PartType.find_by_name("Boolean").update_attribute(:field_type, "radio_button")
4
+ end
5
+
6
+ def self.down
7
+ PartType.find_by_name("Boolean").update_attribute(:field_type, "check_box")
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ class AddTimestamps < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ [:templates, :part_types].each do |table|
5
+ change_table(table) do |t|
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ [:templates, :part_types].each do |table|
13
+ change_table(table) do |t|
14
+ t.remove_timestamps
15
+ end
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+ module FileSystem::Model::PartTypeExtensions
2
+ def content_type
3
+ "text/x-yaml"
4
+ end
5
+
6
+ def content_type=(value)
7
+ end
8
+
9
+ def content
10
+ attrs = self.attributes.dup
11
+ attrs.delete('id')
12
+ attrs.delete('name')
13
+ attrs.to_yaml
14
+ end
15
+
16
+ def content=(yaml_text)
17
+ self.attributes = YAML.load(yaml_text)
18
+ end
19
+ end
@@ -0,0 +1,52 @@
1
+ require 'yaml'
2
+ module FileSystem::Model::TemplateExtensions
3
+ def self.included(base)
4
+ base.class_eval do
5
+ alias_method_chain :load_file, :parts
6
+ alias_method_chain :save_file, :parts
7
+ end
8
+ class << base
9
+ def load_files
10
+ Dir[self.path + "/*.yaml", self.path + "/*.yml"].each do |yml|
11
+ template = find_or_initialize_by_filename(yml)
12
+ puts "Loading template attributes (and parts) from #{File.basename(yml)}"
13
+ template.load_file(yml)
14
+ basename = yml.sub(/\.ya?ml/, "")
15
+ content = Dir[basename + "*"].reject {|f| f =~ /\.ya?ml/ }.find {|f| f =~ /#{basename}(\.|$)/ }
16
+ puts "Loading template content from #{File.basename(content)}"
17
+ template.load_file(content) if content
18
+ template.save!
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def load_file_with_parts(filename)
25
+ if filename =~ /\.ya?ml$/
26
+ if yml = YAML::load_file(filename)
27
+ self.layout_name = yml.delete('layout_name')
28
+ self.page_class_name = yml.delete('page_class_name')
29
+ self.template_parts = yml
30
+ end
31
+ else
32
+ load_file_without_parts(filename)
33
+ end
34
+ end
35
+
36
+ def save_file_with_parts
37
+ save_file_without_parts
38
+ hash = self.template_parts.inject({}) do |h,part|
39
+ h.merge(part.id => { 'filter_id' => part.filter_id,
40
+ 'name' => part.name,
41
+ 'part_type_name' => part.part_type.name,
42
+ 'description' => part.description })
43
+ end
44
+ hash['layout_name'] = self.layout.name
45
+ filename = self.filename.sub(/\.\w+$/, ".yaml")
46
+ File.open(filename, 'w') {|f| f.write YAML.dump(hash)}
47
+ end
48
+
49
+ def layout_name=(name)
50
+ self.layout = Layout.find_by_name(name)
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ namespace :radiant do
2
+ namespace :extensions do
3
+ namespace :templates do
4
+
5
+ desc "Runs the migration of the Templates extension"
6
+ task :migrate => :environment do
7
+ require 'radiant/extension_migrator'
8
+ if ENV["VERSION"]
9
+ TemplatesExtension.migrator.migrate(ENV["VERSION"].to_i)
10
+ else
11
+ TemplatesExtension.migrator.migrate
12
+ end
13
+ end
14
+
15
+ desc "Copies public assets of the Templates to the instance public/ directory."
16
+ task :update => :environment do
17
+ is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
18
+ Dir[TemplatesExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
19
+ path = file.sub(TemplatesExtension.root, '')
20
+ directory = File.dirname(path)
21
+ puts "Copying #{path}..."
22
+ mkdir_p RAILS_ROOT + directory
23
+ cp file, RAILS_ROOT + path
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module Templates::Associations
2
+ def self.included(base)
3
+ base.class_eval {
4
+ belongs_to :template
5
+ }
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ module Templates::ControllerExtensions
2
+ def self.included(base)
3
+ base.class_eval {
4
+ before_filter :load_template, :only => [:new, :edit]
5
+ }
6
+ end
7
+
8
+ def load_template
9
+ unless params[:template].blank?
10
+ case params[:template].to_i
11
+ when 0
12
+ @page.template = @content_template = nil
13
+ params[:page][:template_id] = nil if params[:page]
14
+ else
15
+ @page.template = @content_template = Template.find(params[:template])
16
+ params[:page][:template_id] = @content_template.id if params[:page]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,75 @@
1
+ module Templates::Helper
2
+
3
+ def page_part_name(index)
4
+ "page[parts_attributes][#{index}]"
5
+ end
6
+
7
+ def template_part_field(template_part, index, drafts_enabled = false)
8
+ field_html = []
9
+ if drafts_enabled
10
+ live_part_content = @page.part(template_part.name).try(:content) || '' rescue ''
11
+ live_field_name = "#{page_part_name(index)}[content]"
12
+ live_field_id = "page_parts_#{index}_content"
13
+ # part_content = @page.part(template_part.name).try(:draft_content) || ''
14
+ part_content = @page.part(template_part.name).try(:draft_content) || '' rescue ''
15
+ field_name = "#{page_part_name(index)}[draft_content]"
16
+ field_id = "page_parts_#{index}_draft_content"
17
+ field_html << hidden_field_tag(live_field_name, h(live_part_content), :id => live_field_id)
18
+ else
19
+ part_content = @page.part(template_part.name).try(:content) || '' rescue ''
20
+ field_name = "#{page_part_name(index)}[content]"
21
+ field_id = "page_parts_#{index}_content"
22
+ end
23
+
24
+ options = {:class => template_part.part_type.field_class,
25
+ :style => template_part.part_type.field_styles,
26
+ :id => field_id}.reject{ |k,v| v.blank? }
27
+
28
+ case template_part.part_type.field_type
29
+ when "text_area"
30
+ field_html << text_area_tag(field_name, h(part_content), options)
31
+
32
+ when "text_field"
33
+ field_html << text_field_tag(field_name, h(part_content), options)
34
+
35
+ when "radio_button"
36
+ options[:style] = "display:inline;margin-left:1em;"
37
+ options [:style] << template_part.part_type.field_styles if template_part.part_type.field_styles
38
+ field_html << "<span>"
39
+ options[:id] = "#{field_id}_true"
40
+ field_html << "&mdash;" + radio_button_tag(field_name, "true", part_content =~ /true/, options)
41
+ field_html << label_tag("True",nil,:style=>"display:inline;")
42
+ options[:id] = "#{field_id}_false"
43
+ field_html << radio_button_tag(field_name, "false", part_content !~ /true/, options)
44
+ field_html << label_tag("False",nil,:style=>"display:inline;")
45
+ field_html << "</span>"
46
+
47
+ when "hidden"
48
+ field_html << hidden_field_tag(field_name, part_content, options)
49
+
50
+ when "predefined"
51
+ field_html << hidden_field_tag(field_name, template_part.description, options)
52
+ end
53
+
54
+ field_html.join("\n")
55
+ end
56
+
57
+ def child_menu_for(page)
58
+ children = children_for(page)
59
+ return nil if children.size < 2
60
+ children.unshift(children.delete(page.default_child), :separator) if children.include?(page.default_child)
61
+ name_for = proc { |p| (name = p.name.to_name('Page')).blank? ? t('blank_page') : name }
62
+ content_tag :ul, :class => 'menu', :id => "allowed_children_#{page.id}" do
63
+ children.map do |child|
64
+ if child == :separator
65
+ content_tag :li, nil, :class => 'separator'
66
+ else
67
+ info = child.name.eql?("Page") ? "Add child as 'Blank Page'" : "Add child as '#{child.name}' Page"
68
+ link = child.name.eql?("Page") ? name_for[child] : image('template') + ' ' + name_for[child]
69
+ content_tag :li, link_to(link, new_admin_page_child_path(page, :template => child), :title => info)
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ end