radiant-templates-extension 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HELP_designer.textile +79 -0
- data/README.textile +123 -0
- data/Rakefile +136 -0
- data/VERSION +1 -0
- data/app/controllers/admin/part_types_controller.rb +8 -0
- data/app/controllers/admin/templates_controller.rb +38 -0
- data/app/helpers/admin/part_types_helper.rb +26 -0
- data/app/helpers/admin/templates_helper.rb +108 -0
- data/app/models/part_type.rb +14 -0
- data/app/models/template.rb +80 -0
- data/app/models/template_part.rb +21 -0
- data/app/views/admin/pages/_edit_template.html.haml +32 -0
- data/app/views/admin/pages/_edit_template_part.html.haml +20 -0
- data/app/views/admin/pages/_switch_templates.html.haml +23 -0
- data/app/views/admin/pages/_template_column.html.haml +3 -0
- data/app/views/admin/pages/_template_column_header.html.haml +1 -0
- data/app/views/admin/part_types/_form.html.haml +36 -0
- data/app/views/admin/part_types/_list.html.haml +23 -0
- data/app/views/admin/part_types/edit.html.haml +5 -0
- data/app/views/admin/part_types/index.html.haml +7 -0
- data/app/views/admin/part_types/new.html.haml +2 -0
- data/app/views/admin/part_types/remove.html.haml +15 -0
- data/app/views/admin/templates/_form.html.haml +65 -0
- data/app/views/admin/templates/_template_part.html.haml +21 -0
- data/app/views/admin/templates/_templates_css.html.haml +12 -0
- data/app/views/admin/templates/edit.html.haml +10 -0
- data/app/views/admin/templates/index.html.haml +47 -0
- data/app/views/admin/templates/new.html.haml +9 -0
- data/app/views/admin/templates/remove.html.haml +15 -0
- data/config/initializers/radiant_config.rb +3 -0
- data/config/locales/en.yml +32 -0
- data/config/routes.rb +7 -0
- data/db/migrate/001_create_templates.rb +17 -0
- data/db/migrate/002_create_template_parts.rb +15 -0
- data/db/migrate/003_rename_sublayout_column.rb +9 -0
- data/db/migrate/004_add_position_to_templates.rb +13 -0
- data/db/migrate/005_create_part_types.rb +17 -0
- data/db/migrate/006_add_description_to_template_parts.rb +9 -0
- data/db/migrate/007_add_page_class_name_to_templates.rb +9 -0
- data/db/migrate/008_add_index_to_templates.rb +9 -0
- data/db/migrate/009_create_default_part_types.rb +23 -0
- data/db/migrate/010_update_boolean_part_type.rb +9 -0
- data/db/migrate/011_add_timestamps.rb +19 -0
- data/lib/file_system/model/part_type_extensions.rb +19 -0
- data/lib/file_system/model/template_extensions.rb +52 -0
- data/lib/tasks/templates_extension_tasks.rake +28 -0
- data/lib/templates/associations.rb +7 -0
- data/lib/templates/controller_extensions.rb +20 -0
- data/lib/templates/helper.rb +75 -0
- data/lib/templates/page_extensions.rb +43 -0
- data/lib/templates/tags.rb +43 -0
- data/public/images/admin/menu_arrow.png +0 -0
- data/public/images/admin/move_higher.png +0 -0
- data/public/images/admin/move_lower.png +0 -0
- data/public/images/admin/move_to_bottom.png +0 -0
- data/public/images/admin/move_to_top.png +0 -0
- data/public/images/admin/part_type.png +0 -0
- data/public/images/admin/template.png +0 -0
- data/spec/controllers/admin_page_controller_extensions_spec.rb +61 -0
- data/spec/controllers/part_types_controller_spec.rb +89 -0
- data/spec/controllers/templates_controller_spec.rb +322 -0
- data/spec/datasets/part_types_dataset.rb +15 -0
- data/spec/datasets/templates_dataset.rb +34 -0
- data/spec/helpers/templates_helper_spec.rb +56 -0
- data/spec/models/page_extensions_spec.rb +9 -0
- data/spec/models/part_type_spec.rb +28 -0
- data/spec/models/tags_spec.rb +44 -0
- data/spec/models/template_part_spec.rb +37 -0
- data/spec/models/template_spec.rb +88 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +39 -0
- data/templates_extension.rb +83 -0
- data/vendor/plugins/acts_as_list/README +23 -0
- data/vendor/plugins/acts_as_list/init.rb +3 -0
- data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
- data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
- data/vendor/plugins/make_resourceful/DEFAULTS +148 -0
- data/vendor/plugins/make_resourceful/LICENSE +7 -0
- data/vendor/plugins/make_resourceful/README +239 -0
- data/vendor/plugins/make_resourceful/Rakefile +42 -0
- data/vendor/plugins/make_resourceful/VERSION +1 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb +87 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/controller.rb +5 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/fixtures.yml +10 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/functional_test.rb +57 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/helper.rb +2 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/migration.rb +13 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/model.rb +2 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/unit_test.rb +7 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view__form.haml +5 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_edit.haml +11 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_index.haml +5 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_new.haml +9 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_partial.haml +12 -0
- data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_show.haml +14 -0
- data/vendor/plugins/make_resourceful/init.rb +3 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/base.rb +52 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/builder.rb +354 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/accessors.rb +346 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/actions.rb +92 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/callbacks.rb +51 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/responses.rb +118 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/default/urls.rb +137 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/maker.rb +83 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/response.rb +33 -0
- data/vendor/plugins/make_resourceful/lib/resourceful/serialize.rb +181 -0
- data/vendor/plugins/make_resourceful/spec/accessors_spec.rb +473 -0
- data/vendor/plugins/make_resourceful/spec/actions_spec.rb +283 -0
- data/vendor/plugins/make_resourceful/spec/base_spec.rb +12 -0
- data/vendor/plugins/make_resourceful/spec/builder_spec.rb +332 -0
- data/vendor/plugins/make_resourceful/spec/callbacks_spec.rb +71 -0
- data/vendor/plugins/make_resourceful/spec/integration_spec.rb +396 -0
- data/vendor/plugins/make_resourceful/spec/maker_spec.rb +91 -0
- data/vendor/plugins/make_resourceful/spec/response_spec.rb +37 -0
- data/vendor/plugins/make_resourceful/spec/responses_spec.rb +314 -0
- data/vendor/plugins/make_resourceful/spec/rspec_on_rails/LICENSE +35 -0
- data/vendor/plugins/make_resourceful/spec/rspec_on_rails/redirect_to.rb +81 -0
- data/vendor/plugins/make_resourceful/spec/rspec_on_rails/render_template.rb +28 -0
- data/vendor/plugins/make_resourceful/spec/serialize_spec.rb +133 -0
- data/vendor/plugins/make_resourceful/spec/spec_helper.rb +279 -0
- data/vendor/plugins/make_resourceful/spec/urls_spec.rb +276 -0
- metadata +214 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
The Templates extension provides internal structure to Radiant pages, adding a layer of flexibility in Layout development. This allows a single Layout to serve as a wireframe for the entire site, with many different template page designs filling the "content well." Using templates, you now only need a single <r:content /> tag within the Layout. Thus we simplify and ensure layout consistency in the creation of pages by the end user of the CMS.
|
2
|
+
|
3
|
+
h2. Usage
|
4
|
+
|
5
|
+
h3. Creating a template
|
6
|
+
|
7
|
+
For each new template:
|
8
|
+
|
9
|
+
* Add the template parts, specifying the part type, and their filters. Each part will be editable in the page interface.
|
10
|
+
* Create the structure of the page, using the template parts you have created.
|
11
|
+
* Specify the Layout and page class that will be used by pages with a given template.
|
12
|
+
|
13
|
+
Let's say I want a template for press releases. Press releases consist of a short description which also serves as the first paragraph, a longer description, a location, contact information, and standard information about the company. So I would create the new template like so:
|
14
|
+
|
15
|
+
h4. The template parts
|
16
|
+
|
17
|
+
For each template part, you specify _name_, _description_, _type_ (part type) and _filter_ (formatting filter like Textile or Markdown):
|
18
|
+
|
19
|
+
The would be, respectively, for the needed parts:
|
20
|
+
|
21
|
+
# Location, City of Origin, One-line, none
|
22
|
+
# Short description, Introductory blurb, One-line, none
|
23
|
+
# Long description, The full text of the Press Release, Plain textarea, Textile
|
24
|
+
# Contact information, Whom to contact for details, Plain textarea, Textile
|
25
|
+
|
26
|
+
h4. The structure
|
27
|
+
|
28
|
+
Now you set the structure (which becomes the 'body' page-part) to be something like:
|
29
|
+
|
30
|
+
<pre><code>
|
31
|
+
<div class="press-release">
|
32
|
+
<p class="contact"><r:content part="Contact information" /></p>
|
33
|
+
<p><strong><r:date format="%d %m %Y"/>,
|
34
|
+
<r:content part="Location"/></strong> -
|
35
|
+
<r:content part="Short description"/>
|
36
|
+
</p>
|
37
|
+
<r:content part="Long description" />
|
38
|
+
<r:snippet name="corporate-press-release-blurb" />
|
39
|
+
</div>
|
40
|
+
</code></pre>
|
41
|
+
|
42
|
+
This will not be visible to the Page Editors. They will only see the Template parts you've defined, along with their descriptions as form field labels.
|
43
|
+
|
44
|
+
h4. Layout and Page Type
|
45
|
+
|
46
|
+
Finally, at the bottom of the Edit page, set the Layout (normally your standard one), and Page Type according to preference. These cannot be changed by the Page editors.
|
47
|
+
|
48
|
+
h3. Applying a template
|
49
|
+
|
50
|
+
h4. Creating a new page
|
51
|
+
|
52
|
+
* Click "Add Child" to create a child page an existing page.
|
53
|
+
* Dropdown menu appears listing "Blank Page" (no template), and all the currently defined templates.
|
54
|
+
* Select the template you wish for the new page.
|
55
|
+
* Voilá. Now just fill in the template-defined page parts.
|
56
|
+
|
57
|
+
h4. Changing the template for an existing page
|
58
|
+
|
59
|
+
* When editing the page, expand the meta drawer, by clicking 'More' underneath the Page Title.
|
60
|
+
* You will see the current template bolded, and the others as links
|
61
|
+
* To change to another template, simply select it, and save the page.
|
62
|
+
|
63
|
+
WARNING: For page parts of your old template, if your new template does a page parts of the same name, then that content will be lost. This is a good reason to follow naming standards when creating templates, e.g. define a page part "main_content" for all your templates.
|
64
|
+
|
65
|
+
h2. Admin
|
66
|
+
|
67
|
+
h3. Template Part Types (Admin users only)
|
68
|
+
|
69
|
+
h4. Access
|
70
|
+
|
71
|
+
Only Admin users have access to create and edit part types. Default part types should not be removed. Care should be taken in editing them, since any change to part type will affect every template which uses it, and hence potentially every page which is built with any of those templates.
|
72
|
+
|
73
|
+
h4. Management
|
74
|
+
|
75
|
+
Each Part type has Name and Field Type (e.g. radio_button, or text_field). They also have optional Field Class and Field Style, by which the admin user can alter the display characteristics of the parts to the page editors.
|
76
|
+
|
77
|
+
Normally new part types would only be created to refine display characteristics. For example, you might want a "Small Textarea" part type, which would be exactly the same as the default "Plain Textarea" part type, except that Field Style would have "height:80px".
|
78
|
+
|
79
|
+
|
data/README.textile
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
h1. Templates
|
2
|
+
|
3
|
+
The Templates extension provides internal structure to Radiant pages which adds an extra layer
|
4
|
+
of flexibility in Layout development. This allows my one Layout to serve as a wireframe for the entire site, with many different page designs filling the "content well." I now only need a single <r:content /> tag within the Layout to accomplish this. Thus we simplify and ensure layout consistency in the creation of pages by the end user of the CMS.
|
5
|
+
|
6
|
+
h2. Requirements
|
7
|
+
|
8
|
+
The current version of the Templates extension is intended for use with Radiant 0.9.1 or higher, since its UI was made to match the new "Blade" UI of Radiant 9. It may work with earlier versions, but there are no guarantees. The "radiant-0.7.1 branch":https://github.com/avonderluft/radiant-templates-extension/tree/radiant-0.7.1 works with Radiant >= 0.7.1 and < 0.9.
|
9
|
+
|
10
|
+
h2. Version History
|
11
|
+
|
12
|
+
* 1.0.0 - gemified by Andrew vonderLuft, March 2011
|
13
|
+
* 0.9 - Radiant 0.9 Blade UI, i18n additions Andrew vonderLuft, January 2011 -
|
14
|
+
* -- Radiant 0.8 compatible, Andrew vonderLuft, May 2010
|
15
|
+
* -- Refactored to standard structure under /admin, admin UI for Part Types added, backward compatibility to < 0.8, by Andrew vonderLuft, November 2009,
|
16
|
+
* -- Refactored by Sean Cribbs, August 2008
|
17
|
+
* -- Radiant 0.7 Compatible, March 2009 ("radiant-0.7.1 branch":https://github.com/avonderluft/radiant-templates-extension/tree/radiant-0.7.1)
|
18
|
+
* -- Created by Sean Cribbs, September 2007
|
19
|
+
|
20
|
+
h3. Installation
|
21
|
+
|
22
|
+
h4. From github:
|
23
|
+
|
24
|
+
* From your Radiant root run:
|
25
|
+
|
26
|
+
<pre>git clone git://github.com/avonderluft/radiant-templates-extension.git ./vendor/extensions/templates
|
27
|
+
rake radiant:extensions:templates:migrate
|
28
|
+
rake radiant:extensions:templates:update
|
29
|
+
</pre>
|
30
|
+
|
31
|
+
* Restart your radiant app, and you should be good to go.
|
32
|
+
|
33
|
+
h4. Using the gem
|
34
|
+
|
35
|
+
* Install the gem
|
36
|
+
|
37
|
+
<pre>gem install radiant-concurrent_draft-extension</pre>
|
38
|
+
|
39
|
+
* Update your Radiant config: add to environment.rb with other gem.configs
|
40
|
+
|
41
|
+
<pre>config.gem 'radiant-concurrent_draft-extension', :lib => false</pre>
|
42
|
+
|
43
|
+
h2. Usage
|
44
|
+
|
45
|
+
h3. Creating a template
|
46
|
+
|
47
|
+
For each new template:
|
48
|
+
|
49
|
+
* Add the template parts, specifying the part type, and their filters. Each part will be editable in the page interface.
|
50
|
+
* Create the structure of the page, using the template parts you have created.
|
51
|
+
* Specify the Layout and page class that will be used by pages with a given template.
|
52
|
+
|
53
|
+
Let's say I want a template for press releases. Press releases consist of a short description which also serves as the first paragraph, a longer description, a location, contact information, and standard information about the company. So I would create the new template like so:
|
54
|
+
|
55
|
+
h4. The template parts
|
56
|
+
|
57
|
+
For each template part, you specify _name_, _description_, _type_ (part type) and _filter_ (formatting filter like Textile or Markdown):
|
58
|
+
|
59
|
+
The would be, respectively, for the needed parts:
|
60
|
+
|
61
|
+
# Location, City of Origin, One-line, none
|
62
|
+
# Short description, Introductory blurb, One-line, none
|
63
|
+
# Long description, The full text of the Press Release, Plain textarea, Textile
|
64
|
+
# Contact information, Whom to contact for details, Plain textarea, Textile
|
65
|
+
|
66
|
+
h4. The structure
|
67
|
+
|
68
|
+
Now you set the structure (which becomes the 'body' page-part) to be something like:
|
69
|
+
|
70
|
+
<pre><code>
|
71
|
+
<div class="press-release">
|
72
|
+
<p class="contact"><r:content part="Contact information" /></p>
|
73
|
+
<p><strong><r:date format="%d %m %Y"/>,
|
74
|
+
<r:content part="Location"/></strong> -
|
75
|
+
<r:content part="Short description"/>
|
76
|
+
</p>
|
77
|
+
<r:content part="Long description" />
|
78
|
+
<r:snippet name="corporate-press-release-blurb" />
|
79
|
+
</div>
|
80
|
+
</code></pre>
|
81
|
+
|
82
|
+
This will not be visible to the Page Editors. They will only see the Template parts you've defined, along with their descriptions as form field labels.
|
83
|
+
|
84
|
+
h4. Layout and Page Type
|
85
|
+
|
86
|
+
Finally, at the bottom of the Edit page, set the Layout (normally your standard one), and Page Type according to preference. These cannot be changed by the Page editors.
|
87
|
+
|
88
|
+
h3. Applying a template
|
89
|
+
|
90
|
+
h4. Creating a new page
|
91
|
+
|
92
|
+
* Click "Add Child" to create a child page an existing page.
|
93
|
+
* Dropdown menu appears listing "Blank Page" (no template), and all the currently defined templates.
|
94
|
+
* Select the template you wish for the new page.
|
95
|
+
* Voilá. Now just fill in the template-defined page parts.
|
96
|
+
|
97
|
+
h4. Changing the template for an existing page
|
98
|
+
|
99
|
+
* When editing the page, expand the meta drawer, by clicking 'More' underneath the Page Title.
|
100
|
+
* You will see the current template bolded, and the others as links
|
101
|
+
* To change to another template, simply select it, and save the page.
|
102
|
+
|
103
|
+
WARNING: For page parts of your old template, if your new template does a page parts of the same name, then that content will be lost. This is a good reason to follow naming standards when creating templates, e.g. define a page part "main_content" for all your templates.
|
104
|
+
|
105
|
+
h2. Admin
|
106
|
+
|
107
|
+
h3. Template Part Types (Admin users only)
|
108
|
+
|
109
|
+
h4. Access
|
110
|
+
|
111
|
+
Only Admin users have access to create and edit part types. Default part types should not be removed. Care should be taken in editing them, since any change to part type will affect every template which uses it, and hence potentially every page which is built with any of those templates.
|
112
|
+
|
113
|
+
h4. Management
|
114
|
+
|
115
|
+
Each Part type has Name and Field Type (e.g. radio_button, or text_field). They also have optional Field Class and Field Style, by which the admin user can alter the display characteristics of the parts to the page editors.
|
116
|
+
|
117
|
+
Normally new part types would only be created to refine display characteristics. For example, you might want a "Small Textarea" part type, which would be exactly the same as the default "Plain Textarea" part type, except that Field Style would have "height:80px".
|
118
|
+
|
119
|
+
h2. Acknowledgments
|
120
|
+
|
121
|
+
Thanks to Digital Pulp for funding the initial development of this extension
|
122
|
+
for use in the Redken project, and to Con-way for funding further
|
123
|
+
development.
|
data/Rakefile
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gem|
|
4
|
+
gem.name = "radiant-templates-extension"
|
5
|
+
gem.summary = %Q{Templates Extension for Radiant CMS}
|
6
|
+
gem.description = %Q{Imposes structure on pages via content templates.}
|
7
|
+
gem.email = "avonderluft@avlux.net"
|
8
|
+
gem.homepage = "https://github.com/avonderluft/radiant-templates-extension"
|
9
|
+
gem.authors = ['Andrew vonderLuft','Sean Cribbs']
|
10
|
+
gem.add_dependency 'radiant', ">=0.9.1"
|
11
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
12
|
+
end
|
13
|
+
rescue LoadError
|
14
|
+
puts "Jeweler (or a dependency) not available. This is only required if you plan to package concurrent_draft as a gem."
|
15
|
+
end
|
16
|
+
|
17
|
+
# I think this is the one that should be moved to the extension Rakefile template
|
18
|
+
|
19
|
+
# In rails 1.2, plugins aren't available in the path until they're loaded.
|
20
|
+
# Check to see if the rspec plugin is installed first and require
|
21
|
+
# it if it is. If not, use the gem version.
|
22
|
+
|
23
|
+
# Determine where the RSpec plugin is by loading the boot
|
24
|
+
unless defined? RADIANT_ROOT
|
25
|
+
ENV["RAILS_ENV"] = "test"
|
26
|
+
case
|
27
|
+
when ENV["RADIANT_ENV_FILE"]
|
28
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
29
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
30
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
31
|
+
else
|
32
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rake'
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
require 'rake/testtask'
|
39
|
+
|
40
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
41
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
42
|
+
require 'spec/rake/spectask'
|
43
|
+
# require 'spec/translator'
|
44
|
+
|
45
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
46
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
47
|
+
|
48
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
49
|
+
|
50
|
+
task :default => :spec
|
51
|
+
task :stats => "spec:statsetup"
|
52
|
+
|
53
|
+
desc "Run all specs in spec directory"
|
54
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
55
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
56
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
57
|
+
end
|
58
|
+
|
59
|
+
namespace :spec do
|
60
|
+
desc "Run all specs in spec directory with RCov"
|
61
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
62
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
63
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
64
|
+
t.rcov = true
|
65
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Print Specdoc for all specs"
|
69
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
70
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
71
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
72
|
+
end
|
73
|
+
|
74
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
75
|
+
desc "Run the specs under spec/#{sub}"
|
76
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
77
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
78
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Hopefully no one has written their extensions in pre-0.9 style
|
83
|
+
# desc "Translate specs from pre-0.9 to 0.9 style"
|
84
|
+
# task :translate do
|
85
|
+
# translator = ::Spec::Translator.new
|
86
|
+
# dir = RAILS_ROOT + '/spec'
|
87
|
+
# translator.translate(dir, dir)
|
88
|
+
# end
|
89
|
+
|
90
|
+
# Setup specs for stats
|
91
|
+
task :statsetup do
|
92
|
+
require 'code_statistics'
|
93
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
94
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
95
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
96
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
97
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
98
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
99
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
100
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
101
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
102
|
+
end
|
103
|
+
|
104
|
+
namespace :db do
|
105
|
+
namespace :fixtures do
|
106
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
107
|
+
task :load => :environment do
|
108
|
+
require 'active_record/fixtures'
|
109
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
110
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
111
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
desc 'Generate documentation for the templates extension.'
|
119
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
120
|
+
rdoc.rdoc_dir = 'rdoc'
|
121
|
+
rdoc.title = 'TemplatesExtension'
|
122
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
123
|
+
rdoc.rdoc_files.include('README')
|
124
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
125
|
+
end
|
126
|
+
|
127
|
+
# For extensions that are in transition
|
128
|
+
desc 'Test the templates extension.'
|
129
|
+
Rake::TestTask.new(:test) do |t|
|
130
|
+
t.libs << 'lib'
|
131
|
+
t.pattern = 'test/**/*_test.rb'
|
132
|
+
t.verbose = true
|
133
|
+
end
|
134
|
+
|
135
|
+
# Load any custom rakefiles for extension
|
136
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class Admin::PartTypesController < Admin::ResourceController
|
2
|
+
|
3
|
+
only_allow_access_to :index, :show, :new, :edit, :create, :update, :remove, :destroy,
|
4
|
+
:when => [:admin],
|
5
|
+
:denied_url => { :controller => 'admin/pages', :action => 'index' },
|
6
|
+
:denied_message => 'You must have admin privileges to perform this action.'
|
7
|
+
|
8
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Admin::TemplatesController < ApplicationController
|
2
|
+
|
3
|
+
only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy, :move_higher, :move_lower, :move_to_top, :move_to_bottom,
|
4
|
+
:when => [:designer, :admin],
|
5
|
+
:denied_url => { :controller => 'admin/pages', :action => 'index' },
|
6
|
+
:denied_message => 'You must have designer privileges to perform this action.'
|
7
|
+
|
8
|
+
make_resourceful do
|
9
|
+
actions :index, :show, :new, :create, :edit, :update, :remove, :destroy
|
10
|
+
|
11
|
+
response_for(:show) do
|
12
|
+
redirect_to edit_admin_template_url
|
13
|
+
end
|
14
|
+
|
15
|
+
response_for(:create, :update) do
|
16
|
+
redirect_to params[:continue] ? edit_admin_template_url(current_object) : objects_path
|
17
|
+
end
|
18
|
+
|
19
|
+
response_for(:destroy, :destroy_fails) do
|
20
|
+
redirect_to objects_path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Ordering actions
|
25
|
+
%w{move_higher move_lower move_to_top move_to_bottom}.each do |action|
|
26
|
+
define_method action do
|
27
|
+
load_object
|
28
|
+
Template.reordering do
|
29
|
+
current_object.send(action)
|
30
|
+
end
|
31
|
+
request.env["HTTP_REFERER"] ? redirect_to(:back) : redirect_to(objects_path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def instance_variable_name
|
36
|
+
'content_templates'
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Admin::PartTypesHelper
|
2
|
+
|
3
|
+
def updated_stamp(model)
|
4
|
+
unless model.new_record?
|
5
|
+
updated_by = (model.updated_by || model.created_by) if model.respond_to?(:updated_by)
|
6
|
+
login = updated_by ? updated_by.login : nil
|
7
|
+
time = (model.updated_at || model.created_at)
|
8
|
+
# promoted_at = model.draft_promoted_at if model.respond_to?(:draft_promoted_at)
|
9
|
+
html = %{<p style="clear: left"><small>}
|
10
|
+
if login or time
|
11
|
+
html << 'Last updated '
|
12
|
+
html << %{by #{login} } if login
|
13
|
+
html << %{at #{ timestamp(time) }} if time
|
14
|
+
html << '. '
|
15
|
+
end
|
16
|
+
# if promoted_at
|
17
|
+
# html << %{Last promoted at #{ timestamp(promoted_at) }.}
|
18
|
+
# end
|
19
|
+
html << %{</small></p>}
|
20
|
+
html
|
21
|
+
else
|
22
|
+
%{<p class="clear"> </p>}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module Admin::TemplatesHelper
|
2
|
+
|
3
|
+
def template_edit_javascripts
|
4
|
+
<<-JS
|
5
|
+
var template_parts_index = 0;
|
6
|
+
var template_part_partial = new Template(#{blank_template_part});
|
7
|
+
function new_template_part(){
|
8
|
+
var parts = $('parts');
|
9
|
+
if(parts.down('.template_part')){
|
10
|
+
var id = parts.select('.template_part').last().id;
|
11
|
+
template_parts_index = parseInt(id.split("_").last());
|
12
|
+
}
|
13
|
+
template_parts_index += 1;
|
14
|
+
new Insertion.Bottom('parts', template_part_partial.evaluate({index: template_parts_index}));
|
15
|
+
}
|
16
|
+
|
17
|
+
function zeroPad(num,count){
|
18
|
+
var numZeropad = num + '';
|
19
|
+
while(numZeropad.length < count) {
|
20
|
+
numZeropad = "0" + numZeropad;
|
21
|
+
}
|
22
|
+
return numZeropad;
|
23
|
+
}
|
24
|
+
|
25
|
+
function fix_template_part_indexes(){
|
26
|
+
var parts = $('parts');
|
27
|
+
var new_index = 0;
|
28
|
+
parts.select(".template_part").each(function(row){
|
29
|
+
new_index += 1;
|
30
|
+
row.select("input, select, textarea").each(function(input){
|
31
|
+
input.name = input.name.sub(/\\d+/, zeroPad(new_index,2));
|
32
|
+
});
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
function reorder_template_part(element, direction){
|
37
|
+
var parts = $('parts');
|
38
|
+
var template_part = $(element).up('.template_part');
|
39
|
+
switch(direction){
|
40
|
+
case 'up':
|
41
|
+
if(template_part.previous())
|
42
|
+
template_part.previous().insert({ before: template_part });
|
43
|
+
break;
|
44
|
+
case 'down':
|
45
|
+
if(template_part.next())
|
46
|
+
template_part.next().insert({ after: template_part });
|
47
|
+
break;
|
48
|
+
case 'top':
|
49
|
+
parts.insert({ top: template_part });
|
50
|
+
break;
|
51
|
+
case 'bottom':
|
52
|
+
parts.insert({ bottom: template_part });
|
53
|
+
break;
|
54
|
+
default:
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
fix_template_part_indexes();
|
58
|
+
}
|
59
|
+
JS
|
60
|
+
end
|
61
|
+
|
62
|
+
def filter_options
|
63
|
+
[['none', '']] + TextFilter.descendants.map { |f| f.filter_name }.sort
|
64
|
+
end
|
65
|
+
|
66
|
+
def part_type_options
|
67
|
+
PartType.find(:all, :order => "name ASC").map {|t| [t.name, t.id]}
|
68
|
+
end
|
69
|
+
|
70
|
+
def blank_template_part
|
71
|
+
ostruct = OpenStruct.new(:index => '#{index}')
|
72
|
+
@blank_template_part ||= (render :partial => "template_part", :object => ostruct).to_json
|
73
|
+
end
|
74
|
+
|
75
|
+
def order_links(template)
|
76
|
+
returning String.new do |output|
|
77
|
+
%w{move_to_top move_higher move_lower move_to_bottom}.each do |action|
|
78
|
+
output << link_to(image("#{action}.png", :alt => action.humanize),
|
79
|
+
url_for(:action => action, :id => template),
|
80
|
+
:method => :post)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def updated_stamp(model)
|
86
|
+
unless model.new_record?
|
87
|
+
updated_by = (model.updated_by || model.created_by) if model.respond_to?(:updated_by)
|
88
|
+
login = updated_by ? updated_by.login : nil
|
89
|
+
time = (model.updated_at || model.created_at)
|
90
|
+
# promoted_at = model.draft_promoted_at if model.respond_to?(:draft_promoted_at)
|
91
|
+
html = %{<p style="clear: left"><small>}
|
92
|
+
if login or time
|
93
|
+
html << 'Last updated '
|
94
|
+
html << %{by #{login} } if login
|
95
|
+
html << %{at #{ timestamp(time) }} if time
|
96
|
+
html << '. '
|
97
|
+
end
|
98
|
+
# if promoted_at
|
99
|
+
# html << %{Last promoted at #{ timestamp(promoted_at) }.}
|
100
|
+
# end
|
101
|
+
html << %{</small></p>}
|
102
|
+
html
|
103
|
+
else
|
104
|
+
%{<p class="clear"> </p>}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|