refinerycms 0.9.5.30 → 0.9.5.31
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +15 -5
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/refinery +9 -9
- data/bin/refinery-update-core +8 -5
- data/config/environment.rb +1 -1
- data/config/routes.rb +1 -0
- data/contributors.md +18 -0
- data/db/migrate/20100127004649_add_reset_code_to_users.rb +9 -0
- data/db/schema.rb +2 -1
- data/db/seeds.rb +11 -1
- data/{LICENSE → license.md} +3 -3
- data/public/javascripts/admin.js +5 -0
- data/public/javascripts/refinery/boot_wym.js +1 -1
- data/public/stylesheets/refinery/refinery.css +7 -0
- data/readme.md +161 -0
- data/themes/demolicious.zip +0 -0
- data/themes/hemingway.zip +0 -0
- data/vendor/plugins/authentication/app/controllers/admin/users_controller.rb +0 -27
- data/vendor/plugins/authentication/app/controllers/sessions_controller.rb +3 -0
- data/vendor/plugins/authentication/app/controllers/users_controller.rb +36 -21
- data/vendor/plugins/authentication/app/models/user.rb +40 -41
- data/vendor/plugins/authentication/app/models/user_mailer.rb +5 -12
- data/vendor/plugins/authentication/app/views/sessions/new.html.erb +3 -0
- data/vendor/plugins/authentication/app/views/user_mailer/reset_notification.html.erb +6 -0
- data/vendor/plugins/authentication/app/views/users/forgot.html.erb +13 -0
- data/vendor/plugins/authentication/app/views/users/reset.html.erb +18 -0
- data/vendor/plugins/authentication/authentication.md +7 -0
- data/vendor/plugins/authentication/config/routes.rb +6 -1
- data/vendor/plugins/dashboard/dashboard.md +22 -0
- data/vendor/plugins/images/images.md +46 -0
- data/vendor/plugins/inquiries/app/controllers/inquiries_controller.rb +0 -8
- data/vendor/plugins/inquiries/app/views/admin/inquiries/show.html.erb +3 -3
- data/vendor/plugins/inquiries/inquiries.md +31 -0
- data/vendor/plugins/news/app/controllers/news_items_controller.rb +9 -19
- data/vendor/plugins/news/app/views/news_items/index.html.erb +1 -1
- data/vendor/plugins/news/app/views/news_items/show.html.erb +13 -18
- data/vendor/plugins/news/news.md +20 -0
- data/vendor/plugins/pages/app/controllers/pages_controller.rb +2 -12
- data/vendor/plugins/pages/app/models/page.rb +5 -5
- data/vendor/plugins/pages/app/presenters/page_presenter.rb +3 -0
- data/vendor/plugins/pages/pages.md +141 -0
- data/vendor/plugins/pages/rails/init.rb +1 -1
- data/vendor/plugins/refinery/app/views/admin/_head.html.erb +1 -0
- data/vendor/plugins/refinery/app/views/layouts/application.html.erb +2 -15
- data/vendor/plugins/refinery/app/views/shared/_head.html.erb +13 -0
- data/vendor/plugins/refinery/app/views/shared/_header.html.erb +1 -1
- data/vendor/plugins/refinery/app/views/shared/_menu.html.erb +4 -15
- data/vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb +20 -25
- data/vendor/plugins/refinery/app/views/shared/_submenu.html.erb +5 -4
- data/vendor/plugins/refinery/crud.md +197 -0
- data/vendor/plugins/refinery/lib/generators/refinery/templates/public_controller.rb +6 -1
- data/vendor/plugins/refinery/lib/refinery/application_controller.rb +18 -5
- data/vendor/plugins/refinery/lib/refinery/application_helper.rb +31 -28
- data/vendor/plugins/refinery/lib/refinery/base_presenter.rb +27 -0
- data/vendor/plugins/refinery/lib/refinery/initializer.rb +7 -3
- data/vendor/plugins/refinery/lib/tasks/doc.rake +4 -4
- data/vendor/plugins/refinery/plugins.md +194 -0
- data/vendor/plugins/refinery/rails/init.rb +5 -0
- data/vendor/plugins/refinery_settings/settings.md +5 -0
- data/vendor/plugins/resources/resources.md +9 -0
- data/vendor/plugins/themes/app/controllers/themes_controller.rb +12 -15
- data/vendor/plugins/themes/app/models/theme.rb +8 -14
- data/vendor/plugins/themes/config/routes.rb +3 -3
- data/vendor/plugins/themes/themes.md +133 -0
- metadata +29 -38
- data/CONTRIBUTORS +0 -11
- data/README.rdoc +0 -78
- data/themes/demolicious/LICENSE +0 -21
- data/themes/demolicious/README +0 -1
- data/themes/demolicious/images/footer_background.png +0 -0
- data/themes/demolicious/images/header_background.png +0 -0
- data/themes/demolicious/preview.png +0 -0
- data/themes/demolicious/stylesheets/application.css +0 -94
- data/themes/demolicious/stylesheets/formatting.css +0 -36
- data/themes/demolicious/stylesheets/home.css +0 -11
- data/themes/demolicious/stylesheets/ie6.css +0 -0
- data/themes/demolicious/stylesheets/ie7.css +0 -0
- data/themes/demolicious/views/layouts/application.html.erb +0 -33
- data/themes/demolicious/views/pages/home.html.erb +0 -1
- data/themes/demolicious/views/pages/show.html.erb +0 -1
- data/themes/hemingway/LICENSE +0 -7
- data/themes/hemingway/README +0 -3
- data/themes/hemingway/images/archives.gif +0 -0
- data/themes/hemingway/images/footer_black.gif +0 -0
- data/themes/hemingway/images/kyle-header.jpg +0 -0
- data/themes/hemingway/images/readon_black.gif +0 -0
- data/themes/hemingway/images/search.gif +0 -0
- data/themes/hemingway/images/spinner.gif +0 -0
- data/themes/hemingway/images/trackback_pingback.gif +0 -0
- data/themes/hemingway/preview.png +0 -0
- data/themes/hemingway/stylesheets/application.css +0 -713
- data/themes/hemingway/views/layouts/application.html.erb +0 -64
- data/themes/hemingway/views/shared/content_page.html.erb +0 -0
- data/vendor/plugins/authentication/app/models/user_observer.rb +0 -11
- data/vendor/plugins/authentication/app/views/user_mailer/activation.html.erb +0 -3
- data/vendor/plugins/authentication/app/views/user_mailer/signup_notification.html.erb +0 -8
- data/vendor/plugins/themes/themes.rdoc +0 -131
@@ -1,4 +1,5 @@
|
|
1
|
-
<% children = @page.root.children
|
2
|
-
<ul id='submenu'
|
3
|
-
|
4
|
-
</ul>
|
1
|
+
<% unless (children = @page.root.children).empty? -%>
|
2
|
+
<ul id='submenu'>
|
3
|
+
<%= render :partial => "/shared/submenu_branch", :collection => children %>
|
4
|
+
</ul>
|
5
|
+
<% end -%>
|
@@ -0,0 +1,197 @@
|
|
1
|
+
# The Magical Mixin: Crudify (create, read, update & delete)
|
2
|
+
|
3
|
+
## Introduction
|
4
|
+
|
5
|
+
__Most controllers Refinery and other apps do four common things, create, read, update and delete stuff.__ Instead of writing the same logic for these actions over and over again we wrap all this functionality up into what we called ``crudify``.
|
6
|
+
|
7
|
+
``crudify`` takes these four basic actions and extends them to allow easy paging, searching and sorting too.
|
8
|
+
|
9
|
+
Although this single file is included in Refinery, you could take just this single file and use it in any app you like.
|
10
|
+
|
11
|
+
The best part about ``crudify`` is that this gives you a smart default and if there is anything you want to work differently just override that method.
|
12
|
+
|
13
|
+
## Where is it located?
|
14
|
+
|
15
|
+
``vendor/plugins/refinery/lib/crud.rb``
|
16
|
+
|
17
|
+
## How do I use it in my plugins?
|
18
|
+
|
19
|
+
All you need to do is call ``crudify`` in your controller.
|
20
|
+
|
21
|
+
If you used the Refinery generator you're plugin will already be using ``crudify``.
|
22
|
+
|
23
|
+
### Example
|
24
|
+
|
25
|
+
class NewsItemsController < ApplicationController
|
26
|
+
|
27
|
+
crudify :news_item, :order => "created_at DESC"
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
### Complex Example
|
32
|
+
|
33
|
+
class NewsItemsController < ApplicationController
|
34
|
+
|
35
|
+
crudify :news_item, :order => "created_at DESC"
|
36
|
+
:conditions => 'published = true',
|
37
|
+
:sortable => false,
|
38
|
+
:searchable => true,
|
39
|
+
:include => [:author],
|
40
|
+
:paging => true,
|
41
|
+
:search_conditions => ''
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
## What can you configure with ``crudify``?
|
46
|
+
|
47
|
+
### ``:title_attribute``
|
48
|
+
|
49
|
+
Default value is ``title``
|
50
|
+
|
51
|
+
This is the human readable value you want ``crudify`` to use throughout. Just choose an attribute that is on your model that is short and descriptive to what the model is.
|
52
|
+
|
53
|
+
#### Example
|
54
|
+
|
55
|
+
On a page model you'd probably use "title" (which is default so you don't need to specify this)
|
56
|
+
|
57
|
+
#### Example 2
|
58
|
+
|
59
|
+
On a ``team_member`` model you'd probably want to use an attribute like ``name``.
|
60
|
+
|
61
|
+
### ``:order``
|
62
|
+
|
63
|
+
Default value is ``position ASC``
|
64
|
+
|
65
|
+
This is the position that is used when listing out what you're crudifying. If you have ``:sortable`` set to ``true`` you probably want to have your ``:order`` set to ``position ASC`` so it uses the order you have set when sorting.
|
66
|
+
|
67
|
+
If you have a news area, it makes more sense to sort by ``posted_at``. So you might set it like this
|
68
|
+
|
69
|
+
:order => "posted_at DESC"
|
70
|
+
|
71
|
+
### ``:conditions``
|
72
|
+
|
73
|
+
Default value is ``nil``
|
74
|
+
|
75
|
+
This will filter down the list of items you have when you're asking for all records.
|
76
|
+
|
77
|
+
An example here is say you're crudifying a photos table that uses attachment_fu. Attachment_fu creates several photo records, 1 for the main photo and others for it's "children" thumbnails. Those thumbnails have a parent id set.
|
78
|
+
|
79
|
+
So when viewing a list of the images you have you don't want it to show all the thumbnails too, you just want to each see unique image listed so you need to apply some conditions to hide the thumbnails.
|
80
|
+
|
81
|
+
You do that like this:
|
82
|
+
|
83
|
+
:conditions => "parent_id IS NULL"
|
84
|
+
|
85
|
+
### ``:sortable``
|
86
|
+
|
87
|
+
Default value is ``true``
|
88
|
+
|
89
|
+
Enabling ``:sortable`` gives you several handy methods which "just work" with sortable JavaScript lists. One of the methods is ``update_positions()`` which handles saving the new position items have been sorted into.
|
90
|
+
|
91
|
+
### ``:searchable``
|
92
|
+
|
93
|
+
Default value is ``true``
|
94
|
+
|
95
|
+
When this option is ``true``, the routes are modified so when you go to the next page of results the search continues on.
|
96
|
+
|
97
|
+
### ``:include``
|
98
|
+
|
99
|
+
Default value is ``[]``
|
100
|
+
|
101
|
+
For performance optimisation, sometimes you might want to eager load other related models to this one. For example a ``news_post`` might below to a ``user`` who wrote the post. But in our index view we're printing out the name of each user.
|
102
|
+
|
103
|
+
Instead of having to look up each user for each of the ``news_posts`` we iterate over, the ``:include`` option allows you to load the ``news_post`` and user all at the same time which'll allow you to save on expensive database queries.
|
104
|
+
|
105
|
+
Here's an example of that.
|
106
|
+
|
107
|
+
class NewsItem
|
108
|
+
|
109
|
+
belongs_to :user
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
class NewsItemsController < ApplicationController
|
114
|
+
|
115
|
+
crudify :news_item, :order => "created_at DESC", :include => [:user]
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
### ``:paging``
|
120
|
+
|
121
|
+
Default value is ``true``
|
122
|
+
|
123
|
+
The ``:paging`` option tells ``crudify`` you don't just want one big long list but rather to break it out into pages and support paging methods uses [will_paginate](http://wiki.github.com/mislav/will_paginate/).
|
124
|
+
|
125
|
+
### ``:search_conditions``
|
126
|
+
|
127
|
+
Default value is ``nil``
|
128
|
+
|
129
|
+
Similar to the ``:conditions`` options, ``:search_conditions`` just apply these conditions when delivering search results.
|
130
|
+
|
131
|
+
## Easy Accessor Methods
|
132
|
+
|
133
|
+
``crudify`` automatically writes up finder methods for the model you're crudifying. The easier way to explain this is with an example.
|
134
|
+
|
135
|
+
Say we have a pages controller that is going to manage pages.
|
136
|
+
|
137
|
+
class PagesController < ApplicationController
|
138
|
+
|
139
|
+
crudify :page
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
In this controller, automatically I have these methods:
|
144
|
+
|
145
|
+
find_page()
|
146
|
+
find_all_pages()
|
147
|
+
|
148
|
+
So say I wanted to change the way all pages are found, all I do is override the ``find_all_pages`` method.
|
149
|
+
|
150
|
+
class PagesController < ApplicationController
|
151
|
+
|
152
|
+
crudify :page
|
153
|
+
|
154
|
+
def find_all_pages
|
155
|
+
@pages = Page.find(...) # apply any logic I want here to get all pages.
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
## Overriding or Extending Crudify
|
161
|
+
|
162
|
+
Before overriding anything, the best thing to do is check out how the default works. Read the ``vendor/plugins/refinery/lib/crud.rb`` and see what code it's injecting into your controller.
|
163
|
+
|
164
|
+
Pick the method you want to override and then override it in your controller.
|
165
|
+
|
166
|
+
Let's go back to the example above with the pages controller.
|
167
|
+
|
168
|
+
class PagesController < ApplicationController
|
169
|
+
|
170
|
+
crudify :page
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
Say every time someone deletes a page I want my ``NotificationMailer`` to email me to say someone just deleted a page.
|
175
|
+
|
176
|
+
When I look in the ``crud.rb`` file I see that my controller has this added to it
|
177
|
+
|
178
|
+
def destroy
|
179
|
+
flash[:notice] = "'\#{@#{singular_name}.#{options[:title_attribute]}}' was successfully deleted." if @#{singular_name}.destroy
|
180
|
+
redirect_to admin_#{plural_name}_url
|
181
|
+
end
|
182
|
+
|
183
|
+
To override this all I would is create my own delete method that works the same but just with my mailer code on it.
|
184
|
+
|
185
|
+
class PagesController < ApplicationController
|
186
|
+
|
187
|
+
crudify :page
|
188
|
+
|
189
|
+
def destroy
|
190
|
+
if @page.destroy
|
191
|
+
flash[:notice] = "'#{@page.title}' was successfully deleted."
|
192
|
+
NotificationMailer.deliver_page_deleted(@page) # sends me an email to say a page was deleted
|
193
|
+
end
|
194
|
+
redirect_to admin_pages_url
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
@@ -4,11 +4,16 @@ class <%= class_name.pluralize %>Controller < ApplicationController
|
|
4
4
|
|
5
5
|
def index
|
6
6
|
@<%= plural_name %> = <%= class_name %>.find(:all, :order => "position ASC")
|
7
|
+
present(@page)
|
7
8
|
end
|
8
9
|
|
9
10
|
def show
|
10
11
|
@<%= plural_name %> = <%= class_name %>.find(:all, :order => "position ASC") # for body_content_right
|
11
12
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
13
|
+
|
14
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
15
|
+
# by swapping @page for @<%= singular_name %> in the line below:
|
16
|
+
present(@page)
|
12
17
|
end
|
13
18
|
|
14
19
|
protected
|
@@ -17,4 +22,4 @@ protected
|
|
17
22
|
@page = Page.find_by_link_url("/<%= plural_name %>")
|
18
23
|
end
|
19
24
|
|
20
|
-
end
|
25
|
+
end
|
@@ -7,7 +7,8 @@ class Refinery::ApplicationController < ActionController::Base
|
|
7
7
|
include Crud # basic create, read, update and delete methods
|
8
8
|
include AuthenticatedSystem
|
9
9
|
|
10
|
-
before_filter :
|
10
|
+
before_filter :take_down_for_maintenance?, :setup_theme, :find_pages_for_menu, :show_welcome_page
|
11
|
+
|
11
12
|
rescue_from ActiveRecord::RecordNotFound, :with => :error_404
|
12
13
|
rescue_from ActionController::UnknownAction, :with => :error_404
|
13
14
|
|
@@ -43,13 +44,12 @@ class Refinery::ApplicationController < ActionController::Base
|
|
43
44
|
protected
|
44
45
|
|
45
46
|
def setup_theme
|
46
|
-
self.view_paths = ::ActionController::Base.view_paths.dup.unshift(
|
47
|
+
self.view_paths = ::ActionController::Base.view_paths.dup.unshift(File.join(%W(#{RAILS_ROOT} themes #{RefinerySetting[:theme]} views)))
|
47
48
|
end
|
48
49
|
|
49
50
|
def take_down_for_maintenance?
|
50
51
|
if RefinerySetting.find_or_set(:down_for_maintenance, false)
|
51
|
-
@page = Page.find_by_menu_match("^/maintenance$", :include => [:parts, :slugs])
|
52
|
-
unless @page.nil?
|
52
|
+
if (@page = Page.find_by_menu_match("^/maintenance$", :include => [:parts, :slugs])).present?
|
53
53
|
render :template => "/pages/show", :status => 503
|
54
54
|
else
|
55
55
|
render :text => "Our website is currently down for maintenance. Please try back soon."
|
@@ -61,8 +61,21 @@ protected
|
|
61
61
|
render :template => "/welcome", :layout => "admin" if just_installed? and params[:controller] != "users"
|
62
62
|
end
|
63
63
|
|
64
|
+
# get all the pages to be displayed in the site menu.
|
64
65
|
def find_pages_for_menu
|
65
66
|
@menu_pages = Page.top_level(include_children=true)
|
66
67
|
end
|
67
68
|
|
68
|
-
|
69
|
+
# use a different model for the meta information.
|
70
|
+
def present(model)
|
71
|
+
presenter = Object.const_get("#{model.class}Presenter") rescue Refinery::BasePresenter
|
72
|
+
@meta = presenter.new(model)
|
73
|
+
end
|
74
|
+
|
75
|
+
# this hooks into the Rails render method.
|
76
|
+
def render(action = nil, options = {}, &blk)
|
77
|
+
present(@page) unless admin? or @meta.present?
|
78
|
+
super
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -1,27 +1,25 @@
|
|
1
1
|
# Methods added to this helper will be available to all templates in the application.
|
2
2
|
module Refinery::ApplicationHelper
|
3
|
-
include Refinery::HtmlTruncationHelper
|
4
3
|
|
5
|
-
|
6
|
-
content_for :head, "<meta name=\"keywords\" content=\"#{@page.meta_keywords}\" />" unless @page.meta_keywords.blank?
|
7
|
-
content_for :head, "<meta name=\"description\" content=\"#{@page.meta_description}\" />" unless @page.meta_description.blank?
|
8
|
-
end
|
4
|
+
include Refinery::HtmlTruncationHelper
|
9
5
|
|
10
|
-
def
|
11
|
-
|
12
|
-
if @page.browser_title.blank?
|
13
|
-
@page.path
|
14
|
-
else
|
15
|
-
@page.browser_title
|
16
|
-
end
|
6
|
+
def setup
|
7
|
+
logger.warn("*** Refinery::ApplicationHelper::setup has now been deprecated from the Refinery API. ***")
|
17
8
|
end
|
18
9
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
10
|
+
def browser_title(yield_title=nil)
|
11
|
+
[
|
12
|
+
yield_title.present? ? yield_title : nil,
|
13
|
+
@meta.browser_title.present? ? @meta.browser_title : @meta.path,
|
14
|
+
RefinerySetting.find_or_set(:site_name, "Company Name")
|
15
|
+
].compact.join(" - ")
|
22
16
|
end
|
23
17
|
|
18
|
+
# you can override the object used for the title by supplying options[:object]
|
19
|
+
# this object must support custom_title_type if you want custom titles.
|
24
20
|
def page_title(options = {})
|
21
|
+
object = options.fetch(:object, @page)
|
22
|
+
options.delete(:object)
|
25
23
|
options = RefinerySetting.find_or_set(:page_title, {
|
26
24
|
:chain_page_title => false,
|
27
25
|
:ancestors => {
|
@@ -37,32 +35,37 @@ module Refinery::ApplicationHelper
|
|
37
35
|
}).merge(options)
|
38
36
|
|
39
37
|
title = []
|
40
|
-
|
38
|
+
objects = (options[:chain_page_title] and object.respond_to?(:ancestors)) ? [object.ancestors, object] : [object]
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
objects.flatten.each do |obj|
|
41
|
+
if obj.respond_to?(:custom_title_type)
|
42
|
+
title << case obj.custom_title_type
|
43
|
+
when "text"
|
44
|
+
obj.custom_title
|
45
|
+
when "image"
|
46
|
+
image_fu obj.custom_title_image, nil, {:alt => obj.title} rescue obj.title
|
47
|
+
else
|
48
|
+
obj.title
|
49
|
+
end
|
50
|
+
else
|
51
|
+
title << obj.title
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
55
|
final_title = title.pop
|
54
56
|
if (options[:page_title][:wrap_if_not_chained] and title.empty?) and !options[:page_title][:tag].blank?
|
55
|
-
|
57
|
+
css = options[:page_title][:class].present? ? " class='#{options[:page_title][:class]}'" : nil
|
58
|
+
final_title = "<#{options[:page_title][:tag]}#{css}>#{final_title}</#{options[:page_title][:tag]}>"
|
56
59
|
end
|
57
60
|
if (title.empty?)
|
58
|
-
final_title
|
61
|
+
return final_title
|
59
62
|
else
|
60
|
-
"<#{options[:ancestors][:tag]} class='#{options[:ancestors][:class]}'>#{title.join options[:ancestors][:separator]}#{options[:ancestors][:separator]}</#{options[:ancestors][:tag]}>#{final_title}"
|
63
|
+
return "<#{options[:ancestors][:tag]} class='#{options[:ancestors][:class]}'>#{title.join options[:ancestors][:separator]}#{options[:ancestors][:separator]}</#{options[:ancestors][:tag]}>#{final_title}"
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
67
|
def descendant_page_selected?(page)
|
65
|
-
|
68
|
+
page.descendants.any? {|descendant| selected_page?(descendant) }
|
66
69
|
end
|
67
70
|
|
68
71
|
def selected_page?(page)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Refinery::BasePresenter
|
2
|
+
|
3
|
+
DEFAULT_FIELDS = {
|
4
|
+
:title => Proc.new { |p| p.model.class.name.titleize },
|
5
|
+
:path => Proc.new { |p| p.title },
|
6
|
+
:browser_title => nil,
|
7
|
+
:meta_description => nil,
|
8
|
+
:meta_keywords => nil
|
9
|
+
}
|
10
|
+
|
11
|
+
attr_reader :model
|
12
|
+
|
13
|
+
def initialize(obj)
|
14
|
+
@model = obj
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(method, *args)
|
18
|
+
if @model.respond_to? method
|
19
|
+
@model.send method
|
20
|
+
elsif DEFAULT_FIELDS.has_key? method
|
21
|
+
(value = DEFAULT_FIELDS[method]).is_a?(Proc) ? value.call(self) : value
|
22
|
+
else
|
23
|
+
raise NoMethodError.new("#{self.class.name} doesn't know #{method}. Define or delegate it.", method)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -5,19 +5,21 @@ rescue LoadError => load_error
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module Refinery
|
8
|
+
|
8
9
|
if defined? Rails::Configuration
|
9
10
|
class Configuration < Rails::Configuration
|
10
11
|
def default_plugin_paths
|
11
|
-
paths = super.push(
|
12
|
+
paths = super.push(File.join(%W(#{REFINERY_ROOT} vendor plugins))).uniq
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
16
|
+
|
15
17
|
if defined? Rails::Plugin::Loader
|
16
18
|
class PluginLoader < Rails::Plugin::Loader
|
17
19
|
def add_plugin_load_paths
|
18
20
|
super
|
19
21
|
# add plugin lib paths to the $LOAD_PATH so that rake tasks etc. can be run when using a gem for refinery or gems for plugins.
|
20
|
-
search_for = Regexp.new(File.join(
|
22
|
+
search_for = Regexp.new(File.join(%W(\( #{REFINERY_ROOT} vendor plugins \)? .+? lib)))
|
21
23
|
paths = plugins.collect{ |plugin| plugin.load_paths }.flatten.reject{|path| path.scan(search_for).empty? or path.include?('/rails-') }
|
22
24
|
paths = paths.reject{ |path| path.include?(REFINERY_ROOT) } if REFINERY_ROOT == RAILS_ROOT # superfluous when not in gem.
|
23
25
|
($refinery_gem_plugin_lib_paths = paths).each do |path|
|
@@ -27,6 +29,7 @@ module Refinery
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
32
|
+
|
30
33
|
if defined? Rails::Initializer
|
31
34
|
class Initializer < Rails::Initializer
|
32
35
|
def self.run(command = :process, configuration = Configuration.new)
|
@@ -42,4 +45,5 @@ module Refinery
|
|
42
45
|
end
|
43
46
|
end
|
44
47
|
end
|
45
|
-
|
48
|
+
|
49
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
namespace :doc do
|
2
|
-
|
2
|
+
|
3
3
|
task :app => [:refinery]
|
4
|
-
|
4
|
+
|
5
5
|
desc "Generate documentation for the application"
|
6
6
|
Rake::RDocTask.new(:refinery) { |rdoc|
|
7
7
|
rdoc.title = "Refinery CMS Documentation"
|
8
|
-
rdoc.main = "
|
8
|
+
rdoc.main = "readme.md"
|
9
9
|
rdoc.options = ['--inline-source']
|
10
10
|
rdoc.rdoc_files.include('lib/**/*.rb',
|
11
11
|
'lib/*',
|
@@ -23,7 +23,7 @@ namespace :doc do
|
|
23
23
|
'vendor/plugins/refinery_settings/**/*.rb',
|
24
24
|
'vendor/plugins/resources/**/*.rb',
|
25
25
|
'vendor/plugins/themes/**/*.rb',
|
26
|
-
'
|
26
|
+
'readme.md', 'license.md', 'contributors.md', 'vendor/plugins/themes/themes.md')
|
27
27
|
}
|
28
28
|
|
29
29
|
end
|