radiant-reader-extension 1.3.13 → 2.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/Rakefile +0 -19
- data/app/controllers/admin/group_invitations_controller.rb +78 -0
- data/app/controllers/admin/groups_controller.rb +8 -0
- data/app/controllers/admin/memberships_controller.rb +42 -0
- data/app/controllers/admin/messages_controller.rb +8 -3
- data/app/controllers/admin/permissions_controller.rb +42 -0
- data/app/controllers/admin/reader_configuration_controller.rb +0 -1
- data/app/controllers/admin/readers_controller.rb +1 -1
- data/app/controllers/password_resets_controller.rb +5 -5
- data/app/controllers/reader_action_controller.rb +13 -33
- data/app/controllers/reader_activations_controller.rb +4 -8
- data/app/controllers/reader_sessions_controller.rb +15 -26
- data/app/controllers/readers_controller.rb +26 -9
- data/app/helpers/reader_helper.rb +45 -17
- data/app/models/group.rb +80 -0
- data/app/models/membership.rb +13 -0
- data/app/models/message.rb +10 -7
- data/app/models/permission.rb +11 -0
- data/app/models/reader.rb +79 -35
- data/app/models/reader_notifier.rb +1 -0
- data/app/views/admin/group_invitations/new.html.haml +31 -0
- data/app/views/admin/group_invitations/preview.html.haml +58 -0
- data/app/views/admin/groups/_add_readers.html.haml +0 -0
- data/app/views/admin/groups/_form.html.haml +26 -0
- data/app/views/admin/groups/_list_head.html.haml +12 -0
- data/app/views/admin/groups/edit.html.haml +9 -0
- data/app/views/admin/groups/index.html.haml +44 -0
- data/app/views/admin/groups/new.html.haml +7 -0
- data/app/views/admin/groups/remove.html.haml +31 -0
- data/app/views/admin/groups/show.html.haml +74 -0
- data/app/views/admin/memberships/_reader.html.haml +9 -0
- data/app/views/admin/messages/_function.haml +31 -0
- data/app/views/admin/messages/_list_function.haml +7 -3
- data/app/views/admin/messages/_list_notes.html.haml +9 -0
- data/app/views/admin/messages/_message_description.html.haml +5 -1
- data/app/views/admin/messages/_message_group.html.haml +5 -0
- data/app/views/admin/messages/index.haml +4 -4
- data/app/views/admin/messages/show.html.haml +15 -15
- data/app/views/admin/pages/_listed.html.haml +16 -0
- data/app/views/admin/pages/_page_groups.html.haml +13 -0
- data/app/views/admin/permissions/_page.html.haml +24 -0
- data/app/views/admin/reader_configuration/edit.html.haml +3 -1
- data/app/views/admin/reader_configuration/show.html.haml +4 -2
- data/app/views/admin/readers/_form.html.haml +7 -7
- data/app/views/admin/readers/_password_fields.html.haml +6 -6
- data/app/views/admin/readers/_reader_groups.html.haml +7 -0
- data/app/views/admin/readers/edit.html.haml +2 -1
- data/app/views/admin/readers/index.html.haml +5 -2
- data/app/views/password_resets/create.html.haml +13 -8
- data/app/views/password_resets/edit.html.haml +26 -26
- data/app/views/password_resets/new.html.haml +28 -25
- data/app/views/reader_activations/_activation_required.haml +2 -2
- data/app/views/reader_activations/show.html.haml +11 -13
- data/app/views/reader_sessions/_login_form.html.haml +13 -12
- data/app/views/reader_sessions/new.html.haml +6 -8
- data/app/views/readers/_controls.html.haml +11 -9
- data/app/views/readers/_form.html.haml +32 -33
- data/app/views/readers/_memberships.html.haml +11 -0
- data/app/views/readers/edit.html.haml +11 -11
- data/app/views/readers/index.html.haml +9 -10
- data/app/views/readers/login.html.haml +10 -12
- data/app/views/readers/new.html.haml +11 -13
- data/app/views/readers/permission_denied.html.haml +7 -7
- data/app/views/readers/show.html.haml +7 -8
- data/app/views/shared/_standard_reader_parts.html.haml +14 -0
- data/app/views/site/not_allowed.html.haml +4 -0
- data/config/initializers/authlogic_connect_config.rb +12 -0
- data/config/initializers/radiant_config.rb +1 -0
- data/config/locales/en.yml +217 -177
- data/config/routes.rb +5 -0
- data/db/migrate/20090921125654_group_messages.rb +35 -0
- data/db/migrate/20091120083119_groups_public.rb +11 -0
- data/db/migrate/20110214101339_multiple_ownership.rb +13 -0
- data/lib/controller_extensions.rb +1 -1
- data/lib/group_tags.rb +65 -0
- data/lib/grouped_model.rb +125 -0
- data/lib/grouped_page.rb +39 -0
- data/lib/message_tags.rb +183 -0
- data/lib/radiant-reader-extension.rb +8 -0
- data/lib/reader_admin_ui.rb +29 -6
- data/lib/reader_tags.rb +7 -183
- data/lib/sanitize/config/generous.rb +49 -0
- data/lib/site_controller_extensions.rb +35 -0
- data/public/javascripts/reader.js +1 -1
- data/public/stylesheets/sass/reader.sass +18 -8
- data/radiant-reader-extension.gemspec +30 -176
- data/reader_extension.rb +31 -23
- data/spec/controllers/admin/messages_controller_spec.rb +1 -1
- data/spec/controllers/admin/readers_controller_spec.rb +0 -1
- data/spec/controllers/password_resets_controller_spec.rb +1 -1
- data/spec/controllers/reader_activations_controller_spec.rb +1 -1
- data/spec/controllers/readers_controller_spec.rb +67 -40
- data/spec/controllers/site_controller_spec.rb +63 -0
- data/spec/datasets/readers_dataset.rb +100 -11
- data/spec/models/group_spec.rb +46 -0
- data/spec/models/message_spec.rb +40 -15
- data/spec/models/page_spec.rb +81 -0
- data/spec/models/reader_notifier_spec.rb +1 -1
- data/spec/models/reader_spec.rb +17 -12
- metadata +99 -67
- data/.gitignore +0 -2
- data/VERSION +0 -1
- data/app/views/readers/_standard_parts.html.haml +0 -23
- data/spec/datasets/messages_dataset.rb +0 -49
- data/spec/datasets/reader_layouts_dataset.rb +0 -26
- data/spec/datasets/reader_sites_dataset.rb +0 -10
@@ -0,0 +1,35 @@
|
|
1
|
+
module SiteControllerExtensions
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval {
|
5
|
+
# NB. to control access without disabling the cache we have overridden Page.cache?
|
6
|
+
# to return false for any page that has a group association.
|
7
|
+
|
8
|
+
def find_page_with_group_check(url)
|
9
|
+
page = find_page_without_group_check(url)
|
10
|
+
raise ReaderGroup::PermissionDenied if page && !page.visible_to?(current_reader)
|
11
|
+
page
|
12
|
+
end
|
13
|
+
|
14
|
+
def show_page_with_group_check
|
15
|
+
show_page_without_group_check
|
16
|
+
rescue ReaderGroup::PermissionDenied
|
17
|
+
if current_reader
|
18
|
+
flash[:error] = t("reader_extension.access_denied")
|
19
|
+
redirect_to reader_permission_denied_url
|
20
|
+
else
|
21
|
+
flash[:explanation] = t("reader_extension.page_not_public")
|
22
|
+
flash[:error] = t("reader_extension.please_log_in")
|
23
|
+
store_location
|
24
|
+
redirect_to reader_login_url
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method_chain :find_page, :group_check
|
29
|
+
alias_method_chain :show_page, :group_check
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
@@ -1,11 +1,12 @@
|
|
1
1
|
@import compass/css3
|
2
2
|
|
3
3
|
$dark: #4d4e53
|
4
|
-
$mid: #8c8d8e
|
4
|
+
$mid: #8c8d8e
|
5
5
|
$pale: #afafaf
|
6
6
|
$paler: #bdbdbd
|
7
7
|
$verypale: #d6d6d4
|
8
|
-
$accent
|
8
|
+
$accent: #d1005d
|
9
|
+
$warning: red
|
9
10
|
|
10
11
|
=functional
|
11
12
|
font-family: helvetica, arial, sans-serif
|
@@ -23,7 +24,7 @@ div.error, div.notice
|
|
23
24
|
top: 50px
|
24
25
|
right: 50px
|
25
26
|
+border-radius
|
26
|
-
+box-shadow
|
27
|
+
+box-shadow($dark 2px 2px 4px)
|
27
28
|
color: white
|
28
29
|
padding: 1px 1em
|
29
30
|
a.closer
|
@@ -55,15 +56,20 @@ p.administrative
|
|
55
56
|
color: $pale
|
56
57
|
|
57
58
|
img.gravatar
|
58
|
-
+box-shadow
|
59
|
+
+box-shadow($dark 2px 2px 4px)
|
59
60
|
border: 3px solid white
|
60
61
|
&.thumbnail
|
61
62
|
margin: 2px 10px 10px 0
|
62
63
|
&.big
|
63
64
|
margin: 8px 10px 4px 0
|
64
65
|
&.tiny
|
65
|
-
margin:
|
66
|
+
margin: 3px 6px 4px 0
|
66
67
|
border: 1px solid white
|
68
|
+
&.left
|
69
|
+
float: left
|
70
|
+
&.right
|
71
|
+
float: right
|
72
|
+
margin: 8px 0 4px 10px
|
67
73
|
|
68
74
|
form.friendly
|
69
75
|
margin: 0 0 2em 0
|
@@ -82,10 +88,13 @@ form.friendly
|
|
82
88
|
input.standard
|
83
89
|
width: 95%
|
84
90
|
span.formnote
|
91
|
+
+small
|
85
92
|
color: $mid
|
86
93
|
label
|
87
94
|
&.required
|
88
95
|
font-weight: bold
|
96
|
+
div.hidden, div.innocuous
|
97
|
+
display: none
|
89
98
|
span.password
|
90
99
|
display: block
|
91
100
|
width: 95%
|
@@ -97,16 +106,17 @@ form.friendly
|
|
97
106
|
span.error-with-field
|
98
107
|
input, select
|
99
108
|
border: 1px solid red
|
100
|
-
color:
|
109
|
+
color: $warning
|
101
110
|
span.error
|
111
|
+
+small
|
102
112
|
line-height: 1.4
|
103
|
-
background-color: $
|
113
|
+
background-color: $warning
|
104
114
|
color: white
|
105
115
|
padding: 3px 6px
|
106
116
|
margin: -5px 0 0 6px
|
107
117
|
cursor: pointer
|
108
118
|
+border-radius
|
109
|
-
+box-shadow
|
119
|
+
+box-shadow($dark 2px 2px 4px)
|
110
120
|
a.closer
|
111
121
|
margin-left: 10px
|
112
122
|
color: white
|
@@ -1,184 +1,38 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "radiant-reader-extension"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = "radiant-reader-extension"
|
7
|
+
s.version = RadiantReaderExtension::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = RadiantReaderExtension::AUTHORS
|
10
|
+
s.email = RadiantReaderExtension::EMAIL
|
11
|
+
s.homepage = RadiantReaderExtension::URL
|
12
|
+
s.summary = RadiantReaderExtension::SUMMARY
|
13
|
+
s.description = RadiantReaderExtension::DESCRIPTION
|
9
14
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.email = %q{will@spanner.org}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.md"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".gitignore",
|
20
|
-
"README.md",
|
21
|
-
"Rakefile",
|
22
|
-
"VERSION",
|
23
|
-
"app/controllers/admin/messages_controller.rb",
|
24
|
-
"app/controllers/admin/reader_configuration_controller.rb",
|
25
|
-
"app/controllers/admin/readers_controller.rb",
|
26
|
-
"app/controllers/messages_controller.rb",
|
27
|
-
"app/controllers/password_resets_controller.rb",
|
28
|
-
"app/controllers/reader_action_controller.rb",
|
29
|
-
"app/controllers/reader_activations_controller.rb",
|
30
|
-
"app/controllers/reader_sessions_controller.rb",
|
31
|
-
"app/controllers/readers_controller.rb",
|
32
|
-
"app/helpers/reader_helper.rb",
|
33
|
-
"app/models/message.rb",
|
34
|
-
"app/models/message_function.rb",
|
35
|
-
"app/models/message_reader.rb",
|
36
|
-
"app/models/reader.rb",
|
37
|
-
"app/models/reader_notifier.rb",
|
38
|
-
"app/models/reader_session.rb",
|
39
|
-
"app/views/admin/messages/_form.html.haml",
|
40
|
-
"app/views/admin/messages/_help.html.haml",
|
41
|
-
"app/views/admin/messages/_list_function.haml",
|
42
|
-
"app/views/admin/messages/_message_description.html.haml",
|
43
|
-
"app/views/admin/messages/edit.html.haml",
|
44
|
-
"app/views/admin/messages/index.haml",
|
45
|
-
"app/views/admin/messages/new.html.haml",
|
46
|
-
"app/views/admin/messages/preview.html.haml",
|
47
|
-
"app/views/admin/messages/show.html.haml",
|
48
|
-
"app/views/admin/reader_configuration/edit.html.haml",
|
49
|
-
"app/views/admin/reader_configuration/show.html.haml",
|
50
|
-
"app/views/admin/readers/_avatar.html.haml",
|
51
|
-
"app/views/admin/readers/_form.html.haml",
|
52
|
-
"app/views/admin/readers/_password_fields.html.haml",
|
53
|
-
"app/views/admin/readers/edit.html.haml",
|
54
|
-
"app/views/admin/readers/index.html.haml",
|
55
|
-
"app/views/admin/readers/new.html.haml",
|
56
|
-
"app/views/admin/readers/remove.html.haml",
|
57
|
-
"app/views/admin/sites/_choose_reader_layout.html.haml",
|
58
|
-
"app/views/messages/preview.html.haml",
|
59
|
-
"app/views/messages/show.html.haml",
|
60
|
-
"app/views/password_resets/create.html.haml",
|
61
|
-
"app/views/password_resets/edit.html.haml",
|
62
|
-
"app/views/password_resets/new.html.haml",
|
63
|
-
"app/views/reader_activations/_activation_required.haml",
|
64
|
-
"app/views/reader_activations/show.html.haml",
|
65
|
-
"app/views/reader_notifier/message.html.haml",
|
66
|
-
"app/views/reader_sessions/_login_form.html.haml",
|
67
|
-
"app/views/reader_sessions/new.html.haml",
|
68
|
-
"app/views/readers/_contributions.html.haml",
|
69
|
-
"app/views/readers/_controls.html.haml",
|
70
|
-
"app/views/readers/_extra_controls.html.haml",
|
71
|
-
"app/views/readers/_flasher.html.haml",
|
72
|
-
"app/views/readers/_form.html.haml",
|
73
|
-
"app/views/readers/_standard_parts.html.haml",
|
74
|
-
"app/views/readers/edit.html.haml",
|
75
|
-
"app/views/readers/index.html.haml",
|
76
|
-
"app/views/readers/login.html.haml",
|
77
|
-
"app/views/readers/new.html.haml",
|
78
|
-
"app/views/readers/permission_denied.html.haml",
|
79
|
-
"app/views/readers/show.html.haml",
|
80
|
-
"config/initializers/radiant_config.rb",
|
81
|
-
"config/locales/en.yml",
|
82
|
-
"config/routes.rb",
|
83
|
-
"db/migrate/001_create_readers.rb",
|
84
|
-
"db/migrate/002_extend_sites.rb",
|
85
|
-
"db/migrate/003_reader_honorifics.rb",
|
86
|
-
"db/migrate/004_user_readers.rb",
|
87
|
-
"db/migrate/005_last_login.rb",
|
88
|
-
"db/migrate/007_adapt_for_authlogic.rb",
|
89
|
-
"db/migrate/20090921125653_reader_messages.rb",
|
90
|
-
"db/migrate/20090924164413_functional_messages.rb",
|
91
|
-
"db/migrate/20090925081225_standard_messages.rb",
|
92
|
-
"db/migrate/20091006102438_message_visibility.rb",
|
93
|
-
"db/migrate/20091010083503_registration_config.rb",
|
94
|
-
"db/migrate/20091019124021_message_functions.rb",
|
95
|
-
"db/migrate/20091020133533_forenames.rb",
|
96
|
-
"db/migrate/20091020135152_contacts.rb",
|
97
|
-
"db/migrate/20091111090819_ensure_functional_messages_visible.rb",
|
98
|
-
"db/migrate/20091119092936_messages_have_layout.rb",
|
99
|
-
"db/migrate/20100922152338_lock_versions.rb",
|
100
|
-
"db/migrate/20101004074945_unlock_version.rb",
|
101
|
-
"db/migrate/20101019094714_message_sent_date.rb",
|
102
|
-
"lib/controller_extensions.rb",
|
103
|
-
"lib/reader_admin_ui.rb",
|
104
|
-
"lib/reader_site.rb",
|
105
|
-
"lib/reader_tags.rb",
|
106
|
-
"lib/rfc822.rb",
|
107
|
-
"lib/tasks/reader_extension_tasks.rake",
|
108
|
-
"public/images/admin/chk_off.png",
|
109
|
-
"public/images/admin/chk_on.png",
|
110
|
-
"public/images/admin/delta.png",
|
111
|
-
"public/images/furniture/no_gravatar.png",
|
112
|
-
"public/javascripts/reader.js",
|
113
|
-
"public/stylesheets/sass/admin/reader.sass",
|
114
|
-
"public/stylesheets/sass/reader.sass",
|
115
|
-
"radiant-reader-extension.gemspec",
|
116
|
-
"reader_extension.rb",
|
117
|
-
"spec/controllers/admin/messages_controller_spec.rb",
|
118
|
-
"spec/controllers/admin/readers_controller_spec.rb",
|
119
|
-
"spec/controllers/password_resets_controller_spec.rb",
|
120
|
-
"spec/controllers/reader_activations_controller_spec.rb",
|
121
|
-
"spec/controllers/readers_controller_spec.rb",
|
122
|
-
"spec/datasets/messages_dataset.rb",
|
123
|
-
"spec/datasets/reader_layouts_dataset.rb",
|
124
|
-
"spec/datasets/reader_sites_dataset.rb",
|
125
|
-
"spec/datasets/readers_dataset.rb",
|
126
|
-
"spec/lib/reader_admin_ui_spec.rb",
|
127
|
-
"spec/lib/reader_site_spec.rb",
|
128
|
-
"spec/matchers/reader_login_system_matcher.rb",
|
129
|
-
"spec/models/message_spec.rb",
|
130
|
-
"spec/models/reader_notifier_spec.rb",
|
131
|
-
"spec/models/reader_spec.rb",
|
132
|
-
"spec/spec.opts",
|
133
|
-
"spec/spec_helper.rb"
|
134
|
-
]
|
135
|
-
s.homepage = %q{http://github.com/spanner/radiant-reader-extension}
|
136
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
137
|
-
s.require_paths = ["lib"]
|
138
|
-
s.rubygems_version = %q{1.3.7}
|
139
|
-
s.summary = %q{User-services extension for Radiant CMS}
|
140
|
-
s.test_files = [
|
141
|
-
"spec/controllers/admin/messages_controller_spec.rb",
|
142
|
-
"spec/controllers/admin/readers_controller_spec.rb",
|
143
|
-
"spec/controllers/password_resets_controller_spec.rb",
|
144
|
-
"spec/controllers/reader_activations_controller_spec.rb",
|
145
|
-
"spec/controllers/readers_controller_spec.rb",
|
146
|
-
"spec/datasets/messages_dataset.rb",
|
147
|
-
"spec/datasets/reader_layouts_dataset.rb",
|
148
|
-
"spec/datasets/reader_sites_dataset.rb",
|
149
|
-
"spec/datasets/readers_dataset.rb",
|
150
|
-
"spec/lib/reader_admin_ui_spec.rb",
|
151
|
-
"spec/lib/reader_site_spec.rb",
|
152
|
-
"spec/matchers/reader_login_system_matcher.rb",
|
153
|
-
"spec/models/message_spec.rb",
|
154
|
-
"spec/models/reader_notifier_spec.rb",
|
155
|
-
"spec/models/reader_spec.rb",
|
156
|
-
"spec/spec_helper.rb"
|
157
|
-
]
|
158
|
-
|
159
|
-
if s.respond_to? :specification_version then
|
160
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
161
|
-
s.specification_version = 3
|
15
|
+
s.add_dependency 'radiant-layouts-extension', "~> 0.9.1"
|
16
|
+
s.add_dependency 'radiant-mailer_layouts-extension', "~> 0.1.1"
|
17
|
+
s.add_dependency 'authlogic', "~> 2.1.6"
|
18
|
+
s.add_dependency 'sanitize', "~> 2.0.1"
|
162
19
|
|
163
|
-
|
164
|
-
|
165
|
-
s.add_runtime_dependency(%q<radiant-layouts-extension>, [">= 0"])
|
166
|
-
s.add_runtime_dependency(%q<radiant-mailer_layouts-extension>, [">= 0"])
|
167
|
-
s.add_runtime_dependency(%q<authlogic>, [">= 0"])
|
168
|
-
s.add_runtime_dependency(%q<sanitize>, [">= 0"])
|
169
|
-
else
|
170
|
-
s.add_dependency(%q<radiant>, [">= 0.9.0"])
|
171
|
-
s.add_dependency(%q<radiant-layouts-extension>, [">= 0"])
|
172
|
-
s.add_dependency(%q<radiant-mailer_layouts-extension>, [">= 0"])
|
173
|
-
s.add_dependency(%q<authlogic>, [">= 0"])
|
174
|
-
s.add_dependency(%q<sanitize>, [">= 0"])
|
175
|
-
end
|
20
|
+
ignores = if File.exist?('.gitignore')
|
21
|
+
File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
|
176
22
|
else
|
177
|
-
|
178
|
-
s.add_dependency(%q<radiant-layouts-extension>, [">= 0"])
|
179
|
-
s.add_dependency(%q<radiant-mailer_layouts-extension>, [">= 0"])
|
180
|
-
s.add_dependency(%q<authlogic>, [">= 0"])
|
181
|
-
s.add_dependency(%q<sanitize>, [">= 0"])
|
23
|
+
[]
|
182
24
|
end
|
183
|
-
|
25
|
+
s.files = Dir['**/*'] - ignores
|
26
|
+
s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
|
27
|
+
# s.executables = Dir['bin/*'] - ignores
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
|
30
|
+
s.post_install_message = %{
|
31
|
+
Add this to your radiant project with:
|
32
|
+
|
33
|
+
config.gem 'radiant-reader-extension', :version => '~> #{RadiantReaderExtension::VERSION}'
|
34
|
+
|
35
|
+
and please remember to enable ActionMailer in your project's config/environment.rb.
|
36
|
+
}
|
184
37
|
|
38
|
+
end
|
data/reader_extension.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
1
|
require_dependency 'application_controller'
|
2
|
+
require 'radiant-reader-extension'
|
2
3
|
|
3
4
|
class ReaderExtension < Radiant::Extension
|
4
|
-
version
|
5
|
-
description
|
6
|
-
url
|
5
|
+
version RadiantReaderExtension::VERSION
|
6
|
+
description RadiantReaderExtension::DESCRIPTION
|
7
|
+
url RadiantReaderExtension::URL
|
7
8
|
|
8
9
|
extension_config do |config|
|
9
|
-
config.gem
|
10
|
+
config.gem "authlogic"
|
10
11
|
config.gem 'sanitize'
|
11
12
|
end
|
12
13
|
|
14
|
+
migrate_from 'Reader Group', 20110214101339
|
15
|
+
|
13
16
|
def activate
|
14
|
-
|
17
|
+
ActiveRecord::Base.send :include, GroupedModel # has_group mechanism for any model that can belong_to a group
|
15
18
|
ApplicationController.send :include, ControllerExtensions # hooks up reader authentication and layout-chooser
|
19
|
+
SiteController.send :include, SiteControllerExtensions # access control based on group membership
|
20
|
+
Page.send :include, GroupedPage # group associations and visibility decisions
|
16
21
|
Site.send :include, ReaderSite if defined? Site # adds site scope and site-based layout-chooser
|
17
22
|
Page.send :include, ReaderTags # a few mailmerge-like radius tags for use in messages, or for greeting readers on (uncached) pages
|
18
23
|
UserActionObserver.instance.send :add_observer!, Reader
|
@@ -22,27 +27,30 @@ class ReaderExtension < Radiant::Extension
|
|
22
27
|
Radiant::AdminUI.send :include, ReaderAdminUI
|
23
28
|
Radiant::AdminUI.load_reader_extension_regions
|
24
29
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
admin.tabs.add "Readers", "/admin/readers", :after => "Layouts", :visibility => [:all]
|
37
|
-
if admin.tabs['Readers'].respond_to?(:add_link)
|
38
|
-
admin.tabs['Readers'].add_link('readers', '/admin/readers')
|
39
|
-
admin.tabs['Readers'].add_link('messages', '/admin/readers/messages')
|
40
|
-
admin.tabs['Readers'].add_link('settings', '/admin/readers/reader_configuration')
|
41
|
-
end
|
30
|
+
|
31
|
+
admin.page.edit.add :layout, "page_groups"
|
32
|
+
|
33
|
+
tab("Readers") do
|
34
|
+
add_item("Readers", "/admin/readers")
|
35
|
+
add_item("Groups", "/admin/readers/groups")
|
36
|
+
add_item("Messages", "/admin/readers/messages")
|
37
|
+
add_item("Settings", "/admin/readers/reader_configuration")
|
38
|
+
end
|
39
|
+
tab("Settings") do
|
40
|
+
add_item("Reader", "/admin/readers/reader_configuration")
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
def deactivate
|
46
|
-
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module ReaderGroup
|
50
|
+
class Exception < StandardError
|
51
|
+
def initialize(message = "Sorry: group problem"); super end
|
52
|
+
end
|
53
|
+
class PermissionDenied < Exception
|
54
|
+
def initialize(message = "Sorry: you don't have access to that"); super end
|
47
55
|
end
|
48
56
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe ReadersController do
|
4
|
-
dataset :readers
|
4
|
+
dataset :readers
|
5
5
|
|
6
6
|
before do
|
7
7
|
controller.stub!(:request).and_return(request)
|
@@ -11,6 +11,11 @@ describe ReadersController do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "with a get to new" do
|
14
|
+
before do
|
15
|
+
@reader = Reader.new
|
16
|
+
Reader.stub!(:new).and_return(@reader)
|
17
|
+
end
|
18
|
+
|
14
19
|
it "should render the registration screen" do
|
15
20
|
get :new
|
16
21
|
response.should be_success
|
@@ -18,38 +23,68 @@ describe ReadersController do
|
|
18
23
|
end
|
19
24
|
|
20
25
|
it "should generate a secret email field name" do
|
21
|
-
|
26
|
+
newreader = Reader.new
|
27
|
+
Reader.stub!(:new).and_return(newreader)
|
28
|
+
Authlogic::Random.should_receive(:friendly_token).at_least(:once).and_return("hello_dolly")
|
29
|
+
get :new
|
30
|
+
newreader.email_field.should == "hello_dolly"
|
31
|
+
session[:email_field].should == "hello_dolly"
|
22
32
|
end
|
23
33
|
end
|
24
34
|
|
25
35
|
describe "with a registration" do
|
26
|
-
before do
|
27
|
-
session[:email_field] = @email_field = 'randomstring'
|
28
|
-
post :create, :reader => {:name => "registering user", :password => "password", :password_confirmation => "password"}, :randomstring => 'registrant@spanner.org'
|
29
|
-
@reader = Reader.find_by_name('registering user')
|
30
|
-
end
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
describe "that validates" do
|
38
|
+
before do
|
39
|
+
session[:email_field] = 'gibberish'
|
40
|
+
post :create, :reader => {:name => "registering user", :password => "password", :password_confirmation => "password"}, :gibberish => 'registrant@spanner.org'
|
41
|
+
@newreader = Reader.find_by_name("registering user")
|
42
|
+
end
|
43
|
+
it "should create a new reader" do
|
44
|
+
@newreader.should_not be_nil
|
45
|
+
@newreader.new_record?.should be_false
|
46
|
+
@newreader.should be_valid
|
47
|
+
end
|
35
48
|
|
36
|
-
|
37
|
-
|
38
|
-
|
49
|
+
it "should set the current reader" do
|
50
|
+
controller.send(:current_reader).should == @newreader
|
51
|
+
end
|
39
52
|
|
40
|
-
|
41
|
-
|
42
|
-
|
53
|
+
it "should have deobfuscated the email field" do
|
54
|
+
@newreader.email.should == 'registrant@spanner.org'
|
55
|
+
end
|
43
56
|
|
44
|
-
|
45
|
-
|
46
|
-
|
57
|
+
it "should redirect to the please-activate page" do
|
58
|
+
response.should be_redirect
|
59
|
+
response.should redirect_to(reader_activation_url)
|
47
60
|
end
|
48
61
|
end
|
62
|
+
|
63
|
+
describe "that does not validate" do
|
64
|
+
before do
|
65
|
+
session[:email_field] = 'gibberish'
|
66
|
+
@newreader = Reader.new
|
67
|
+
Reader.stub!(:new).and_return(@newreader)
|
68
|
+
post :create, :reader => {:name => "registering user", :password => "password", :password_confirmation => "passwrd"}, :gibberish => 'registrant@spanner.org'
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should not create the user" do
|
72
|
+
@newreader.new_record?.should be_true
|
73
|
+
end
|
49
74
|
|
50
|
-
|
51
|
-
|
52
|
-
|
75
|
+
it "should not set the current reader" do
|
76
|
+
controller.send(:current_reader).should be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should return to the registration form" do
|
80
|
+
response.should be_success
|
81
|
+
response.should render_template('new')
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should set validation error messages" do
|
85
|
+
@newreader.errors.should_not be_empty
|
86
|
+
@newreader.errors.on(:password).should_not be_empty
|
87
|
+
end
|
53
88
|
end
|
54
89
|
|
55
90
|
describe "with the trap field filled in" do
|
@@ -79,6 +114,14 @@ describe ReadersController do
|
|
79
114
|
# controller.stub!(:current_reader_session).and_return(rsession)
|
80
115
|
end
|
81
116
|
|
117
|
+
it "should route '/account' to my account" do
|
118
|
+
params_from(:get, '/account').should == {:controller => 'readers', :action => 'edit'}
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should route '/profile' to my account" do
|
122
|
+
params_from(:get, '/profile').should == {:controller => 'readers', :action => 'show'}
|
123
|
+
end
|
124
|
+
|
82
125
|
it "should consent to show another reader page" do
|
83
126
|
get :show, :id => reader_id(:visible)
|
84
127
|
response.should be_success
|
@@ -123,9 +166,9 @@ describe ReadersController do
|
|
123
166
|
login_as_reader(:normal)
|
124
167
|
end
|
125
168
|
|
126
|
-
describe "that
|
169
|
+
describe "that is valid" do
|
127
170
|
before do
|
128
|
-
put :update, {:id => reader_id(:normal), :reader => {:name => "New Name"
|
171
|
+
put :update, {:id => reader_id(:normal), :reader => {:name => "New Name"}}
|
129
172
|
@reader = readers(:normal)
|
130
173
|
end
|
131
174
|
|
@@ -140,22 +183,6 @@ describe ReadersController do
|
|
140
183
|
|
141
184
|
end
|
142
185
|
|
143
|
-
describe "that does not include the correct password" do
|
144
|
-
before do
|
145
|
-
put :update, {:id => reader_id(:normal), :reader => {:name => "New Name"}, :current_password => 'wrongo'}
|
146
|
-
@reader = readers(:normal)
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should not update the reader" do
|
150
|
-
@reader.name.should == 'Normal'
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should re-render the edit form" do
|
154
|
-
response.should be_success
|
155
|
-
response.should render_template("edit")
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
186
|
describe "that does not validate" do
|
160
187
|
before do
|
161
188
|
put :update, {:id => reader_id(:normal), :reader => {:login => "visible@spanner.org"}, :current_password => 'password'}
|