hobo 0.7.5 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/{hobo_files/plugin/CHANGES.txt → CHANGES.txt} +391 -0
- data/Manifest +146 -0
- data/{hobo_files/plugin/README → README} +0 -0
- data/bin/hobo +13 -26
- data/dryml_generators/rapid/cards.dryml.erb +55 -0
- data/dryml_generators/rapid/forms.dryml.erb +43 -0
- data/dryml_generators/rapid/pages.dryml.erb +284 -0
- data/hobo.gemspec +168 -0
- data/init.rb +9 -0
- data/lib/action_view_extensions/helpers/tag_helper.rb +7 -0
- data/lib/active_record/association_collection.rb +54 -0
- data/{hobo_files/plugin/lib → lib}/active_record/association_proxy.rb +12 -4
- data/{hobo_files/plugin/lib → lib}/active_record/association_reflection.rb +7 -1
- data/{hobo_files/plugin/lib → lib}/extensions/test_case.rb +17 -17
- data/{hobo_files/plugin/lib → lib}/hobo.rb +193 -100
- data/{hobo_files/plugin/lib → lib}/hobo/authentication_support.rb +8 -8
- data/{hobo_files/plugin/lib → lib}/hobo/bundle.rb +90 -89
- data/{hobo_files/plugin/lib → lib}/hobo/composite_model.rb +21 -21
- data/{hobo_files/plugin/lib → lib}/hobo/controller.rb +38 -25
- data/{hobo_files/plugin/lib → lib}/hobo/dev_controller.rb +10 -6
- data/lib/hobo/dryml.rb +167 -0
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_builder.rb +28 -25
- data/lib/hobo/dryml/dryml_generator.rb +210 -0
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_support_controller.rb +1 -1
- data/lib/hobo/dryml/parser.rb +3 -0
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/attribute.rb +6 -6
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/base_parser.rb +16 -16
- data/lib/hobo/dryml/parser/document.rb +57 -0
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/element.rb +7 -7
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/elements.rb +9 -9
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/source.rb +3 -3
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/text.rb +3 -3
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/tree_parser.rb +3 -3
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/part_context.rb +26 -26
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/scoped_variables.rb +15 -15
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/tag_parameters.rb +10 -10
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/taglib.rb +43 -37
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/template.rb +290 -208
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_environment.rb +173 -115
- data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_handler.rb +19 -24
- data/lib/hobo/find_for.rb +95 -0
- data/{hobo_files/plugin/lib → lib}/hobo/generator.rb +2 -1
- data/{hobo_files/plugin/lib → lib}/hobo/guest.rb +12 -4
- data/{hobo_files/plugin/lib → lib}/hobo/hobo_helper.rb +146 -117
- data/lib/hobo/include_in_save.rb +43 -0
- data/lib/hobo/lifecycles.rb +94 -0
- data/lib/hobo/lifecycles/actions.rb +73 -0
- data/lib/hobo/lifecycles/creator.rb +76 -0
- data/lib/hobo/lifecycles/lifecycle.rb +205 -0
- data/lib/hobo/lifecycles/state.rb +23 -0
- data/lib/hobo/lifecycles/transition.rb +66 -0
- data/{hobo_files/plugin/lib → lib}/hobo/model.rb +306 -217
- data/{hobo_files/plugin/lib → lib}/hobo/model_controller.rb +342 -213
- data/{hobo_files/plugin/lib → lib}/hobo/model_router.rb +151 -120
- data/{hobo_files/plugin/lib → lib}/hobo/model_support.rb +9 -9
- data/{hobo_files/plugin/lib → lib}/hobo/rapid_helper.rb +30 -23
- data/{hobo_files/plugin/lib → lib}/hobo/scopes.rb +22 -68
- data/{hobo_files/plugin/lib → lib}/hobo/scopes/apply_scopes.rb +5 -5
- data/lib/hobo/scopes/association_proxy_extensions.rb +47 -0
- data/{hobo_files/plugin/lib → lib}/hobo/scopes/automatic_scopes.rb +104 -79
- data/lib/hobo/scopes/named_scope_extensions.rb +27 -0
- data/{hobo_files/plugin/lib → lib}/hobo/static_tags +1 -11
- data/{hobo_files/plugin/lib → lib}/hobo/undefined.rb +1 -1
- data/{hobo_files/plugin/lib → lib}/hobo/undefined_access_error.rb +0 -0
- data/{hobo_files/plugin/lib → lib}/hobo/user.rb +27 -25
- data/{hobo_files/plugin/lib → lib}/hobo/user_controller.rb +80 -34
- data/{hobo_files/plugin/generators → rails_generators}/hobo/hobo_generator.rb +7 -7
- data/rails_generators/hobo/templates/application.css +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/application.dryml +0 -2
- data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/dryml-support.js +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/guest.rb +0 -0
- data/rails_generators/hobo/templates/initializer.rb +9 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/USAGE +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/hobo_front_controller_generator.rb +1 -3
- data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/controller.rb +1 -1
- data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/functional_test.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/helper.rb +0 -0
- data/rails_generators/hobo_front_controller/templates/index.dryml +25 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model/USAGE +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model/hobo_model_generator.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/fixtures.yml +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/model.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/unit_test.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/USAGE +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/hobo_model_controller_generator.rb +0 -7
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/controller.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/functional_test.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/helper.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/hobo_model_resource_generator.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/controller.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/functional_test.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/helper.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/hobo_rapid_generator.rb +21 -11
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/IE7.js +1 -1
- data/rails_generators/hobo_rapid/templates/blank.gif +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.css +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.js +175 -104
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/lowpro.js +0 -0
- data/rails_generators/hobo_rapid/templates/nicEditorIcons.gif +0 -0
- data/rails_generators/hobo_rapid/templates/nicedit.js +91 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/reset.css +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/pencil.png +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/small_close.png +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/spinner.gif +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css +80 -71
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +6 -1
- data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/views/clean.dryml +4 -4
- data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +73 -0
- data/rails_generators/hobo_subsite/templates/application.dryml +1 -0
- data/rails_generators/hobo_subsite/templates/controller.rb +5 -0
- data/rails_generators/hobo_subsite/templates/site_taglib.dryml +13 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/USAGE +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/hobo_user_controller_generator.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/controller.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/functional_test.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/helper.rb +0 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/USAGE +0 -0
- data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +30 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/fixtures.yml +0 -0
- data/rails_generators/hobo_user_model/templates/forgot_password.erb +10 -0
- data/rails_generators/hobo_user_model/templates/mailer.rb +14 -0
- data/rails_generators/hobo_user_model/templates/model.rb +55 -0
- data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/unit_test.rb +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/{hobo_files/plugin/taglibs → taglibs}/core.dryml +6 -7
- data/{hobo_files/plugin/taglibs → taglibs}/rapid.dryml +36 -67
- data/{hobo_files/plugin/taglibs → taglibs}/rapid_document_tags.dryml +7 -24
- data/{hobo_files/plugin/taglibs → taglibs}/rapid_editing.dryml +51 -50
- data/{hobo_files/plugin/taglibs → taglibs}/rapid_forms.dryml +62 -56
- data/taglibs/rapid_generics.dryml +33 -0
- data/taglibs/rapid_lifecycles.dryml +43 -0
- data/{hobo_files/plugin/taglibs → taglibs}/rapid_navigation.dryml +23 -23
- data/taglibs/rapid_pages.dryml +183 -0
- data/{hobo_files/plugin/taglibs → taglibs}/rapid_plus.dryml +30 -5
- data/{hobo_files/plugin/taglibs → taglibs}/rapid_support.dryml +3 -4
- data/taglibs/rapid_user_pages.dryml +179 -0
- data/{hobo_files/plugin/tasks → tasks}/environments.rake +0 -0
- data/{hobo_files/plugin/tasks → tasks}/fix_dryml.rake +0 -0
- data/{hobo_files/plugin/tasks → tasks}/generate_tag_reference.rb +21 -22
- data/tasks/hobo_tasks.rake +32 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +1 -0
- data/test/test_hobo_model_controller_generator.rb +56 -0
- data/{hobo_files/plugin/uninstall.rb → uninstall.rb} +0 -0
- metadata +240 -225
- data/README.txt +0 -18
- data/hobo_files/plugin/LICENSE.txt +0 -22
- data/hobo_files/plugin/Rakefile +0 -96
- data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +0 -24
- data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +0 -19
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/banner.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-bodytop.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-01.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-02.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-03.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-04.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-bottom.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-left.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-right.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-top.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-blue.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-dblue.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-green.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-purple.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-red.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/logo.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/plus.png +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/spinner.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-dblue.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-green.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-purple.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-red.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-01.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-02.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-03.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-04.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-bottom.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-left.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-right.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-top.gif +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +0 -400
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +0 -96
- data/hobo_files/plugin/generators/hobo_user_model/hobo_user_model_generator.rb +0 -25
- data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +0 -56
- data/hobo_files/plugin/init.rb +0 -101
- data/hobo_files/plugin/lib/action_view_extensions/base.rb +0 -15
- data/hobo_files/plugin/lib/active_record/has_many_association.rb +0 -55
- data/hobo_files/plugin/lib/active_record/has_many_through_association.rb +0 -20
- data/hobo_files/plugin/lib/hobo/dryml.rb +0 -165
- data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +0 -53
- data/hobo_files/plugin/lib/hobo/scopes/association_proxy_extensions.rb +0 -33
- data/hobo_files/plugin/lib/hobo/scopes/defined_scope_proxy_extender.rb +0 -90
- data/hobo_files/plugin/lib/hobo/scopes/scope_reflection.rb +0 -18
- data/hobo_files/plugin/lib/hobo/scopes/scoped_proxy.rb +0 -55
- data/hobo_files/plugin/taglib-docs/core.markdown +0 -165
- data/hobo_files/plugin/taglib-docs/rapid.markdown +0 -677
- data/hobo_files/plugin/taglib-docs/rapid_document_tags.markdown +0 -240
- data/hobo_files/plugin/taglib-docs/rapid_editing.markdown +0 -418
- data/hobo_files/plugin/taglib-docs/rapid_forms.markdown +0 -562
- data/hobo_files/plugin/taglib-docs/rapid_generics.markdown +0 -187
- data/hobo_files/plugin/taglib-docs/rapid_navigation.markdown +0 -214
- data/hobo_files/plugin/taglib-docs/rapid_pages.markdown +0 -530
- data/hobo_files/plugin/taglib-docs/rapid_plus.markdown +0 -65
- data/hobo_files/plugin/taglib-docs/rapid_support.markdown +0 -50
- data/hobo_files/plugin/taglib-docs/rapid_user_pages.markdown +0 -129
- data/hobo_files/plugin/taglibs/rapid_generics.dryml +0 -117
- data/hobo_files/plugin/taglibs/rapid_pages.dryml +0 -359
- data/hobo_files/plugin/taglibs/rapid_user_pages.dryml +0 -104
- data/hobo_files/plugin/tasks/dump_fixtures.rake +0 -70
- data/hobo_files/plugin/tasks/hobo_tasks.rake +0 -17
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module NamedScope
|
3
|
+
class Scope
|
4
|
+
|
5
|
+
delegate :member_class, :to => :proxy_found
|
6
|
+
|
7
|
+
include Hobo::Scopes::ApplyScopes
|
8
|
+
|
9
|
+
def respond_to?(method)
|
10
|
+
super || scopes.include?(method) || proxy_scope.respond_to?(method)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def method_missing(method, *args, &block)
|
16
|
+
if respond_to?(method) && scopes.include?(method)
|
17
|
+
scopes[method].call(self, *args)
|
18
|
+
else
|
19
|
+
with_scope :find => proxy_options do
|
20
|
+
proxy_scope.send(method, *args, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -2,21 +2,17 @@ abbr
|
|
2
2
|
acronym
|
3
3
|
address
|
4
4
|
applet
|
5
|
-
area
|
6
5
|
b
|
7
|
-
base
|
8
6
|
basefont
|
9
7
|
bdo
|
10
8
|
big
|
11
9
|
blockquote
|
12
10
|
body
|
13
|
-
br
|
14
11
|
button
|
15
12
|
caption
|
16
13
|
center
|
17
14
|
cite
|
18
15
|
code
|
19
|
-
col
|
20
16
|
colgroup
|
21
17
|
dd
|
22
18
|
del
|
@@ -29,7 +25,6 @@ em
|
|
29
25
|
embed
|
30
26
|
fieldset
|
31
27
|
font
|
32
|
-
frame
|
33
28
|
frameset
|
34
29
|
h1
|
35
30
|
h2
|
@@ -38,21 +33,16 @@ h4
|
|
38
33
|
h5
|
39
34
|
h6
|
40
35
|
head
|
41
|
-
hr
|
42
|
-
html
|
43
36
|
i
|
44
37
|
iframe
|
45
|
-
img
|
46
38
|
ins
|
47
39
|
isindex
|
48
40
|
kbd
|
49
41
|
label
|
50
42
|
legend
|
51
43
|
li
|
52
|
-
link
|
53
44
|
map
|
54
45
|
menu
|
55
|
-
meta
|
56
46
|
noframes
|
57
47
|
noscript
|
58
48
|
object
|
@@ -60,7 +50,6 @@ ol
|
|
60
50
|
optgroup
|
61
51
|
option
|
62
52
|
p
|
63
|
-
param
|
64
53
|
pre
|
65
54
|
q
|
66
55
|
s
|
@@ -84,4 +73,5 @@ title
|
|
84
73
|
tr
|
85
74
|
tt
|
86
75
|
u
|
76
|
+
ul
|
87
77
|
var
|
File without changes
|
@@ -3,13 +3,13 @@ require 'digest/sha1'
|
|
3
3
|
module Hobo
|
4
4
|
|
5
5
|
module User
|
6
|
-
|
6
|
+
|
7
7
|
@user_models = []
|
8
|
-
|
8
|
+
|
9
9
|
def self.default_user_model
|
10
10
|
@user_models.first._?.constantize
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
AUTHENTICATION_FIELDS = [:salt, :crypted_password, :remember_token, :remember_token_expires_at]
|
14
14
|
|
15
15
|
# Extend the base class with AuthenticatedUser functionality
|
@@ -19,18 +19,18 @@ module Hobo
|
|
19
19
|
# - login token for rembering a login during multiple browser sessions
|
20
20
|
def self.included(base)
|
21
21
|
@user_models << base.name
|
22
|
-
|
22
|
+
|
23
23
|
base.extend(ClassMethods)
|
24
24
|
|
25
25
|
base.class_eval do
|
26
|
-
|
26
|
+
|
27
27
|
fields do
|
28
28
|
crypted_password :string, :limit => 40
|
29
29
|
salt :string, :limit => 40
|
30
30
|
remember_token :string
|
31
31
|
remember_token_expires_at :datetime
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
validates_confirmation_of :password, :if => :password_required?
|
35
35
|
|
36
36
|
# Virtual attributes for setting and changing the password
|
@@ -38,43 +38,46 @@ module Hobo
|
|
38
38
|
|
39
39
|
|
40
40
|
validate :validate_current_password_when_changing_password
|
41
|
-
|
41
|
+
|
42
42
|
before_save :encrypt_password
|
43
|
-
|
43
|
+
|
44
44
|
never_show *AUTHENTICATION_FIELDS
|
45
|
-
|
45
|
+
|
46
46
|
attr_protected *AUTHENTICATION_FIELDS
|
47
|
-
|
47
|
+
|
48
48
|
password_validations
|
49
|
+
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
53
|
# Additional classmethods for authentication
|
53
54
|
module ClassMethods
|
54
|
-
|
55
|
+
|
55
56
|
# Validation of the plaintext password
|
56
57
|
def password_validations
|
57
58
|
validates_length_of :password, :within => 4..40, :if => :password_required?
|
58
59
|
end
|
59
|
-
|
60
|
+
|
60
61
|
def login_attribute=(attr, validate=true)
|
61
62
|
@login_attribute = attr = attr.to_sym
|
62
63
|
unless attr == :login
|
63
64
|
alias_attribute(:login, attr)
|
64
65
|
declare_attr_type(:login, attr_type(attr)) if table_exists? # this breaks if the table doesn't exist
|
65
66
|
end
|
66
|
-
|
67
|
+
|
67
68
|
if validate
|
68
69
|
validates_length_of attr, :within => 3..100
|
69
70
|
validates_uniqueness_of attr, :case_sensitive => false
|
70
71
|
end
|
71
72
|
end
|
73
|
+
|
72
74
|
attr_reader :login_attribute
|
73
75
|
|
76
|
+
|
74
77
|
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
|
75
78
|
def authenticate(login, password)
|
76
79
|
u = find(:first, :conditions => ["#{@login_attribute} = ?", login]) # need to get the salt
|
77
|
-
|
80
|
+
|
78
81
|
if u && u.authenticated?(password)
|
79
82
|
if u.respond_to?(:last_login_at) || u.respond_to?(:login_count)
|
80
83
|
u.last_login_at = Time.now if u.respond_to?(:last_login_at)
|
@@ -91,11 +94,6 @@ module Hobo
|
|
91
94
|
def encrypt(password, salt)
|
92
95
|
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
|
93
96
|
end
|
94
|
-
|
95
|
-
|
96
|
-
def set_admin_on_first_user
|
97
|
-
before_create { |user| user.administrator = true if count == 0 }
|
98
|
-
end
|
99
97
|
|
100
98
|
end
|
101
99
|
|
@@ -131,9 +129,13 @@ module Hobo
|
|
131
129
|
def guest?
|
132
130
|
false
|
133
131
|
end
|
134
|
-
|
132
|
+
|
133
|
+
def signed_up?
|
134
|
+
true
|
135
|
+
end
|
136
|
+
|
135
137
|
def changing_password?
|
136
|
-
crypted_password? && (password || password_confirmation)
|
138
|
+
crypted_password? && (password || password_confirmation) && !lifecycle.valid_key?
|
137
139
|
end
|
138
140
|
|
139
141
|
protected
|
@@ -144,17 +146,17 @@ module Hobo
|
|
144
146
|
self.crypted_password = encrypt(password)
|
145
147
|
end
|
146
148
|
|
147
|
-
|
149
|
+
|
148
150
|
# Is a password required for login? (or do we have an empty password?)
|
149
151
|
def password_required?
|
150
152
|
(crypted_password.blank? && password != nil) || !password.blank? || changing_password?
|
151
153
|
end
|
152
154
|
|
153
|
-
|
155
|
+
|
154
156
|
def validate_current_password_when_changing_password
|
155
|
-
changing_password? && !authenticated?(current_password) and errors.add :current_password, "is not correct"
|
157
|
+
changing_password? && !authenticated?(current_password) and errors.add :current_password, "is not correct"
|
156
158
|
end
|
157
|
-
|
159
|
+
|
158
160
|
end
|
159
161
|
|
160
162
|
end
|
@@ -4,32 +4,59 @@ module Hobo
|
|
4
4
|
|
5
5
|
class << self
|
6
6
|
def included(base)
|
7
|
-
base.class_eval do
|
8
|
-
|
9
|
-
skip_before_filter :login_required, :only => [:login, :signup]
|
7
|
+
base.class_eval do
|
8
|
+
extend ClassMethods
|
10
9
|
|
11
|
-
|
10
|
+
class << self
|
11
|
+
alias_method_chain :available_auto_actions, :user_actions
|
12
|
+
alias_method_chain :def_auto_actions, :user_actions
|
13
|
+
end
|
12
14
|
|
15
|
+
filter_parameter_logging "password"
|
16
|
+
skip_before_filter :login_required, :only => [:login, :signup, :forgot_password, :reset_password_page, :reset_password]
|
17
|
+
|
18
|
+
include_taglib "rapid_user_pages", :plugin => "hobo"
|
19
|
+
|
13
20
|
show_action :account
|
14
|
-
|
21
|
+
|
15
22
|
alias_method_chain :hobo_update, :account_flash
|
16
23
|
end
|
24
|
+
|
17
25
|
end
|
26
|
+
|
27
|
+
|
18
28
|
end
|
19
29
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
30
|
+
module ClassMethods
|
31
|
+
|
32
|
+
def available_auto_actions_with_user_actions
|
33
|
+
available_auto_actions_without_user_actions +
|
34
|
+
[:login, :signup, :logout, :forgot_password, :reset_password]
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def def_auto_actions_with_user_actions
|
39
|
+
def_auto_actions_without_user_actions
|
40
|
+
|
41
|
+
class_eval do
|
42
|
+
def login; hobo_login; end if include_action?(:login)
|
43
|
+
def logout; hobo_logout; end if include_action?(:logout)
|
44
|
+
def do_signup; hobo_do_signup end if include_action?(:do_signup)
|
45
|
+
def forgot_password; hobo_forgot_password; end if include_action?(:forgot_password)
|
46
|
+
def do_reset_password; hobo_do_reset_password; end if include_action?(:do_reset_password)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
26
53
|
private
|
27
|
-
|
54
|
+
|
28
55
|
def hobo_login(options={})
|
29
56
|
login_attr = model.login_attribute.to_s.titleize.downcase
|
30
57
|
options.reverse_merge!(:success_notice => "You have logged in.",
|
31
58
|
:failure_notice => "You did not provide a valid #{login_attr} and password.")
|
32
|
-
|
59
|
+
|
33
60
|
if request.post?
|
34
61
|
user = model.authenticate(params[:login], params[:password])
|
35
62
|
if user.nil?
|
@@ -37,7 +64,7 @@ module Hobo
|
|
37
64
|
else
|
38
65
|
old_user = current_user
|
39
66
|
self.current_user = user
|
40
|
-
|
67
|
+
|
41
68
|
# If supplied, a block can be used to test if this user is
|
42
69
|
# allowed to log in (e.g. the account may be disabled)
|
43
70
|
account_available = block_given? ? yield : true
|
@@ -58,23 +85,18 @@ module Hobo
|
|
58
85
|
end
|
59
86
|
end
|
60
87
|
|
61
|
-
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
redirect_back_or_default(home_page)
|
70
|
-
end
|
71
|
-
else
|
72
|
-
self.this = model.new
|
73
|
-
yield if block_given?
|
88
|
+
|
89
|
+
def hobo_do_signup(&b)
|
90
|
+
do_creator_action(:signup) do
|
91
|
+
response_block(&b) or if valid?
|
92
|
+
self.current_user = this
|
93
|
+
flash[:notice] = "Thanks for signing up!"
|
94
|
+
redirect_back_or_default(home_page)
|
95
|
+
end
|
74
96
|
end
|
75
97
|
end
|
76
98
|
|
77
|
-
|
99
|
+
|
78
100
|
def hobo_logout(options={})
|
79
101
|
options = options.reverse_merge(:notice => "You have logged out.",
|
80
102
|
:redirect_to => base_url)
|
@@ -84,17 +106,41 @@ module Hobo
|
|
84
106
|
flash[:notice] ||= options[:notice]
|
85
107
|
redirect_back_or_default(options[:redirect_to]) unless performed?
|
86
108
|
end
|
87
|
-
|
88
|
-
|
109
|
+
|
110
|
+
|
111
|
+
def hobo_forgot_password
|
112
|
+
if request.post?
|
113
|
+
user = model.find_by_email_address(params[:email_address])
|
114
|
+
if user && (!block_given? || yield(user))
|
115
|
+
Hobo::Controller.request_host = request.host_with_port
|
116
|
+
Hobo::Controller.app_name = call_tag(:app_name)
|
117
|
+
user.lifecycle.request_password_reset(:nobody)
|
118
|
+
end
|
119
|
+
render_tag :forgot_password_email_sent_page
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
def hobo_do_reset_password(&b)
|
125
|
+
do_transition_action :reset_password do
|
126
|
+
response_block(&b) or if valid?
|
127
|
+
self.current_user = this
|
128
|
+
flash[:notice] = "Your password has been reset"
|
129
|
+
redirect_to home_page
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
89
135
|
def hobo_update_with_account_flash(*args)
|
90
136
|
hobo_update_without_account_flash(*args) do
|
91
137
|
flash[:notice] = "Changes to your account were saved" if valid? && @this == current_user
|
92
138
|
yield if block_given?
|
93
139
|
end
|
94
140
|
end
|
95
|
-
|
141
|
+
|
96
142
|
private
|
97
|
-
|
143
|
+
|
98
144
|
def logout_current_user
|
99
145
|
if logged_in?
|
100
146
|
current_user.forget_me
|
@@ -103,7 +149,7 @@ module Hobo
|
|
103
149
|
self.current_user = nil
|
104
150
|
end
|
105
151
|
end
|
106
|
-
|
152
|
+
|
107
153
|
end
|
108
|
-
|
154
|
+
|
109
155
|
end
|
@@ -5,9 +5,7 @@ class HoboGenerator < Rails::Generator::Base
|
|
5
5
|
routes_path = File.join(RAILS_ROOT, "config/routes.rb")
|
6
6
|
|
7
7
|
route = " Hobo.add_routes(map)\n"
|
8
|
-
|
9
8
|
route_src = File.read(routes_path)
|
10
|
-
|
11
9
|
unless route_src.include?(route)
|
12
10
|
head = "ActionController::Routing::Routes.draw do |map|"
|
13
11
|
route_src.sub!(head, head + "\n\n" + route)
|
@@ -16,12 +14,14 @@ class HoboGenerator < Rails::Generator::Base
|
|
16
14
|
end
|
17
15
|
|
18
16
|
record do |m|
|
19
|
-
m.directory
|
20
|
-
m.directory
|
21
|
-
m.directory
|
17
|
+
m.directory File.join("app/views/taglibs")
|
18
|
+
m.directory File.join("app/views/taglibs/themes")
|
19
|
+
m.directory File.join("public/hobothemes")
|
22
20
|
m.template "application.dryml", File.join("app/views/taglibs/application.dryml")
|
23
|
-
m.file "guest.rb",
|
24
|
-
m.file "dryml-support.js",
|
21
|
+
m.file "guest.rb", File.join("app/models/guest.rb")
|
22
|
+
m.file "dryml-support.js", File.join("public/javascripts/dryml-support.js")
|
23
|
+
m.file "application.css", File.join("public/stylesheets/application.css")
|
24
|
+
m.file "initializer.rb", File.join("config/initializers/hobo.rb")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
File without changes
|