hobo 1.3.0.RC4 → 1.3.0.pre10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +234 -282
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/app/controllers/dev_controller.rb +2 -2
- data/bin/hobo +3 -3
- data/config/routes.rb +1 -1
- data/doctests/hobo/lifecycles.rdoctest +1 -0
- data/doctests/hobo/model.rdoctest +5 -0
- data/doctests/hobo/multi_model_forms.rdoctest +5 -4
- data/doctests/hobo/scopes.rdoctest +8 -11
- data/doctests/prepare_testapp.rb +1 -2
- data/hobo.gemspec +2 -2
- data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +11 -5
- data/lib/generators/hobo/admin_subsite/templates/admin.css +2 -20
- data/lib/generators/hobo/admin_subsite/templates/admin_tag_injection.erb +1 -3
- data/lib/generators/hobo/admin_subsite/templates/controller.rb.erb +5 -5
- data/lib/generators/hobo/admin_subsite/templates/users_index.dryml +1 -3
- data/lib/generators/hobo/basic/basic_generator.rb +17 -0
- data/lib/generators/hobo/{assets → basic}/templates/application.css +0 -0
- data/lib/generators/hobo/{assets → basic}/templates/application.dryml.erb +1 -1
- data/lib/generators/hobo/{assets → basic}/templates/dryml-support.js +2 -2
- data/lib/generators/hobo/{assets → basic}/templates/en_injection.yml +0 -0
- data/lib/generators/hobo/{assets → basic}/templates/guest.rb +0 -0
- data/lib/generators/hobo/controller.rb +1 -6
- data/lib/generators/hobo/front_controller/front_controller_generator.rb +3 -2
- data/{app/views/dev → lib/generators/hobo/front_controller/templates}/summary.dryml +10 -7
- data/lib/generators/hobo/hints/hints_generator.rb +12 -0
- data/lib/generators/hobo/hints/templates/hints.rb.erb +5 -0
- data/lib/generators/hobo/hints/templates/model_injection.rb.erb +36 -0
- data/lib/generators/hobo/i18n/i18n_generator.rb +9 -1
- data/lib/generators/hobo/i18n/templates/app.en.yml +1 -1
- data/lib/generators/hobo/i18n/templates/app.es-DO.yml +24 -0
- data/lib/generators/hobo/i18n/templates/app.it.yml +1 -5
- data/lib/generators/hobo/i18n/templates/app.pt-PT.yml +0 -1
- data/lib/generators/hobo/i18n/templates/default_count_injection.rb +10 -0
- data/lib/generators/hobo/i18n/templates/hobo.en.yml +10 -26
- data/lib/generators/hobo/i18n/templates/{hobo.es.yml → hobo.es-DO.yml} +10 -27
- data/lib/generators/hobo/i18n/templates/hobo.it.yml +4 -20
- data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +9 -25
- data/lib/generators/hobo/model.rb +13 -0
- data/lib/generators/hobo/model/USAGE +3 -2
- data/lib/generators/hobo/model/model_generator.rb +1 -2
- data/lib/generators/hobo/rapid/rapid_generator.rb +0 -2
- data/lib/generators/hobo/rapid/templates/hobo-rapid.js +93 -78
- data/lib/generators/hobo/rapid/templates/ie7-recalc.js +21 -21
- data/lib/generators/hobo/rapid/templates/lowpro.js +31 -31
- data/lib/generators/hobo/rapid/templates/reset.css +1 -1
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/clean.css +16 -17
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +3 -3
- data/lib/generators/hobo/rapid/templates/themes/clean/views/clean.dryml +1 -1
- data/lib/generators/hobo/resource/resource_generator.rb +1 -1
- data/lib/generators/hobo/routes/router.rb +4 -4
- data/lib/generators/hobo/routes/routes_generator.rb +1 -12
- data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +1 -1
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +43 -88
- data/lib/generators/hobo/subsite.rb +5 -18
- data/lib/generators/hobo/subsite/subsite_generator.rb +1 -1
- data/lib/generators/hobo/subsite/templates/controller.rb.erb +1 -1
- data/lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb +2 -2
- data/lib/generators/hobo/test_framework/test_framework_generator.rb +7 -7
- data/lib/generators/hobo/user_controller/templates/controller.rb.erb +3 -8
- data/lib/generators/hobo/user_mailer/templates/activation.erb +2 -2
- data/lib/generators/hobo/user_mailer/templates/forgot_password.erb +2 -2
- data/lib/generators/hobo/user_mailer/templates/invite.erb +2 -2
- data/lib/generators/hobo/user_mailer/templates/mailer.rb.erb +17 -10
- data/lib/generators/hobo/user_mailer/user_mailer_generator.rb +1 -1
- data/lib/generators/hobo/user_model/USAGE +9 -2
- data/lib/generators/hobo/user_model/user_model_generator.rb +1 -2
- data/lib/hobo.rb +7 -13
- data/lib/hobo/controller.rb +14 -21
- data/lib/hobo/controller/authentication_support.rb +23 -1
- data/lib/hobo/controller/model.rb +53 -48
- data/lib/hobo/controller/{user_base.rb → user.rb} +36 -47
- data/lib/hobo/engine.rb +11 -25
- data/lib/hobo/extensions/action_controller/hobo_methods.rb +1 -25
- data/lib/hobo/extensions/active_model/translation.rb +1 -1
- data/lib/hobo/extensions/active_record/{associations/collection.rb → association_collection.rb} +3 -12
- data/lib/hobo/extensions/active_record/{associations/proxy.rb → association_proxy.rb} +7 -6
- data/lib/hobo/extensions/active_record/association_reflection.rb +19 -0
- data/lib/hobo/extensions/active_record/hobo_methods.rb +1 -1
- data/lib/hobo/extensions/active_record/scopes.rb +31 -0
- data/lib/hobo/extensions/array.rb +1 -13
- data/lib/hobo/helper.rb +6 -27
- data/lib/hobo/helper/translations.rb +90 -39
- data/lib/hobo/model.rb +20 -72
- data/lib/hobo/model/lifecycles.rb +11 -12
- data/lib/hobo/model/lifecycles/lifecycle.rb +4 -12
- data/lib/hobo/model/lifecycles/transition.rb +0 -1
- data/lib/hobo/model/permissions.rb +3 -2
- data/lib/hobo/model/scopes/apply_scopes.rb +1 -1
- data/lib/hobo/model/scopes/automatic_scopes.rb +80 -78
- data/lib/hobo/model/{user_base.rb → user.rb} +7 -9
- data/lib/hobo/rapid/generators/rapid/cards.dryml.erb +2 -2
- data/lib/hobo/rapid/generators/rapid/forms.dryml.erb +4 -5
- data/lib/hobo/rapid/generators/rapid/pages.dryml.erb +27 -26
- data/lib/hobo/rapid/helper.rb +5 -10
- data/lib/hobo/rapid/taglibs/rapid.dryml +1 -1
- data/lib/hobo/rapid/taglibs/rapid_core.dryml +42 -72
- data/lib/hobo/rapid/taglibs/rapid_document_tags.dryml +2 -2
- data/lib/hobo/rapid/taglibs/rapid_editing.dryml +16 -36
- data/lib/hobo/rapid/taglibs/rapid_forms.dryml +49 -87
- data/lib/hobo/rapid/taglibs/rapid_generics.dryml +2 -2
- data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +75 -50
- data/lib/hobo/rapid/taglibs/rapid_lifecycles.dryml +5 -7
- data/lib/hobo/rapid/taglibs/rapid_navigation.dryml +2 -2
- data/lib/hobo/rapid/taglibs/rapid_pages.dryml +7 -8
- data/lib/hobo/rapid/taglibs/rapid_plus.dryml +43 -66
- data/lib/hobo/rapid/taglibs/rapid_summary.dryml +45 -16
- data/lib/hobo/rapid/taglibs/rapid_translations.dryml +36 -0
- data/lib/hobo/rapid/taglibs/rapid_user_pages.dryml +8 -8
- data/lib/hobo/routes.rb +23 -22
- data/lib/hobo/view_hints.rb +101 -0
- data/test/irt/generators/admin_subsite.irt +1 -1
- data/test/irt/generators/{assets.irt → basic.irt} +2 -2
- data/test/irt/generators/front_controller.irt +4 -2
- data/test/irt/generators/partials/_subsite_taglib_variables.rb +1 -1
- data/test/irt/generators/subsite.irt +1 -1
- data/test/permissions/test_permissions.rb +103 -103
- metadata +108 -69
- data/lib/generators/hobo/admin_subsite/USAGE +0 -25
- data/lib/generators/hobo/admin_subsite/templates/application.dryml +0 -1
- data/lib/generators/hobo/assets/USAGE +0 -5
- data/lib/generators/hobo/assets/assets_generator.rb +0 -18
- data/lib/generators/hobo/assets/templates/dryml_taglibs_initializer.rb +0 -1
- data/lib/generators/hobo/controller/USAGE +0 -3
- data/lib/generators/hobo/i18n/USAGE +0 -3
- data/lib/generators/hobo/i18n/templates/app.de.yml +0 -30
- data/lib/generators/hobo/i18n/templates/app.es.yml +0 -31
- data/lib/generators/hobo/i18n/templates/app.fr.yml +0 -26
- data/lib/generators/hobo/i18n/templates/app.nb.yml +0 -25
- data/lib/generators/hobo/i18n/templates/app.ru.yml +0 -24
- data/lib/generators/hobo/i18n/templates/hobo.de.yml +0 -204
- data/lib/generators/hobo/i18n/templates/hobo.fr.yml +0 -195
- data/lib/generators/hobo/i18n/templates/hobo.nb.yml +0 -198
- data/lib/generators/hobo/i18n/templates/hobo.ru.yml +0 -200
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-ACD3E6-DBE1E5-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-DBE1E5-FCFEF5-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/300-3B5F87-ACD3E6-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/spinner.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/stylesheets/clean-sidemenu.css +0 -81
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +0 -30
- data/lib/generators/hobo/resource/USAGE +0 -39
- data/lib/generators/hobo/subsite/USAGE +0 -24
- data/lib/generators/hobo/subsite_taglib/USAGE +0 -4
- data/lib/generators/hobo/test_framework/USAGE +0 -2
- data/lib/generators/hobo/user_controller/USAGE +0 -3
- data/lib/generators/hobo/user_mailer/USAGE +0 -2
- data/lib/generators/hobo/user_resource/USAGE +0 -10
- data/lib/hobo/extensions/action_view/translation_helper.rb +0 -25
- data/lib/hobo/extensions/active_record/associations/reflection.rb +0 -23
- data/lib/hobo/extensions/active_record/associations/scope.rb +0 -35
- data/lib/hobo/extensions/active_record/relation_with_origin.rb +0 -32
- data/lib/hobo/extensions/i18n.rb +0 -17
- data/lib/hobo/helper/translations/normalizer.rb +0 -39
- data/lib/hobo/model/view_hints.rb +0 -123
@@ -4,14 +4,11 @@ class <%= class_name %>Controller < ApplicationController
|
|
4
4
|
|
5
5
|
auto_actions :all, :except => [ :index, :new, :create ]
|
6
6
|
|
7
|
-
# Normally, users should be created via the user lifecycle, except
|
8
|
-
# for the initial user created via the form on the front screen on
|
9
|
-
# first run. This method creates the initial user.
|
10
7
|
def create
|
11
8
|
hobo_create do
|
12
9
|
if valid?
|
13
10
|
self.current_user = this
|
14
|
-
flash[:notice] = t("hobo.messages.you_are_site_admin", :default=>"You are now the site administrator")
|
11
|
+
flash[:notice] = I18n.t("hobo.messages.you_are_site_admin", :default=>"You are now the site administrator")
|
15
12
|
redirect_to home_page
|
16
13
|
end
|
17
14
|
end
|
@@ -20,10 +17,8 @@ class <%= class_name %>Controller < ApplicationController
|
|
20
17
|
|
21
18
|
def do_accept_invitation
|
22
19
|
do_transition_action :accept_invitation do
|
23
|
-
|
24
|
-
|
25
|
-
flash[:notice] = t("hobo.messages.you_signed_up", :default=>"You have signed up")
|
26
|
-
end
|
20
|
+
self.current_user = this
|
21
|
+
flash[:notice] = I18n.t("hobo.messages.you_signed_up", :default=>"You have signed up")
|
27
22
|
end
|
28
23
|
end
|
29
24
|
<% end -%>
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<%%=
|
1
|
+
<%%= @user %>,
|
2
2
|
|
3
3
|
To activate your account for <%%= @app_name %>, click on this link:
|
4
4
|
|
5
|
-
<%%=
|
5
|
+
<%%= user_activate_url :id => @user, :key => @key %>
|
6
6
|
|
7
7
|
Thank you,
|
8
8
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<%%=
|
1
|
+
<%%= @user %>,
|
2
2
|
|
3
3
|
If you have forgotten your password for <%%= @app_name %>, you can choose
|
4
4
|
a new one by clicking on this link:
|
5
5
|
|
6
|
-
<%%= <%= name.underscore -%>_reset_password_url :id =>
|
6
|
+
<%%= <%= name.underscore -%>_reset_password_url :id => @user, :key => @key %>
|
7
7
|
|
8
8
|
Thank you,
|
9
9
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<%%=
|
1
|
+
<%%= @user %>,
|
2
2
|
|
3
3
|
You have been invited to join <%%= @app_name %>. If you wish to accept, please click on the following link
|
4
4
|
|
5
|
-
<%%=
|
5
|
+
<%%= user_accept_invitation_url :id => @user, :key => @key %>
|
6
6
|
|
7
7
|
Thank you,
|
8
8
|
|
@@ -1,25 +1,32 @@
|
|
1
1
|
class <%= class_name -%>Mailer < ActionMailer::Base
|
2
2
|
default :from => "no-reply@#{host}"
|
3
3
|
|
4
|
-
def forgot_password(
|
5
|
-
|
4
|
+
def forgot_password(user, key)
|
5
|
+
set_variables(user, key)
|
6
6
|
mail( :subject => "#{app_name} -- forgotten password",
|
7
|
-
:to =>
|
7
|
+
:to => user.email_address )
|
8
8
|
end
|
9
9
|
|
10
10
|
<% if invite_only? -%>
|
11
|
-
def invite(
|
12
|
-
|
11
|
+
def invite(user, key)
|
12
|
+
set_variables(user, key)
|
13
13
|
mail( :subject => "Invitation to #{app_name}",
|
14
|
-
:to =>
|
14
|
+
:to => user.email_address )
|
15
15
|
end
|
16
16
|
|
17
17
|
<% elsif options[:activation_email] %>
|
18
|
-
def activation(
|
19
|
-
|
20
|
-
mail
|
21
|
-
|
18
|
+
def activation(user, key)
|
19
|
+
set_variables(user, key)
|
20
|
+
mail :subject => "#{app_name} -- activate",
|
21
|
+
:to => user.email_address
|
22
22
|
end
|
23
23
|
|
24
24
|
<% end -%>
|
25
|
+
private
|
26
|
+
|
27
|
+
def set_variables(user, key)
|
28
|
+
@user = user
|
29
|
+
@key = key
|
30
|
+
end
|
31
|
+
|
25
32
|
end
|
@@ -12,7 +12,7 @@ module Hobo
|
|
12
12
|
"rails generate hobo:user_mailer [NAME=user] [options]"
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
check_class_collision :suffix => 'Mailer'
|
16
16
|
|
17
17
|
def generate_mailer
|
18
18
|
template 'mailer.rb.erb', File.join('app/mailers', "#{file_path}_mailer.rb")
|
@@ -1,5 +1,12 @@
|
|
1
1
|
Description:
|
2
|
+
The model generator creates stubs for a new user model.
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
The generator takes a model name as its argument. The
|
5
|
+
model name may be given in CamelCase or under_score and
|
6
|
+
should not be suffixed with 'Model'.
|
5
7
|
|
8
|
+
The generator creates a model class in app/models, invokes
|
9
|
+
the hobo:user_mailer andgenerator the test framework.
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
$ rails generate hobo:user_model User
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'generators/hobo_support/model'
|
2
1
|
module Hobo
|
3
2
|
class UserModelGenerator < Rails::Generators::NamedBase
|
4
3
|
source_root File.expand_path('../templates', __FILE__)
|
@@ -6,7 +5,7 @@ module Hobo
|
|
6
5
|
# overrides the default
|
7
6
|
argument :name, :type => :string, :default => 'user', :optional => true
|
8
7
|
|
9
|
-
include Generators::
|
8
|
+
include Generators::Hobo::Model
|
10
9
|
include Generators::Hobo::InviteOnly
|
11
10
|
include Generators::Hobo::ActivationEmail
|
12
11
|
|
data/lib/hobo.rb
CHANGED
@@ -5,19 +5,18 @@ require 'will_paginate'
|
|
5
5
|
require 'hobo/extensions/enumerable'
|
6
6
|
require 'hobo/extensions/array'
|
7
7
|
|
8
|
-
ActiveSupport::Dependencies.autoload_paths |= [File.dirname(__FILE__)]
|
9
|
-
|
8
|
+
ActiveSupport::Dependencies.autoload_paths |= [ File.dirname(__FILE__)]
|
9
|
+
|
10
10
|
|
11
11
|
module Hobo
|
12
12
|
|
13
13
|
VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
|
14
|
-
@@root = Pathname.new File.expand_path(
|
14
|
+
@@root = Pathname.new File.expand_path(File.dirname(__FILE__) + "/..")
|
15
15
|
def self.root; @@root; end
|
16
16
|
|
17
17
|
class Error < RuntimeError; end
|
18
18
|
class PermissionDeniedError < RuntimeError; end
|
19
19
|
class UndefinedAccessError < RuntimeError; end
|
20
|
-
class I18nError < RuntimeError; end
|
21
20
|
|
22
21
|
# Empty class to represent the boolean type.
|
23
22
|
class Boolean; end
|
@@ -25,7 +24,7 @@ module Hobo
|
|
25
24
|
|
26
25
|
class << self
|
27
26
|
|
28
|
-
attr_accessor :current_theme
|
27
|
+
attr_accessor :current_theme
|
29
28
|
|
30
29
|
def raw_js(s)
|
31
30
|
RawJs.new(s)
|
@@ -64,18 +63,13 @@ module Hobo
|
|
64
63
|
|
65
64
|
def subsites
|
66
65
|
# Any directory inside app/controllers defines a subsite
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
File.basename(f) if File.directory?(f)
|
71
|
-
end.compact
|
72
|
-
end.flatten
|
66
|
+
@subsites ||= Dir["#{Rails.root}/app/controllers/*"].map do |f|
|
67
|
+
File.basename(f) if File.directory?(f)
|
68
|
+
end.compact
|
73
69
|
end
|
74
70
|
|
75
71
|
end
|
76
72
|
|
77
|
-
self.engines = []
|
78
|
-
|
79
73
|
end
|
80
74
|
|
81
75
|
require 'hobo/engine'
|
data/lib/hobo/controller.rb
CHANGED
@@ -27,7 +27,7 @@ module Hobo
|
|
27
27
|
end
|
28
28
|
before_filter :set_mailer_default_url_options
|
29
29
|
@included_taglibs = []
|
30
|
-
rescue_from ActionController::RoutingError, :with => :not_found
|
30
|
+
rescue_from ActionController::RoutingError, :with => :not_found
|
31
31
|
end
|
32
32
|
Hobo::Helper.add_to_controller(klass)
|
33
33
|
end
|
@@ -49,7 +49,7 @@ module Hobo
|
|
49
49
|
|
50
50
|
def redirect_to_with_object_url(destination, *args)
|
51
51
|
if destination.is_one_of?(String, Hash, Symbol)
|
52
|
-
redirect_to_without_object_url(destination
|
52
|
+
redirect_to_without_object_url(destination)
|
53
53
|
else
|
54
54
|
redirect_to_without_object_url(object_url(destination, *args))
|
55
55
|
end
|
@@ -58,9 +58,10 @@ module Hobo
|
|
58
58
|
|
59
59
|
def hobo_ajax_response(*args)
|
60
60
|
results = args.extract_options!
|
61
|
+
page_path = params[:page_path]
|
61
62
|
r = params[:render]
|
62
63
|
if r
|
63
|
-
ajax_update_response(r.values, results)
|
64
|
+
ajax_update_response(page_path, r.values, results)
|
64
65
|
true
|
65
66
|
else
|
66
67
|
false
|
@@ -68,16 +69,12 @@ module Hobo
|
|
68
69
|
end
|
69
70
|
|
70
71
|
|
71
|
-
def ajax_update_response(render_specs, results={}
|
72
|
-
|
73
|
-
|
74
|
-
controller,
|
75
|
-
false,
|
76
|
-
view_context.lookup_context.instance_variable_get('@details')).identifier
|
77
|
-
renderer = Dryml.page_renderer(view_context, identifier, [], controller)
|
72
|
+
def ajax_update_response(page_path, render_specs, results={})
|
73
|
+
@template.send(:_evaluate_assigns_and_ivars)
|
74
|
+
renderer = Dryml.page_renderer(@template, [], page_path) if page_path
|
78
75
|
|
79
76
|
render :update do |page|
|
80
|
-
page <<
|
77
|
+
page << "var _update = typeof Hobo == 'undefined' ? Element.update : Hobo.updateElement;"
|
81
78
|
for spec in render_specs
|
82
79
|
function = spec[:function] || "_update"
|
83
80
|
dom_id = spec[:id]
|
@@ -93,17 +90,10 @@ module Hobo
|
|
93
90
|
end
|
94
91
|
end
|
95
92
|
page << renderer.part_contexts_storage if renderer
|
96
|
-
page << options[:postamble] if options[:postamble]
|
97
93
|
end
|
98
94
|
end
|
99
95
|
|
100
96
|
|
101
|
-
# dryml does not use layouts
|
102
|
-
def action_has_layout?
|
103
|
-
false
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
97
|
def dryml_context
|
108
98
|
@this
|
109
99
|
end
|
@@ -123,7 +113,10 @@ module Hobo
|
|
123
113
|
|
124
114
|
|
125
115
|
def tag_renderer
|
126
|
-
@tag_renderer ||=
|
116
|
+
@tag_renderer ||= begin
|
117
|
+
@template.send(:_evaluate_assigns_and_ivars)
|
118
|
+
Dryml.empty_page_renderer(@template)
|
119
|
+
end
|
127
120
|
end
|
128
121
|
|
129
122
|
|
@@ -135,7 +128,7 @@ module Hobo
|
|
135
128
|
results_hash = Hobo.find_by_search(query)
|
136
129
|
all_results = results_hash.values.flatten.select { |r| r.viewable_by?(current_user) }
|
137
130
|
if all_results.empty?
|
138
|
-
render :text => "<p>"+ t("hobo.live_search.no_results", :default=>["Your search returned no matches."]) + "</p>"
|
131
|
+
render :text => "<p>"+ I18n.t("hobo.live_search.no_results", :default=>["Your search returned no matches."]) + "</p>"
|
139
132
|
else
|
140
133
|
# TODO: call one tag that renders all the search results with headings for each model
|
141
134
|
render_tags(all_results, :search_card, :for_type => true)
|
@@ -160,7 +153,7 @@ module Hobo
|
|
160
153
|
elsif render :not_found, :status => 404
|
161
154
|
# cool
|
162
155
|
else
|
163
|
-
render(:text => t("hobo.messages.not_found", :default=>["The page you requested cannot be found."]) , :status => 404)
|
156
|
+
render(:text => I18n.t("hobo.messages.not_found", :default=>["The page you requested cannot be found."]) , :status => 404)
|
164
157
|
end
|
165
158
|
end
|
166
159
|
|
@@ -38,7 +38,7 @@ module Hobo
|
|
38
38
|
# skip_before_filter :login_required
|
39
39
|
#
|
40
40
|
def login_required(user_model=nil)
|
41
|
-
auth_model = user_model || Hobo::Model::
|
41
|
+
auth_model = user_model || Hobo::Model::User.default_user_model
|
42
42
|
if current_user.guest?
|
43
43
|
username, passwd = get_auth_data
|
44
44
|
self.current_user = auth_model.authenticate(username, passwd) || nil if username && passwd && auth_model
|
@@ -50,6 +50,28 @@ module Hobo
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# Redirect as appropriate when an access request fails.
|
54
|
+
#
|
55
|
+
# The default action is to redirect to the login screen.
|
56
|
+
#
|
57
|
+
# Override this method in your controllers if you want to have special
|
58
|
+
# behavior in case the user is not authorized
|
59
|
+
# to access the requested action. For example, a popup window might
|
60
|
+
# simply close itself.
|
61
|
+
def access_denied(user_model)
|
62
|
+
respond_to do |accepts|
|
63
|
+
accepts.html do
|
64
|
+
store_location
|
65
|
+
redirect_to(login_url(user_model))
|
66
|
+
end
|
67
|
+
accepts.xml do
|
68
|
+
headers["Status"] = "Unauthorized"
|
69
|
+
headers["WWW-Authenticate"] = %(Basic realm="Web Password")
|
70
|
+
render :text => I18n.t("hobo.messages.unauthenticated", :default=>["Couldn't authenticate you"]), :status => '401 Unauthorized'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
false
|
74
|
+
end
|
53
75
|
|
54
76
|
# Store the URI of the current request in the session.
|
55
77
|
#
|
@@ -27,7 +27,7 @@ module Hobo
|
|
27
27
|
helper_method :model, :current_user
|
28
28
|
before_filter :set_no_cache_headers
|
29
29
|
|
30
|
-
rescue_from ActiveRecord::RecordNotFound, :with => :not_found
|
30
|
+
rescue_from ActiveRecord::RecordNotFound, :with => :not_found
|
31
31
|
|
32
32
|
rescue_from Hobo::PermissionDeniedError, :with => :permission_denied
|
33
33
|
rescue_from Hobo::Model::Lifecycles::LifecycleKeyError, :with => :permission_denied
|
@@ -50,21 +50,15 @@ module Hobo
|
|
50
50
|
|
51
51
|
|
52
52
|
def self.all_controllers(subsite=nil, force=false)
|
53
|
-
controller_dirs = ["#{Rails.root}/app/controllers"] + Hobo.engines.map { |e| "#{e}/app/controllers" }
|
54
|
-
|
55
53
|
# Load every controller in app/controllers/<subsite>...
|
56
54
|
@controllers_loaded ||= {}
|
57
55
|
if force || !@controllers_loaded[subsite]
|
58
|
-
|
59
|
-
|
60
|
-
if
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
name = "#{subsite.camelize}::#{name}" if subsite
|
65
|
-
name.constantize
|
66
|
-
end
|
67
|
-
end
|
56
|
+
dir = "#{Rails.root}/app/controllers#{'/' + subsite if subsite}"
|
57
|
+
Dir.entries(dir).each do |f|
|
58
|
+
if f =~ /^[a-zA-Z_][a-zA-Z0-9_]*_controller\.rb$/
|
59
|
+
name = f.remove(/.rb$/).camelize
|
60
|
+
name = "#{subsite.camelize}::#{name}" if subsite
|
61
|
+
name.constantize
|
68
62
|
end
|
69
63
|
end
|
70
64
|
@controllers_loaded[subsite] = true
|
@@ -79,6 +73,7 @@ module Hobo
|
|
79
73
|
end
|
80
74
|
|
81
75
|
|
76
|
+
|
82
77
|
module ClassMethods
|
83
78
|
|
84
79
|
attr_writer :model
|
@@ -129,15 +124,13 @@ module Hobo
|
|
129
124
|
def auto_actions(*args)
|
130
125
|
options = args.extract_options!
|
131
126
|
|
132
|
-
@auto_actions = args.
|
133
|
-
case arg
|
127
|
+
@auto_actions = case args.first
|
134
128
|
when :all then available_auto_actions
|
135
|
-
when :write_only then available_auto_write_actions
|
136
|
-
when :read_only then available_auto_read_actions
|
137
|
-
when :lifecycle then available_auto_lifecycle_actions
|
138
|
-
else
|
139
|
-
|
140
|
-
end.flatten.uniq
|
129
|
+
when :write_only then available_auto_write_actions + args.rest
|
130
|
+
when :read_only then available_auto_read_actions + args.rest
|
131
|
+
when :lifecycle then available_auto_lifecycle_actions + args.rest
|
132
|
+
else args
|
133
|
+
end
|
141
134
|
|
142
135
|
except = Array(options[:except])
|
143
136
|
except_actions = except.map do |arg|
|
@@ -145,9 +138,9 @@ module Hobo
|
|
145
138
|
when :lifecycle then available_auto_lifecycle_actions
|
146
139
|
else arg
|
147
140
|
end
|
148
|
-
end
|
141
|
+
end
|
149
142
|
|
150
|
-
@auto_actions -= except_actions
|
143
|
+
@auto_actions -= except_actions.flatten
|
151
144
|
|
152
145
|
def_auto_actions
|
153
146
|
end
|
@@ -363,15 +356,18 @@ module Hobo
|
|
363
356
|
def re_render_form(default_action=nil)
|
364
357
|
if params[:page_path]
|
365
358
|
@invalid_record = this
|
366
|
-
|
359
|
+
opt = ActionController::Routing::Routes.recognize_path(params[:page_path])
|
360
|
+
controller = opt[:controller]
|
361
|
+
view = opt[:action]
|
362
|
+
view = default_action if view == Dryml::EMPTY_PAGE
|
367
363
|
|
368
364
|
# Hack fix for Bug 477. See also bug 489.
|
369
|
-
if self.class.name == "#{controller.camelize}Controller" &&
|
365
|
+
if self.class.name == "#{controller.camelize}Controller" && view == "index"
|
370
366
|
params['action'] = 'index'
|
371
367
|
self.action_name = 'index'
|
372
368
|
index
|
373
369
|
else
|
374
|
-
render :template => "#{controller}/#{
|
370
|
+
render :template => "#{controller}/#{view}"
|
375
371
|
end
|
376
372
|
else
|
377
373
|
render :action => default_action
|
@@ -404,6 +400,16 @@ module Hobo
|
|
404
400
|
end
|
405
401
|
|
406
402
|
|
403
|
+
def url_for_page_path
|
404
|
+
url_for ActionController::Routing::Routes.recognize_path(params[:page_path])
|
405
|
+
end
|
406
|
+
|
407
|
+
# TODO: Get rid of this joke of an idea that fails miserably if you open another browser window.
|
408
|
+
def previous_page_path
|
409
|
+
session[:previous_page_path]
|
410
|
+
end
|
411
|
+
|
412
|
+
|
407
413
|
def redirect_after_submit(*args)
|
408
414
|
options = args.extract_options!
|
409
415
|
o = options[:redirect]
|
@@ -446,7 +452,7 @@ module Hobo
|
|
446
452
|
do_pagination = options.delete(:paginate) && finder.respond_to?(:paginate)
|
447
453
|
finder = Array.wrap(options.delete(:scope)).inject(finder) { |a, v| a.send(*Array.wrap(v).flatten) }
|
448
454
|
|
449
|
-
options[:order] =
|
455
|
+
options[:order] = :default unless options[:order] || finder.send(:scope, :find)._?[:order]
|
450
456
|
|
451
457
|
if do_pagination
|
452
458
|
options.reverse_merge!(:page => params[:page] || 1)
|
@@ -516,7 +522,7 @@ module Hobo
|
|
516
522
|
this.user_update_attributes(current_user, attributes)
|
517
523
|
else
|
518
524
|
self.this = new_for_create(attributes)
|
519
|
-
this.
|
525
|
+
this.save
|
520
526
|
end
|
521
527
|
create_response(:new, options, &b)
|
522
528
|
end
|
@@ -559,7 +565,7 @@ module Hobo
|
|
559
565
|
|
560
566
|
|
561
567
|
def create_response(new_action, options={}, &b)
|
562
|
-
flash_notice (ht( :"#{@this.class.
|
568
|
+
flash_notice (ht( :"#{@this.class.name.tableize}.messages.create.success", :default=>["The #{@this.class.model_name.human} was created successfully"])) if valid?
|
563
569
|
|
564
570
|
response_block(&b) or
|
565
571
|
if valid?
|
@@ -573,7 +579,7 @@ module Hobo
|
|
573
579
|
errors = this.errors.full_messages.join("\n")
|
574
580
|
wants.html { re_render_form(new_action) }
|
575
581
|
wants.js { render(:status => 500,
|
576
|
-
:text => ht( :"#{this.class.
|
582
|
+
:text => ht( :"#{this.class.name.pluralize.underscore}.messages.create.error", :errors=>errors,:default=>["Couldn't create the #{this.class.name.titleize.downcase}.\n #{errors}"])
|
577
583
|
)}
|
578
584
|
end
|
579
585
|
end
|
@@ -584,12 +590,11 @@ module Hobo
|
|
584
590
|
options = args.extract_options!
|
585
591
|
|
586
592
|
self.this ||= args.first || find_instance
|
587
|
-
changes = options[:attributes] || attribute_parameters or raise RuntimeError, t("hobo.messages.update.no_attribute_error", :default=>["No update specified in params"])
|
593
|
+
changes = options[:attributes] || attribute_parameters or raise RuntimeError, I18n.t("hobo.messages.update.no_attribute_error", :default=>["No update specified in params"])
|
594
|
+
this.user_update_attributes(current_user, changes)
|
588
595
|
|
589
|
-
|
590
|
-
|
591
|
-
@current_user = @this if @this == current_user
|
592
|
-
end
|
596
|
+
# Ensure current_user isn't out of date
|
597
|
+
@current_user = @this if @this == current_user
|
593
598
|
|
594
599
|
in_place_edit_field = changes.keys.first if changes.size == 1 && params[:render]
|
595
600
|
update_response(in_place_edit_field, options, &b)
|
@@ -598,7 +603,7 @@ module Hobo
|
|
598
603
|
|
599
604
|
def update_response(in_place_edit_field=nil, options={}, &b)
|
600
605
|
|
601
|
-
flash_notice (ht(:"#{@this.class.
|
606
|
+
flash_notice (ht(:"#{@this.class.name.pluralize.underscore}.messages.update.success", :default=>["Changes to the #{@this.class.model_name.human} were saved"])) if valid?
|
602
607
|
|
603
608
|
response_block(&b) or
|
604
609
|
if valid?
|
@@ -625,7 +630,7 @@ module Hobo
|
|
625
630
|
errors = @this.errors.full_messages.join("\n")
|
626
631
|
wants.html { re_render_form(:edit) }
|
627
632
|
wants.js { render(:status => 500,
|
628
|
-
:text => ht(:"#{@this.class.
|
633
|
+
:text => ht(:"#{@this.class.name.pluralize.underscore}.messages.update.error",:default=>["There was a problem with that change.\n#{errors}"], :errors=>errors)
|
629
634
|
) }
|
630
635
|
end
|
631
636
|
end
|
@@ -636,7 +641,7 @@ module Hobo
|
|
636
641
|
options = args.extract_options!
|
637
642
|
self.this ||= args.first || find_instance
|
638
643
|
this.user_destroy(current_user)
|
639
|
-
flash_notice ht( :"#{model.
|
644
|
+
flash_notice ht( :"#{model.name.pluralize.underscore}.messages.destroy.success", :default=>["The #{model.name.titleize.downcase} was deleted"])
|
640
645
|
destroy_response(options, &b)
|
641
646
|
end
|
642
647
|
|
@@ -677,7 +682,7 @@ module Hobo
|
|
677
682
|
errors = this.errors.full_messages.join("\n")
|
678
683
|
wants.html { re_render_form(name) }
|
679
684
|
wants.js { render(:status => 500,
|
680
|
-
:text => ht(:"#{@this.class.
|
685
|
+
:text => ht(:"#{@this.class.name.pluralize.underscore}.messages.creator.error", :default=>["Couldn't do creator #{name}.\n#{errors}"], :name=>name, :errors=>errors)
|
681
686
|
)}
|
682
687
|
end
|
683
688
|
end
|
@@ -719,7 +724,7 @@ module Hobo
|
|
719
724
|
errors = this.errors.full_messages.join("\n")
|
720
725
|
wants.html { re_render_form(name) }
|
721
726
|
wants.js { render(:status => 500,
|
722
|
-
:text => ht(:"#{@this.class.
|
727
|
+
:text => ht(:"#{@this.class.name.pluralize.underscore}.messages.transition.error", :default=>["Couldn't do transition #{name}.\n#{errors}"], :name=>name, :errors=>errors)
|
723
728
|
)}
|
724
729
|
end
|
725
730
|
end
|
@@ -730,7 +735,7 @@ module Hobo
|
|
730
735
|
|
731
736
|
def hobo_completions(attribute, finder, options={})
|
732
737
|
options = options.reverse_merge(:limit => 10, :param => :query, :query_scope => "#{attribute}_contains")
|
733
|
-
finder = finder.limit(options[:limit]) unless finder.
|
738
|
+
finder = finder.limit(options[:limit]) unless finder.send(:scope, :find, :limit)
|
734
739
|
|
735
740
|
begin
|
736
741
|
finder = finder.send(options[:query_scope], params[options[:param]])
|
@@ -775,11 +780,11 @@ module Hobo
|
|
775
780
|
if render :permission_denied, :status => 403
|
776
781
|
# job done
|
777
782
|
else
|
778
|
-
render :text => t("hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
|
783
|
+
render :text => I18n.t("hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
|
779
784
|
end
|
780
785
|
end
|
781
786
|
wants.js do
|
782
|
-
render :text => t("hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
|
787
|
+
render :text => I18n.t("hobo.messages.permission_denied", :default=>["Permission Denied"]), :status => 403
|
783
788
|
end
|
784
789
|
end
|
785
790
|
end
|
@@ -787,16 +792,16 @@ module Hobo
|
|
787
792
|
|
788
793
|
|
789
794
|
def this
|
790
|
-
@this ||= (instance_variable_get("@#{model.name.
|
791
|
-
instance_variable_get("@#{model.name.
|
795
|
+
@this ||= (instance_variable_get("@#{model.name.underscore}") ||
|
796
|
+
instance_variable_get("@#{model.name.underscore.pluralize}"))
|
792
797
|
end
|
793
798
|
|
794
799
|
|
795
800
|
def this=(object)
|
796
|
-
ivar = if object.is_a?(Array)
|
797
|
-
(object.try.member_class || model).name.
|
801
|
+
ivar = if object.is_a?(Array)
|
802
|
+
(object.try.member_class || model).name.underscore.pluralize
|
798
803
|
else
|
799
|
-
object.class.name.
|
804
|
+
object.class.name.underscore
|
800
805
|
end
|
801
806
|
@this = instance_variable_set("@#{ivar}", object)
|
802
807
|
end
|