phoenix_core 0.2.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. data/README.md +3 -0
  2. data/app/assets/images/favicon.ico +0 -0
  3. data/app/assets/images/noise.png +0 -0
  4. data/app/assets/javascripts/application.js +14 -0
  5. data/app/assets/stylesheets/application.css +8 -0
  6. data/app/assets/stylesheets/bootstrap.css +2467 -0
  7. data/app/assets/stylesheets/global.css +24 -0
  8. data/app/assets/stylesheets/landing.css +1 -0
  9. data/app/controllers/phoenix/base_controller.rb +5 -0
  10. data/app/controllers/phoenix/home_controller.rb +13 -0
  11. data/app/helpers/phoenix/base_helper.rb +4 -0
  12. data/app/mailers/phoenix/base_mailer.rb +10 -0
  13. data/app/models/phoenix/user.rb +8 -0
  14. data/app/views/phoenix/home/index.html.haml +13 -0
  15. data/app/views/phoenix/layouts/phoenix_core/application.html.erb +14 -0
  16. data/config/initializers/phoenix.rb +3 -0
  17. data/config/initializers/setup_mail.rb +19 -0
  18. data/config/initializers/simple_form.rb +93 -0
  19. data/config/locals/phoenix/en.yml +2 -0
  20. data/config/locals/simple_form/en.yml +23 -0
  21. data/config/locals/simple_form/zn-CN.yml +23 -0
  22. data/config/routes.rb +3 -0
  23. data/lib/generators/phoenix/app/app_generator.rb +209 -0
  24. data/lib/generators/phoenix/dummy/dummy_generator.rb +86 -0
  25. data/lib/generators/phoenix/dummy/templates/rails/Rakefile +7 -0
  26. data/lib/generators/phoenix/dummy/templates/rails/application.rb +14 -0
  27. data/lib/generators/phoenix/dummy/templates/rails/boot.rb +6 -0
  28. data/lib/generators/phoenix/dummy/templates/rails/mongoid.yml +0 -0
  29. data/lib/generators/phoenix/dummy/templates/rails/routes.rb +3 -0
  30. data/lib/generators/phoenix/extension/clash_keywords.yml +3 -0
  31. data/lib/generators/phoenix/extension/extension_generator.rb +137 -0
  32. data/lib/generators/phoenix/extension/templates/Gemfile +13 -0
  33. data/lib/generators/phoenix/extension/templates/README.md +21 -0
  34. data/lib/generators/phoenix/extension/templates/app/assets/javascripts/application.js +1 -0
  35. data/lib/generators/phoenix/extension/templates/app/assets/stylesheets/application.css +3 -0
  36. data/lib/generators/phoenix/extension/templates/app/controllers/phoenix/admin/plural_name_controller.rb +12 -0
  37. data/lib/generators/phoenix/extension/templates/app/controllers/phoenix/plural_name_controller.rb +32 -0
  38. data/lib/generators/phoenix/extension/templates/app/models/phoenix/plural_name/singular_name.rb +27 -0
  39. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_actions.html.erb +28 -0
  40. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_form.html.erb +68 -0
  41. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_plural_name.html.erb +2 -0
  42. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_records.html.erb +18 -0
  43. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_singular_name.html.erb +18 -0
  44. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_sortable_list.html.erb +7 -0
  45. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/edit.html.erb +1 -0
  46. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/index.html.erb +10 -0
  47. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/new.html.erb +1 -0
  48. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/plural_name/index.html.erb +11 -0
  49. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/plural_name/show.html.erb +35 -0
  50. data/lib/generators/phoenix/extension/templates/config/locales/en.yml +5 -0
  51. data/lib/generators/phoenix/extension/templates/config/routes.rb +3 -0
  52. data/lib/generators/phoenix/extension/templates/extension.gemspec +28 -0
  53. data/lib/generators/phoenix/extension/templates/gitignore +10 -0
  54. data/lib/generators/phoenix/extension/templates/lib/generators/phoenix/plural_name_generator.rb +11 -0
  55. data/lib/generators/phoenix/extension/templates/lib/phoenix/plural_name.rb +25 -0
  56. data/lib/generators/phoenix/extension/templates/lib/phoenix/plural_name/engine.rb +29 -0
  57. data/lib/generators/phoenix/extension/templates/lib/phoenix_plural_name.rb +1 -0
  58. data/lib/generators/phoenix/extension/templates/lib/tasks/plural_name.rake +13 -0
  59. data/lib/generators/phoenix/extension/templates/phoenix_plural_name.gemspec +18 -0
  60. data/lib/generators/phoenix/extension/templates/spec/models/phoenix/singular_name_spec.rb +18 -0
  61. data/lib/generators/phoenix/extension/templates/spec/requests/phoenix/admin/plural_name_spec.rb +97 -0
  62. data/lib/generators/phoenix/extension/templates/spec/support/phoenix/factories.rb +7 -0
  63. data/lib/middleware/seo_assist.rb +0 -0
  64. data/lib/phoenix/core.rb +40 -0
  65. data/lib/phoenix/core/controller_helpers.rb +47 -0
  66. data/lib/phoenix/core/development_mail_interceptor.rb +10 -0
  67. data/lib/phoenix/core/engine.rb +10 -0
  68. data/lib/phoenix/core/ssl_requirement.rb +105 -0
  69. data/lib/phoenix/core/testing_support/common_rake.rb +25 -0
  70. data/lib/phoenix/core/testing_support/env.rb +2 -0
  71. data/lib/phoenix/engine.rb +65 -0
  72. data/lib/phoenix/version.rb +16 -0
  73. data/lib/phoenix_core.rb +3 -0
  74. data/lib/tasks/assets.rake +16 -0
  75. data/lib/tasks/phoenix.rake +2 -0
  76. metadata +252 -0
