refinerycms 0.9.8 → 0.9.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -6
- data/app/controllers/application_controller.rb +2 -1
- data/bin/refinerycms +36 -32
- data/changelog.md +471 -0
- data/config/environments/production.rb +1 -1
- data/db/migrate/20100606135207_change_thumbnail_sizes_for_dragonfly.rb +4 -4
- data/db/migrate/20100826232810_move_inquiry_settings_to_refinery_settings.rb +2 -2
- data/db/migrate/20100831122919_move_page_to_nested_set.rb +28 -0
- data/db/schema.rb +7 -1
- data/db/seeds/refinery_settings.rb +2 -4
- data/license.md +21 -0
- data/readme.md +97 -0
- data/todo.md +61 -0
- data/vendor/refinerycms/authentication/app/views/admin/users/index.html.erb +5 -13
- data/vendor/refinerycms/authentication/app/views/layouts/login.html.erb +1 -1
- data/vendor/refinerycms/authentication/config/locales/de.yml +53 -56
- data/vendor/refinerycms/authentication/config/locales/en.yml +1 -2
- data/vendor/refinerycms/authentication/config/locales/lv.yml +38 -38
- data/vendor/refinerycms/authentication/config/locales/pt-BR.yml +21 -48
- data/vendor/refinerycms/authentication/features/lost_password.feature +40 -0
- data/vendor/refinerycms/authentication/features/manage_users.feature +57 -0
- data/vendor/refinerycms/authentication/features/step_definitions/lost_password.rb +8 -0
- data/vendor/refinerycms/authentication/features/step_definitions/user_steps.rb +32 -0
- data/vendor/refinerycms/authentication/features/support/factories.rb +17 -0
- data/vendor/refinerycms/authentication/features/support/paths.rb +24 -0
- data/vendor/refinerycms/authentication/lib/authenticated_system.rb +1 -1
- data/vendor/refinerycms/authentication/lib/authentication.rb +1 -1
- data/vendor/refinerycms/core/app/views/admin/_head.html.erb +4 -4
- data/vendor/refinerycms/core/app/views/admin/_menu_tab.html.erb +2 -2
- data/vendor/refinerycms/core/app/views/layouts/admin.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/layouts/admin_dialog.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_footer.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_google_analytics.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_header.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_menu.html.erb +5 -2
- data/vendor/refinerycms/core/app/views/shared/_menu_branch.html.erb +6 -3
- data/vendor/refinerycms/core/app/views/shared/_site_bar.html.erb +11 -15
- data/vendor/refinerycms/core/app/views/shared/admin/_form_actions.html.erb +1 -0
- data/vendor/refinerycms/core/app/views/shared/admin/_image_picker.html.erb +3 -3
- data/vendor/refinerycms/core/app/views/shared/admin/_make_sortable.html.erb +2 -1
- data/vendor/refinerycms/core/app/views/shared/admin/_resource_picker.html.erb +24 -17
- data/vendor/refinerycms/core/app/views/wymiframe.html.erb +1 -1
- data/vendor/refinerycms/core/config/locales/de.yml +50 -51
- data/vendor/refinerycms/core/config/locales/en.yml +5 -2
- data/vendor/refinerycms/core/config/locales/lv.yml +6 -3
- data/vendor/refinerycms/core/config/locales/pt-BR.yml +34 -38
- data/vendor/refinerycms/core/crud.md +12 -12
- data/vendor/refinerycms/core/features/engine_generator.feature +27 -0
- data/vendor/refinerycms/core/features/search.feature +56 -0
- data/vendor/refinerycms/core/features/site_bar.feature +24 -0
- data/vendor/refinerycms/core/features/step_definitions/core_steps.rb +61 -0
- data/vendor/refinerycms/core/features/step_definitions/engine_generator_steps.rb +19 -0
- data/vendor/refinerycms/core/features/step_definitions/generator_steps.rb +11 -0
- data/vendor/refinerycms/core/features/support/paths.rb +14 -0
- data/vendor/refinerycms/core/features/uploads/beach.jpeg +0 -0
- data/vendor/refinerycms/core/features/uploads/refinery_is_awesome.txt +1 -0
- data/vendor/refinerycms/core/lib/core.rb +52 -53
- data/vendor/refinerycms/core/lib/generators/refinery_engine/refinery_engine_generator.rb +14 -3
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/controllers/admin/plural_name_controller.rb +3 -1
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/models/singular_name.rb +4 -3
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/admin/plural_name/_form.html.erb +2 -1
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/admin/plural_name/_singular_name.html.erb +6 -2
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/plural_name/index.html.erb +3 -1
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/plural_name/show.html.erb +7 -3
- data/vendor/refinerycms/core/lib/refinery/application_controller.rb +85 -75
- data/vendor/refinerycms/core/lib/refinery/application_helper.rb +10 -190
- data/vendor/refinerycms/core/lib/refinery/crud.rb +283 -0
- data/vendor/refinerycms/core/lib/refinery/{form_helpers.rb → helpers/form_helper.rb} +0 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/html_truncation_helper.rb +26 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/image_helper.rb +37 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/menu_helper.rb +38 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/meta_helper.rb +67 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/script_helper.rb +36 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/site_bar_helper.rb +26 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/tag_helper.rb +19 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/translation_helper.rb +17 -0
- data/vendor/refinerycms/core/lib/refinery/plugin.rb +3 -3
- data/vendor/refinerycms/core/lib/tasks/refinery.rake +4 -3
- data/vendor/refinerycms/core/public/javascripts/refinery/admin.js +93 -101
- data/vendor/refinerycms/core/public/javascripts/refinery/core.js +3 -0
- data/vendor/refinerycms/core/public/javascripts/refinery/nestedsortables.js +164 -0
- data/vendor/refinerycms/core/public/javascripts/refinery/serializelist.js +66 -0
- data/vendor/refinerycms/core/public/stylesheets/refinery/refinery.css +11 -73
- data/vendor/refinerycms/dashboard/config/locales/de.yml +6 -6
- data/vendor/refinerycms/dashboard/config/locales/pt-BR.yml +3 -5
- data/vendor/refinerycms/dashboard/features/dashboard.feature +54 -0
- data/vendor/refinerycms/dashboard/features/support/paths.rb +14 -0
- data/vendor/refinerycms/images/app/controllers/admin/images_controller.rb +6 -6
- data/vendor/refinerycms/images/app/helpers/admin/images_helper.rb +1 -1
- data/vendor/refinerycms/images/app/views/admin/images/_existing_image.html.erb +15 -13
- data/vendor/refinerycms/images/app/views/admin/images/_grid_view.html.erb +1 -1
- data/vendor/refinerycms/images/app/views/admin/images/_list_view_image.html.erb +1 -1
- data/vendor/refinerycms/images/config/locales/de.yml +21 -25
- data/vendor/refinerycms/images/config/locales/pt-BR.yml +13 -23
- data/vendor/refinerycms/images/features/manage_images.feature +48 -0
- data/vendor/refinerycms/images/features/step_definitions/image_steps.rb +37 -0
- data/vendor/refinerycms/images/features/support/paths.rb +17 -0
- data/vendor/refinerycms/images/features/uploads/beach.jpeg +0 -0
- data/vendor/refinerycms/images/features/uploads/id-rather-be-here.jpg +0 -0
- data/vendor/refinerycms/images/features/uploads/refinery_is_awesome.txt +1 -0
- data/vendor/refinerycms/images/lib/images.rb +6 -0
- data/vendor/refinerycms/images/readme.md +12 -36
- data/vendor/refinerycms/pages/app/controllers/admin/pages_controller.rb +4 -42
- data/vendor/refinerycms/pages/app/controllers/pages_controller.rb +1 -1
- data/vendor/refinerycms/pages/app/models/page.rb +3 -4
- data/vendor/refinerycms/pages/app/sweepers/page_sweeper.rb +18 -0
- data/vendor/refinerycms/pages/app/views/admin/pages/_form_advanced_options.html.erb +1 -1
- data/vendor/refinerycms/pages/app/views/admin/pages/_page.html.erb +6 -5
- data/vendor/refinerycms/pages/config/locales/de.yml +66 -36
- data/vendor/refinerycms/pages/config/locales/pt-BR.yml +29 -57
- data/vendor/refinerycms/pages/features/manage_pages.feature +45 -0
- data/vendor/refinerycms/pages/features/step_definitions/page_steps.rb +29 -0
- data/vendor/refinerycms/pages/features/support/paths.rb +18 -0
- data/vendor/refinerycms/pages/lib/pages.rb +5 -0
- data/vendor/refinerycms/pages/spec/models/page_spec.rb +13 -0
- data/vendor/refinerycms/refinery.rb +1 -1
- data/vendor/refinerycms/resources/app/views/admin/resources/_existing_resource.html.erb +2 -2
- data/vendor/refinerycms/resources/config/locales/de.yml +16 -17
- data/vendor/refinerycms/resources/config/locales/pt-BR.yml +15 -17
- data/vendor/refinerycms/resources/features/manage_files.feature +39 -0
- data/vendor/refinerycms/resources/features/step_definitions/file_steps.rb +21 -0
- data/vendor/refinerycms/resources/features/support/paths.rb +17 -0
- data/vendor/refinerycms/resources/features/uploads/beach.jpeg +0 -0
- data/vendor/refinerycms/resources/features/uploads/refinery_is_awesome.txt +1 -0
- data/vendor/refinerycms/resources/lib/resources.rb +17 -1
- data/vendor/refinerycms/settings/app/models/refinery_setting.rb +82 -64
- data/vendor/refinerycms/settings/config/locales/de.yml +36 -16
- data/vendor/refinerycms/settings/config/locales/pt-BR.yml +32 -34
- data/vendor/refinerycms/settings/features/manage_refinery_settings.feature +5 -0
- data/vendor/refinerycms/settings/lib/settings.rb +1 -1
- metadata +86 -53
- data/vendor/refinerycms/core/lib/crud.rb +0 -265
- data/vendor/refinerycms/core/lib/refinery/html_truncation_helper.rb +0 -22
- data/vendor/refinerycms/core/public/javascripts/jquery/jquery.nestedsortables.js +0 -186
@@ -1,5 +1,7 @@
|
|
1
1
|
class Admin::<%= class_name.pluralize %>Controller < Admin::BaseController
|
2
2
|
|
3
|
-
crudify :<%= singular_name
|
3
|
+
crudify :<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? and title.name != 'title' %>
|
4
|
+
, :title_attribute => '<%= title.name %>'
|
5
|
+
<% end %>
|
4
6
|
|
5
7
|
end
|
data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/models/singular_name.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
class <%= class_name %> < ActiveRecord::Base
|
2
2
|
|
3
3
|
acts_as_indexed :fields => [:<%= attributes.collect{ |attribute| attribute.name if attribute.type.to_s =~ /string|text/ }.compact.uniq.join(", :") %>]
|
4
|
-
|
5
|
-
validates_presence_of :<%=
|
6
|
-
validates_uniqueness_of :<%=
|
4
|
+
<% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
|
5
|
+
validates_presence_of :<%= title.name %>
|
6
|
+
validates_uniqueness_of :<%= title.name %>
|
7
|
+
<% end -%>
|
7
8
|
|
8
9
|
<% attributes.collect{|a| a if a.type.to_s == 'image'}.compact.uniq.each do |a| -%>
|
9
10
|
belongs_to :<%= a.name.gsub("_id", "") %><%= ", :class_name => 'Image'" unless a.name =~ /^image(_id)?$/ %>
|
@@ -30,6 +30,7 @@
|
|
30
30
|
:locals => {
|
31
31
|
:f => f,
|
32
32
|
:continue_editing => false,
|
33
|
-
:delete_title => t('admin.<%= plural_name %>.<%= singular_name %>.delete')
|
33
|
+
:delete_title => t('admin.<%= plural_name %>.<%= singular_name %>.delete'),
|
34
|
+
:delete_confirmation => t('shared.admin.delete.message'<% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>, :title => @<%= singular_name %>.<%= title.name %><% end %>)
|
34
35
|
} %>
|
35
36
|
<%% end -%>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<li class='clearfix record <%%= cycle("on", "on-hover") %>' id="<%%= dom_id(<%= singular_name %>) -%>">
|
2
2
|
<span class='title'>
|
3
|
-
<%%= <%= singular_name
|
3
|
+
<%%= <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? -%>.<%= title.name %><% end %> %>
|
4
4
|
<span class="preview"> </span>
|
5
5
|
</span>
|
6
6
|
<span class='actions'>
|
@@ -11,6 +11,10 @@
|
|
11
11
|
:title => t('.edit') %>
|
12
12
|
<%%= link_to refinery_icon_tag("delete.png"), admin_<%= singular_name %>_path(<%= singular_name %>),
|
13
13
|
:class => "cancel confirm-delete",
|
14
|
-
:title => t('.delete')
|
14
|
+
:title => t('.delete'),
|
15
|
+
:'data-confirm' => t('shared.admin.delete.message'<% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>,
|
16
|
+
:title => <%= singular_name %>.<%= title.name %>
|
17
|
+
<% end %>),
|
18
|
+
:'data-method' => :delete %>
|
15
19
|
</span>
|
16
20
|
</li>
|
@@ -2,7 +2,9 @@
|
|
2
2
|
<ul id="<%= plural_name %>">
|
3
3
|
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
|
4
4
|
<li>
|
5
|
-
<%%= link_to <%= singular_name
|
5
|
+
<%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
|
6
|
+
.<%= title.name %>
|
7
|
+
<% end %>, <%= singular_name %>_url(<%= singular_name %>) %>
|
6
8
|
</li>
|
7
9
|
<%% end %>
|
8
10
|
</ul>
|
@@ -1,5 +1,7 @@
|
|
1
1
|
<%% content_for :body_content_title do %>
|
2
|
-
<%%= @<%= singular_name
|
2
|
+
<%%= @<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
|
3
|
+
.<%= title.name %>
|
4
|
+
<% end %> %>
|
3
5
|
<%% end %>
|
4
6
|
|
5
7
|
<%% content_for :body_content_left do %>
|
@@ -11,7 +13,7 @@
|
|
11
13
|
<% elsif attribute.type.to_s == 'resource' -%>
|
12
14
|
<%%= link_to <%= "'#{attribute.name}'" %>, @<%= singular_name %>.<%= attribute.name %>.url %>
|
13
15
|
<% else -%>
|
14
|
-
<%%= @<%= singular_name %>.<%= attribute.name %> %>
|
16
|
+
<%%=raw @<%= singular_name %>.<%= attribute.name %> %>
|
15
17
|
<% end -%>
|
16
18
|
</div>
|
17
19
|
<% end %>
|
@@ -22,7 +24,9 @@
|
|
22
24
|
<ul id="<%= plural_name %>">
|
23
25
|
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
|
24
26
|
<li>
|
25
|
-
<%%= link_to <%= singular_name
|
27
|
+
<%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
|
28
|
+
.<%= title.name %>
|
29
|
+
<% end %>, <%= singular_name %>_url(<%= singular_name %>) %>
|
26
30
|
</li>
|
27
31
|
<%% end %>
|
28
32
|
</ul>
|
@@ -1,101 +1,111 @@
|
|
1
1
|
require 'action_controller'
|
2
2
|
|
3
|
-
|
3
|
+
module Refinery::ApplicationController
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:admin?,
|
10
|
-
:login?
|
5
|
+
def self.included(controller)
|
6
|
+
controller.send :include, InstanceMethods
|
7
|
+
controller.send :include, ClassMethods
|
8
|
+
end
|
11
9
|
|
12
|
-
|
10
|
+
module ClassMethods
|
11
|
+
def self.included(c) # Extend controller
|
12
|
+
c.helper_method :home_page?,
|
13
|
+
:local_request?,
|
14
|
+
:just_installed?,
|
15
|
+
:from_dialog?,
|
16
|
+
:admin?,
|
17
|
+
:login?
|
13
18
|
|
14
|
-
|
15
|
-
include AuthenticatedSystem
|
19
|
+
c.protect_from_forgery # See ActionController::RequestForgeryProtection
|
16
20
|
|
17
|
-
|
18
|
-
|
21
|
+
c.send :include, Crud # basic create, read, update and delete methods
|
22
|
+
c.send :include, AuthenticatedSystem
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
c.send :before_filter, :find_pages_for_menu,
|
25
|
+
:show_welcome_page?
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
ActionView::MissingTemplate,
|
26
|
-
:with => :error_404
|
27
|
+
c.send :after_filter, :store_current_location!,
|
28
|
+
:if => Proc.new {|c| c.send(:refinery_user?) rescue false }
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
c.send :rescue_from, ActiveRecord::RecordNotFound,
|
31
|
+
ActionController::UnknownAction,
|
32
|
+
ActionView::MissingTemplate,
|
33
|
+
:with => :error_404
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
render :template => "/pages/show",
|
36
|
-
:format => 'html',
|
37
|
-
:status => 404
|
38
|
-
else
|
39
|
-
# fallback to the default 404.html page.
|
40
|
-
file = Rails.root.join('public', '404.html')
|
41
|
-
file = Refinery.root.join('vendor', 'refinerycms', 'core', 'public', '404.html') unless file.exist?
|
42
|
-
render :file => file.cleanpath.to_s,
|
43
|
-
:layout => false,
|
44
|
-
:status => 404
|
37
|
+
module InstanceMethods
|
38
|
+
def admin?
|
39
|
+
controller_name =~ %r{^admin/}
|
45
40
|
end
|
46
|
-
end
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
def error_404(exception=nil)
|
43
|
+
if (@page = Page.where(:menu_match => "^/404$").includes(:parts, :slugs).first).present?
|
44
|
+
# render the application's custom 404 page with layout and meta.
|
45
|
+
render :template => "/pages/show",
|
46
|
+
:format => 'html',
|
47
|
+
:status => 404
|
48
|
+
else
|
49
|
+
# fallback to the default 404.html page.
|
50
|
+
file = Rails.root.join('public', '404.html')
|
51
|
+
file = Refinery.root.join('vendor', 'refinerycms', 'core', 'public', '404.html') unless file.exist?
|
52
|
+
render :file => file.cleanpath.to_s,
|
53
|
+
:layout => false,
|
54
|
+
:status => 404
|
55
|
+
end
|
56
|
+
end
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
def from_dialog?
|
59
|
+
params[:dialog] == "true" or params[:modal] == "true"
|
60
|
+
end
|
55
61
|
|
56
|
-
|
57
|
-
|
58
|
-
|
62
|
+
def home_page?
|
63
|
+
root_url(:only_path => true) == request.path
|
64
|
+
end
|
59
65
|
|
60
|
-
|
61
|
-
|
62
|
-
|
66
|
+
def just_installed?
|
67
|
+
Role[:refinery].users.empty?
|
68
|
+
end
|
63
69
|
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
def local_request?
|
71
|
+
Rails.env.development? or request.remote_ip =~ /(::1)|(127.0.0.1)|((192.168).*)/
|
72
|
+
end
|
67
73
|
|
68
|
-
|
74
|
+
def login?
|
75
|
+
(controller_name =~ /^(user|session)(|s)/ and not admin?) or just_installed?
|
76
|
+
end
|
69
77
|
|
70
|
-
|
71
|
-
def find_pages_for_menu
|
72
|
-
@menu_pages = Page.top_level
|
73
|
-
end
|
78
|
+
protected
|
74
79
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
+
# get all the pages to be displayed in the site menu.
|
81
|
+
def find_pages_for_menu
|
82
|
+
@menu_pages = Page.top_level
|
83
|
+
end
|
80
84
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
85
|
+
# use a different model for the meta information.
|
86
|
+
def present(model)
|
87
|
+
presenter = (Object.const_get("#{model.class}Presenter") rescue ::Refinery::BasePresenter)
|
88
|
+
@meta = presenter.new(model)
|
89
|
+
end
|
86
90
|
|
87
|
-
|
88
|
-
render
|
89
|
-
|
91
|
+
# this hooks into the Rails render method.
|
92
|
+
def render(action = nil, options = {}, &blk)
|
93
|
+
present(@page) unless admin? or @meta.present?
|
94
|
+
super
|
95
|
+
end
|
90
96
|
|
91
|
-
|
92
|
-
|
93
|
-
if admin?
|
94
|
-
# ensure that we don't redirect to AJAX or POST/PUT/DELETE urls
|
95
|
-
session[:refinery_return_to] = request.path if request.get? and !request.xhr? and !from_dialog?
|
96
|
-
elsif defined?(@page) and @page.present?
|
97
|
-
session[:website_return_to] = @page.url
|
97
|
+
def show_welcome_page?
|
98
|
+
render :template => "/welcome", :layout => "login" if just_installed? and controller_name != "users"
|
98
99
|
end
|
99
|
-
end
|
100
100
|
|
101
|
+
private
|
102
|
+
def store_current_location!
|
103
|
+
if admin?
|
104
|
+
# ensure that we don't redirect to AJAX or POST/PUT/DELETE urls
|
105
|
+
session[:refinery_return_to] = request.path if request.get? and !request.xhr? and !from_dialog?
|
106
|
+
elsif defined?(@page) and @page.present?
|
107
|
+
session[:website_return_to] = @page.url
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
101
111
|
end
|
@@ -1,195 +1,15 @@
|
|
1
1
|
# Methods added to this helper will be available to all templates in the application.
|
2
|
+
Dir[File.expand_path('../helpers/*.rb', __FILE__).to_s].each {|helper| require helper}
|
3
|
+
|
2
4
|
module Refinery
|
3
5
|
module ApplicationHelper
|
4
|
-
include Refinery::HtmlTruncationHelper
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
# This is used to display the title of the current object (normally a page) in the browser's titlebar.
|
15
|
-
#
|
16
|
-
def browser_title(yield_title=nil)
|
17
|
-
[
|
18
|
-
yield_title.present? ? yield_title : nil,
|
19
|
-
@meta.browser_title.present? ? @meta.browser_title : @meta.path,
|
20
|
-
RefinerySetting.find_or_set(:site_name, "Company Name")
|
21
|
-
].compact.join(" - ")
|
22
|
-
end
|
23
|
-
|
24
|
-
# replace all system images with a thumbnail version of them (handy for all images inside a page part)
|
25
|
-
# for example, <%= content_fu(@page[:body], :preview) %> converts all /system/images to their 'preview' thumbnail
|
26
|
-
def content_fu(content, thumbnail)
|
27
|
-
raise NotImplementedError # todo: implement for new syntax.
|
28
|
-
|
29
|
-
content.scan(/\/system\/images([^\"\ ]*)/).flatten.each do |match|
|
30
|
-
parts = match.split(".")
|
31
|
-
extension = parts.pop
|
32
|
-
content.gsub!(match, "#{parts.join(".")}_#{thumbnail}.#{extension}")
|
33
|
-
end unless content.blank?
|
34
|
-
|
35
|
-
return content
|
36
|
-
end
|
37
|
-
|
38
|
-
# This was extracted from REFINERY_ROOT/vendor/plugins/refinery/app/views/shared/_menu_branch.html.erb
|
39
|
-
# to remove the complexity of that template by reducing logic in the view.
|
40
|
-
def css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count = nil)
|
41
|
-
css = []
|
42
|
-
css << "selected" if selected_page?(menu_branch) or descendant_page_selected?(menu_branch)
|
43
|
-
css << "first" if menu_branch_counter == 0
|
44
|
-
css << "last" if menu_branch_counter == (sibling_count ||= menu_branch.shown_siblings.size)
|
45
|
-
css
|
46
|
-
end
|
47
|
-
|
48
|
-
# Determines whether any page underneath the supplied page is the current page according to rails.
|
49
|
-
# Just calls selected_page? for each descendant of the supplied page.
|
50
|
-
def descendant_page_selected?(page)
|
51
|
-
page.descendants.any? {|descendant| selected_page?(descendant) }
|
52
|
-
end
|
53
|
-
|
54
|
-
# image_fu is a helper for inserting an image that has been uploaded into a template.
|
55
|
-
# Say for example that we had a @model.image (@model having a belongs_to :image relationship)
|
56
|
-
# and we wanted to display a thumbnail cropped to 200x200 then we can use image_fu like this:
|
57
|
-
# <%= image_fu @model.image, '200x200' %> or with no thumbnail: <%= image_fu @model.image %>
|
58
|
-
def image_fu(image, geometry = nil, options={})
|
59
|
-
if image.present?
|
60
|
-
# call rails' image tag function with default alt, width and height options.
|
61
|
-
# if any other options were supplied these are merged in and can replace the defaults.
|
62
|
-
image_tag((thumbnail = image.thumbnail(geometry)).url, {
|
63
|
-
:alt => image.respond_to?(:title) ? image.title : image.image_name,
|
64
|
-
:width => thumbnail.width,
|
65
|
-
:height => thumbnail.height
|
66
|
-
}.merge(options))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# This function helps when including both the jquery and jqueryui libraries.
|
71
|
-
# If you use this function then whenever we update or relocate the version of jquery or jquery ui in use
|
72
|
-
# we will update the reference here and your existing application starts to use it.
|
73
|
-
# Use <%= jquery_include_tags %> to include it in your <head> section.
|
74
|
-
def jquery_include_tags(options={})
|
75
|
-
# Merge in options
|
76
|
-
options = {
|
77
|
-
:caching => RefinerySetting.find_or_set(:use_resource_caching, Rails.root.writable?),
|
78
|
-
:google => RefinerySetting.find_or_set(:use_google_ajax_libraries, false),
|
79
|
-
:jquery_ui => true
|
80
|
-
}.merge(options)
|
81
|
-
|
82
|
-
# render the tags normally unless
|
83
|
-
unless options[:google] and !local_request?
|
84
|
-
if options[:jquery_ui]
|
85
|
-
javascript_include_tag "jquery#{"-min" if Rails.env.production?}", "jquery-ui-custom-min",
|
86
|
-
:cache => (options[:caching] ? "cache/jquery" : nil)
|
87
|
-
else
|
88
|
-
javascript_include_tag "jquery#{"-min" if Rails.env.production?}"
|
89
|
-
end
|
90
|
-
else
|
91
|
-
"#{javascript_include_tag("http://www.google.com/jsapi").gsub(".js", "")}
|
92
|
-
<script type='text/javascript'>
|
93
|
-
google.load('jquery', '1.4');
|
94
|
-
#{"google.load('jqueryui', '1.8');" if options[:jquery_ui]}
|
95
|
-
</script>".html_safe
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# you can override the object used for the title by supplying options[:object]
|
100
|
-
# this object must support custom_title_type if you want custom titles.
|
101
|
-
def page_title(options = {})
|
102
|
-
object = options.fetch(:object, @meta)
|
103
|
-
options.delete(:object)
|
104
|
-
options = RefinerySetting.find_or_set(:page_title, {
|
105
|
-
:chain_page_title => false,
|
106
|
-
:ancestors => {
|
107
|
-
:separator => " | ",
|
108
|
-
:class => 'ancestors',
|
109
|
-
:tag => 'span'
|
110
|
-
},
|
111
|
-
:page_title => {
|
112
|
-
:class => nil,
|
113
|
-
:tag => nil,
|
114
|
-
:wrap_if_not_chained => false
|
115
|
-
}
|
116
|
-
}).merge(options)
|
117
|
-
|
118
|
-
title = []
|
119
|
-
objects = (options[:chain_page_title] and object.respond_to?(:ancestors)) ? [object.ancestors, object] : [object]
|
120
|
-
|
121
|
-
objects.flatten.compact.each do |obj|
|
122
|
-
if obj.respond_to?(:custom_title_type)
|
123
|
-
title << case obj.custom_title_type
|
124
|
-
when "text"
|
125
|
-
obj.custom_title
|
126
|
-
when "image"
|
127
|
-
image_fu(obj.custom_title_image, nil, {:alt => obj.title}) rescue obj.title
|
128
|
-
else
|
129
|
-
obj.title
|
130
|
-
end
|
131
|
-
else
|
132
|
-
title << obj.title
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
final_title = title.pop
|
137
|
-
if (options[:page_title][:wrap_if_not_chained] and title.empty?) and options[:page_title][:tag].present?
|
138
|
-
css = options[:page_title][:class].present? ? " class='#{options[:page_title][:class]}'" : nil
|
139
|
-
final_title = "<#{options[:page_title][:tag]}#{css}>#{final_title}</#{options[:page_title][:tag]}>"
|
140
|
-
end
|
141
|
-
|
142
|
-
if title.empty?
|
143
|
-
return final_title.to_s.html_safe
|
144
|
-
else
|
145
|
-
return "<#{options[:ancestors][:tag]} class='#{options[:ancestors][:class]}'>#{title.join options[:ancestors][:separator]}#{options[:ancestors][:separator]}</#{options[:ancestors][:tag]}>#{final_title}".html_safe
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# Returns <span class='help' title='Your Input'>(help)</span>
|
150
|
-
# Remember to wrap your block with <span class='label_with_help'></span> if you're using a label next to the help tag.
|
151
|
-
def refinery_help_tag(title='')
|
152
|
-
"<span class='help' title='#{title}'>(#{t('shared.admin.help')})</span>".html_safe
|
153
|
-
end
|
154
|
-
|
155
|
-
# This is just a quick wrapper to render an image tag that lives inside refinery/icons.
|
156
|
-
# They are all 16x16 so this is the default but is able to be overriden with supplied options.
|
157
|
-
def refinery_icon_tag(filename, options = {})
|
158
|
-
image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge(options)
|
159
|
-
end
|
160
|
-
|
161
|
-
# Determine whether the supplied page is the currently open page according to Rails.
|
162
|
-
def selected_page?(page)
|
163
|
-
# ensure we match the path without the locale.
|
164
|
-
path = request.path
|
165
|
-
if defined?(::Refinery::I18n) and ::Refinery::I18n.enabled?
|
166
|
-
path = path.split("/#{::I18n.locale}").last
|
167
|
-
end
|
168
|
-
|
169
|
-
current_page?(page) or
|
170
|
-
(path =~ Regexp.new(page.menu_match) if page.menu_match.present?) or
|
171
|
-
(path == page.link_url) or
|
172
|
-
(path == page.nested_path)
|
173
|
-
end
|
174
|
-
|
175
|
-
# Generates the link to determine where the site bar switch button returns to.
|
176
|
-
def site_bar_switch_link
|
177
|
-
link_to_if(admin?, t('.switch_to_your_website'),
|
178
|
-
(if session.keys.include?(:website_return_to) and session[:website_return_to].present?
|
179
|
-
session[:website_return_to]
|
180
|
-
else
|
181
|
-
root_url(:only_path => true)
|
182
|
-
end)) do
|
183
|
-
link_to t('.switch_to_your_website_editor'),
|
184
|
-
(if session.keys.include?(:refinery_return_to) and session[:refinery_return_to].present?
|
185
|
-
session[:refinery_return_to]
|
186
|
-
elsif defined?(@page) and @page.present? and !@page.home?
|
187
|
-
edit_admin_page_url(@page, :only_path => true)
|
188
|
-
else
|
189
|
-
(request.fullpath.to_s == '/') ? admin_root_url(:only_path => true) : "/admin#{request.request_uri}/edit"
|
190
|
-
end rescue admin_root_url(:only_path => true))
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
6
|
+
include Refinery::Helpers::HtmlTruncationHelper
|
7
|
+
include Refinery::Helpers::ImageHelper
|
8
|
+
include Refinery::Helpers::MenuHelper
|
9
|
+
include Refinery::Helpers::MetaHelper
|
10
|
+
include Refinery::Helpers::ScriptHelper
|
11
|
+
include Refinery::Helpers::SiteBarHelper
|
12
|
+
include Refinery::Helpers::TagHelper
|
13
|
+
include Refinery::Helpers::TranslationHelper
|
194
14
|
end
|
195
15
|
end
|