@@ -0,0 +1,86 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Phoenix
5
+ class DummyGenerator < Rails::Generators::Base
6
+ desc "Creates blank Rails application, installs Phoenix Engine, and all sample data"
7
+
8
+ class_option :database, :default => ''
9
+
10
+ def self.source_paths
11
+ paths = self.superclass.source_paths
12
+ paths << File.expand_path('../templates', __FILE__)
13
+ paths.flatten
14
+ end
15
+
16
+ PASSTHROUGH_OPTIONS = [
17
+ :skip_active_record, :skip_javascript, :database, :javascript, :quiet, :pretend, :force, :skip
18
+ ]
19
+
20
+ def generate_test_dummy
21
+ opts = (options || {}).slice(*PASSTHROUGH_OPTIONS)
22
+ opts[:database] = 'sqlite3' if opts[:database].blank?
23
+ opts[:force] = true
24
+ opts[:skip_bundle] = true
25
+ opts[:old_style_hash] = true
26
+
27
+ invoke Rails::Generators::AppGenerator, [ File.expand_path(dummy_path, destination_root) ], opts
28
+ end
29
+
30
+ def test_dummy_config
31
+ @database = options[:database]
32
+
33
+ template "rails/database.yml", "#{dummy_path}/config/database.yml", :force => true
34
+ template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true
35
+ template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true
36
+ template "rails/routes.rb", "#{dummy_path}/config/routes.rb", :force => true
37
+ template "rails/Rakefile", "#{dummy_path}/Rakefile", :force => true
38
+ end
39
+
40
+ def test_dummy_clean
41
+ inside dummy_path do
42
+ remove_file ".gitignore"
43
+ remove_file "doc"
44
+ remove_file "Gemfile"
45
+ remove_file "lib/tasks"
46
+ remove_file "app/assets/images/rails.png"
47
+ remove_file "public/index.html"
48
+ remove_file "public/robots.txt"
49
+ remove_file "README"
50
+ remove_file "test"
51
+ remove_file "vendor"
52
+ end
53
+ end
54
+
55
+ attr :database
56
+
57
+ protected
58
+
59
+ def dummy_path
60
+ 'spec/dummy'
61
+ end
62
+
63
+ def module_name
64
+ 'Dummy'
65
+ end
66
+
67
+ def application_definition
68
+ @application_definition ||= begin
69
+ dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
70
+ unless options[:pretend] || !File.exists?(dummy_application_path)
71
+ contents = File.read(dummy_application_path)
72
+ contents[(contents.index("module #{module_name}"))..-1]
73
+ end
74
+ end
75
+ end
76
+ alias :store_application_definition! :application_definition
77
+
78
+ def camelized
79
+ @camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
80
+ end
81
+
82
+ def gemfile_path
83
+ '../../../../Gemfile'
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ require 'bundler/setup'
6
+
7
+ # If you have a Gemfile, require the default gems, the ones in the
8
+ # current environment and also include :assets gems if in development
9
+ # or test environments.
10
+ Bundler.require *Rails.groups(:assets)
11
+
12
+ require 'phoenix'
13
+
14
+ <%= application_definition %>
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path("<%= gemfile_path %>", __FILE__)
3
+
4
+ ENV['BUNDLE_GEMFILE'] = gemfile
5
+ require 'bundler'
6
+ Bundler.setup
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ - case
2
+ - class
3
+ - switch
@@ -0,0 +1,137 @@
1
+ require 'yaml'
2
+ require 'pathname'
3
+ require 'rails/generators/named_base'
4
+
5
+ module Phoenix
6
+ class ExtensionGenerator < Rails::Generators::NamedBase
7
+ source_root Pathname.new(File.expand_path('../templates', __FILE__))
8
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
9
+
10
+ def generate
11
+ clash_file = Pathname.new(File.expand_path('../clash_keywords.yml', __FILE__))
12
+ clash_keywords = File.open(clash_file) { |f| doc = YAML.load(f) }
13
+ if clash_keywords.member?(singular_name.downcase)
14
+ puts "Please choose a different name. Generated code would fail for class '#{singular_name}'"
15
+ puts ""
16
+ exit(1)
17
+ end
18
+
19
+ if singular_name == plural_name
20
+ puts ""
21
+ if singular_name.singularize != singular_name
22
+ puts "Please specify the singular name '#{singular_name.singularize}' instead of '#{plural_name}'."
23
+ else
24
+ puts "The engine name you specified will not work as the singular name is equal to the plural name."
25
+ end
26
+ puts ""
27
+ exit(1)
28
+ end
29
+
30
+ unless attributes.empty? and self.behavior != :revoke
31
+ if (engine = attributes.detect{|a| a.type.to_s == 'engine'}).present? and attributes.reject!{|a| a.type.to_s == 'engine'}.present?
32
+ engine = engine.name.pluralize
33
+ end
34
+
35
+ Pathname.glob(Pathname.new(self.class.source_root).join('**', '**')).reject{|f| f.directory?}.sort.each do |path|
36
+ unless (engine_path = engine_path_for(path, engine)).nil?
37
+ template path, engine_path
38
+ end
39
+ end
40
+
41
+ if engine.present?
42
+ # go through all of the temporary files and merge what we need into the current files.
43
+ tmp_directories = []
44
+ Dir.glob(File.expand_path('../templates/{config/locales/*.yml,config/routes.rb}', __FILE__), File::FNM_DOTMATCH).sort.each do |path|
45
+ # get the path to the current tmp file.
46
+ new_file_path = Rails.root.join(engine_path_for(path, engine))
47
+ tmp_directories << Pathname.new(new_file_path.to_s.split(File::SEPARATOR)[0..-2].join(File::SEPARATOR)) # save for later
48
+
49
+ # get the path to the existing file and perform a deep hash merge.
50
+ current_path = Pathname.new(new_file_path.to_s.split(File::SEPARATOR).reject{|f| f == 'tmp'}.join(File::SEPARATOR))
51
+ new_contents = nil
52
+ if new_file_path.to_s =~ %r{.yml$}
53
+ # merge translation files together.
54
+ new_contents = YAML::load(new_file_path.read).deep_merge(YAML::load(current_path.read)).to_yaml
55
+ elsif new_file_path.to_s =~ %r{/routes.rb$}
56
+ # append any routes from the new file to the current one.
57
+ routes_file = [(file_parts = current_path.read.to_s.split("\n")).first]
58
+ routes_file += file_parts[1..-2]
59
+ routes_file += new_file_path.read.to_s.split("\n")[1..-2]
60
+ routes_file << file_parts.last
61
+ new_contents = routes_file.join("\n")
62
+ end
63
+ # write to current file the merged results.
64
+ current_path.open('w+') { |f| f.puts new_contents } unless new_contents.nil?
65
+ end
66
+
67
+ if File.exist?(lib_file = engine_path_for(File.expand_path("../templates/lib/phoenix_#{engine.pluralize}.rb", __FILE__), engine))
68
+ append_file lib_file, "\nrequire File.expand_path('../phoenix_#{plural_name}', __FILE__)"
69
+ end
70
+
71
+ tmp_directories.uniq.each{|d| d.rmtree unless d.nil? or !d.exist?}
72
+ end
73
+
74
+ # Update the gem file
75
+ if self.behavior != :revoke and !self.options['pretend']
76
+ unless Rails.env.test?
77
+ Rails.root.join('Gemfile').open('a') do |f|
78
+ f.write "\ngem 'phoenix_#{plural_name}', '1.0', :path => 'vendor/engines'"
79
+ end unless engine.present?
80
+
81
+ puts "------------------------"
82
+ puts "Now run:"
83
+ puts "bundle install"
84
+ unless engine.present?
85
+ puts "rails generate phoenix:#{plural_name}"
86
+ else
87
+ puts "rails generate phoenix:#{engine} #{plural_name}"
88
+ end
89
+ puts "rake db:migrate"
90
+ puts "------------------------"
91
+ end
92
+ elsif self.behavior == :revoke
93
+ lines = Rails.root.join('Gemfile').open('r').read.split("\n")
94
+ Rails.root.join('Gemfile').open('w').puts(lines.reject {|l|
95
+ l =~ %r{phoenix_#{plural_name}}
96
+ }.join("\n"))
97
+
98
+ ::Phoenix::Generators::Migrations.revoke({
99
+ :pattern => File.expand_path('../templates/db/migrate/*.rb', __FILE__),
100
+ :plural_name => plural_name,
101
+ :singular_name => singular_name
102
+ })
103
+ end
104
+ else
105
+ puts "You must specify at least one field. For help: rails generate phoenix:engine"
106
+ end
107
+ end
108
+
109
+ protected
110
+
111
+ def engine_path_for(path, engine)
112
+ engine_path = "vendor/engines/#{engine.present? ? engine : plural_name}/"
113
+ path = path.to_s.gsub(File.expand_path('../templates', __FILE__), engine_path)
114
+
115
+ path = path.gsub("plural_name", plural_name)
116
+ path = path.gsub("singular_name", singular_name)
117
+
118
+ # Detect whether this is a special file that needs to get merged not overwritten.
119
+ # This is important only when nesting engines.
120
+ if engine.present? and File.exist?(path)
121
+ path = if path =~ %r{/locales/.*\.yml$} or path =~ %r{/routes.rb$}
122
+ # put new translations into a tmp directory
123
+ path.split(File::SEPARATOR).insert(-2, "tmp").join(File::SEPARATOR)
124
+ elsif path =~ %r{/readme.md$} or path =~ %r{/#{plural_name}.rb$}
125
+ nil
126
+ else
127
+ path
128
+ end
129
+ elsif engine.present? and path =~ /lib\/#{plural_name}.rb$/
130
+ path = nil
131
+ end
132
+
133
+ path
134
+ end
135
+
136
+ end
137
+ end
@@ -0,0 +1,13 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'ffaker'
5
+ end
6
+
7
+ if RUBY_VERSION < "1.9"
8
+ gem "ruby-debug"
9
+ else
10
+ gem "ruby-debug19"
11
+ end
12
+
13
+ gemspec
@@ -0,0 +1,21 @@
1
+ <%= class_name %>
2
+ <%= "=" * class_name.size %>
3
+
4
+ Introduction goes here.
5
+
6
+
7
+ Example
8
+ =======
9
+
10
+ Example goes here.
11
+
12
+ Testing
13
+ -------
14
+
15
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
16
+
17
+ $ bundle
18
+ $ bundle exec rake test app
19
+ $ bundle exec rspec spec
20
+
21
+ Copyright (c) <%= Date.today.year %> [name of extension creator], released under the New BSD License
@@ -0,0 +1,12 @@
1
+ module ::Phoenix
2
+ module Admin
3
+ class <%= class_name.pluralize %>Controller < ::Phoenix::AdminController
4
+
5
+ crudify :'phoenix/<%= singular_name %>'<% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? and title.name != 'title' %>,
6
+ :title_attribute => '<%= title.name %>'<% end %><% if plural_name == singular_name %>,
7
+ :redirect_to_url => :admin_<%= singular_name %>_index_path
8
+ <% end %>, :xhr_paging => true
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ module ::Phoenix
2
+ class <%= class_name.pluralize %>Controller < ::ApplicationController
3
+
4
+ before_filter :find_all_<%= plural_name %>
5
+ before_filter :find_page
6
+
7
+ def index
8
+ # you can use meta fields from your model instead (e.g. browser_title)
9
+ # by swapping @page for @<%= singular_name %> in the line below:
10
+ present(@page)
11
+ end
12
+
13
+ def show
14
+ @<%= singular_name %> = ::Phoenix::<%= class_name.pluralize %>::<%= class_name %>.find(params[:id])
15
+
16
+ # you can use meta fields from your model instead (e.g. browser_title)
17
+ # by swapping @page for @<%= singular_name %> in the line below:
18
+ present(@page)
19
+ end
20
+
21
+ protected
22
+
23
+ def find_all_<%= plural_name %>
24
+ @<%= "all_" if plural_name == singular_name %><%= plural_name %> = ::Phoenix::<%= class_name.pluralize %>::<%= class_name %>.order('position ASC')
25
+ end
26
+
27
+ def find_page
28
+ @page = ::Phoenix::Page.where(:link_url => "/<%= plural_name %>").first
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ module Phoenix
2
+ module <%= class_name.pluralize %>
3
+ class <%= class_name %> < ActiveRecord::Base
4
+ set_table_name :phoenix_<%= plural_name %>
5
+
6
+ <% if (string_attributes = attributes.map{ |attribute| attribute.name.to_sym if attribute.type.to_s =~ /string|text/ }.compact.uniq).any? %>
7
+ acts_as_indexed :fields => <%= string_attributes.inspect %>
8
+
9
+ validates <%= string_attributes.first.inspect %>, :presence => true, :uniqueness => true
10
+ <% else %>
11
+ # def title was created automatically because you didn't specify a string field
12
+ # when you ran the phoenix:engine generator. <3 <3 Phoenix CMS.
13
+ def title
14
+ "Override def title in vendor/engines/<%= plural_name %>/app/models/phoenix/<%= plural_name %>/<%= singular_name %>.rb"
15
+ end
16
+ <% end -%>
17
+ <% attributes.collect{|a| a if a.type.to_s == 'image'}.compact.uniq.each do |a| -%>
18
+
19
+ belongs_to :<%= a.name.gsub("_id", "") -%><%= ", :class_name => '::Phoenix::Image'" unless a.name =~ /^image(_id)?$/ -%>
20
+ <% end -%>
21
+ <% attributes.collect{|a| a if a.type.to_s == 'resource'}.compact.uniq.each do |a| -%>
22
+
23
+ belongs_to :<%= a.name.gsub("_id", "") %><%= ", :class_name => '::Phoenix::Resource'" unless a.name =~ /^resource(_id)?$/ -%>
24
+ <% end %>
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ <ul>
2
+ <%% if ::Phoenix::Admin::<%= class_name.pluralize %>Controller.searchable? %>
3
+ <li>
4
+ <%%= render :partial => "/refinery/admin/search",
5
+ :locals => {
6
+ :url => main_app.refinery_admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_path
7
+ } %>
8
+ </li>
9
+ <%% end %>
10
+ <li>
11
+ <%%= link_to t('.create_new'), main_app.new_refinery_admin_<%= singular_name %>_path,
12
+ :class => "add_icon" %>
13
+ </li>
14
+ <%% if !searching? && ::Phoenix::Admin::<%= class_name.pluralize %>Controller.sortable? && ::Phoenix::<%= class_name.pluralize %>::<%= class_name %>.any? %>
15
+ <li>
16
+ <%%= link_to t('.reorder', :what => "<%= singular_name.titleize.pluralize %>"),
17
+ main_app.refinery_admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_path,
18
+ :id => "reorder_action",
19
+ :class => "reorder_icon" %>
20
+
21
+ <%%= link_to t('.reorder_done', :what => "<%= singular_name.titleize.pluralize %>"),
22
+ main_app.refinery_admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_path,
23
+ :id => "reorder_action_done",
24
+ :style => "display: none;",
25
+ :class => "reorder_icon" %>
26
+ </li>
27
+ <%% end %>
28
+ </ul>
@@ -0,0 +1,68 @@
1
+ <%
2
+ text_areas = attributes.reject{|a| a.field_type.to_s != 'text_area'}
3
+ generated_text_areas = false
4
+ -%>
5
+ <%%= form_for [main_app, :refinery_admin, @<%= singular_name %>] do |f| -%>
6
+ <%%= render :partial => "/refinery/admin/error_messages", :locals => {
7
+ :object => @<%= singular_name %>,
8
+ :include_object_name => true
9
+ } %>
10
+ <% attributes.each_with_index do |attribute, index| %>
11
+ <% if attribute.field_type.to_s != 'text_area' -%>
12
+ <div class='field'>
13
+ <%%= f.label :<%= attribute.name %> -%>
14
+ <% end -%>
15
+ <% if attribute.type.to_s == 'image' -%>
16
+ <%%= render :partial => "/refinery/admin/image_picker", :locals => {
17
+ :f => f,
18
+ :field => :<%= "#{attribute.name}_id".gsub("_id_id", "_id") %>,
19
+ :image => @<%= singular_name %>.<%= attribute.name.gsub("_id", "") %>,
20
+ :toggle_image_display => false
21
+ } %>
22
+ <% elsif attribute.type.to_s == 'resource' -%>
23
+ <%%= render :partial => "/refinery/admin/resource_picker", :locals => {
24
+ :f => f,
25
+ :field => :<%= "#{attribute.name}_id".gsub("_id_id", "_id") %>,
26
+ :resource => @<%= singular_name %>.<%= attribute.name.gsub("_id", "") %>,
27
+ } %>
28
+ <% elsif attribute.field_type.to_s == "text_area" and !generated_text_areas -%>
29
+ <div class='field'>
30
+ <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
31
+ <ul id='page_parts'>
32
+ <%% <%= text_areas.map{|t| t.name.to_sym}.inspect -%>.each_with_index do |part, part_index| %>
33
+ <li class='ui-state-default<%%= ' ui-state-active' if part_index == 0 %>'>
34
+ <%%= link_to part.to_s.titleize, "##{part}" %>
35
+ </li>
36
+ <%% end %>
37
+ </ul>
38
+
39
+ <div id='page_part_editors'>
40
+ <%% <%= text_areas.map{|t| t.name.to_sym}.inspect -%>.each do |part| %>
41
+ <div class='page_part' id='<%%= part %>'>
42
+ <%%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
43
+ </div>
44
+ <%% end %>
45
+ </div>
46
+ <% generated_text_areas = true -%>
47
+ <% elsif attribute.field_type.to_s != 'text_area' -%>
48
+ <%%= f.<%= attribute.field_type -%> :<%= attribute.name -%><%= ", :class => 'larger widest'" if (index == 0 && attribute.field_type == :text_field) -%><%= ", :checked => @#{singular_name}[:#{attribute.name}]" if attribute.field_type == :check_box %> -%>
49
+ <% end -%>
50
+ </div>
51
+ <% end %>
52
+ <%%= render :partial => "/refinery/admin/form_actions",
53
+ :locals => {
54
+ :f => f,
55
+ :continue_editing => false,
56
+ :delete_title => t('delete', :scope => 'refinery.admin.<%= plural_name %>.<%= singular_name %>'),
57
+ :delete_confirmation => t('message', :scope => 'refinery.admin.delete'<% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>, :title => @<%= singular_name %>.<%= title.name %><% end %>)
58
+ } %>
59
+ <%% end -%>
60
+ <% if text_areas.any? -%>
61
+ <%% content_for :javascripts do %>
62
+ <script>
63
+ $(document).ready(function(){
64
+ page_options.init(false, '', '');
65
+ });
66
+ </script>
67
+ <%% end %>
68
+ <% end -%>