radiant-reader-extension 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/README.md +15 -11
  2. data/VERSION +1 -1
  3. data/app/controllers/admin/messages_controller.rb +45 -6
  4. data/app/controllers/admin/reader_configuration_controller.rb +3 -0
  5. data/app/controllers/password_resets_controller.rb +8 -10
  6. data/app/controllers/reader_action_controller.rb +2 -2
  7. data/app/controllers/reader_activations_controller.rb +6 -7
  8. data/app/controllers/reader_sessions_controller.rb +3 -3
  9. data/app/controllers/readers_controller.rb +9 -10
  10. data/app/models/message.rb +2 -2
  11. data/app/models/message_function.rb +4 -0
  12. data/app/models/reader_notifier.rb +10 -7
  13. data/app/views/admin/messages/_form.html.haml +3 -1
  14. data/app/views/admin/messages/_list_function.haml +3 -0
  15. data/app/views/admin/messages/index.haml +42 -0
  16. data/app/views/admin/messages/preview.html.haml +1 -0
  17. data/app/views/admin/messages/show.html.haml +72 -0
  18. data/app/views/admin/reader_configuration/edit.html.haml +41 -0
  19. data/app/views/admin/reader_configuration/show.html.haml +46 -0
  20. data/app/views/admin/readers/_form.html.haml +2 -1
  21. data/app/views/admin/readers/index.html.haml +33 -2
  22. data/app/views/password_resets/create.html.haml +6 -9
  23. data/app/views/password_resets/edit.html.haml +26 -30
  24. data/app/views/password_resets/new.html.haml +10 -11
  25. data/app/views/reader_activations/show.html.haml +17 -26
  26. data/app/views/reader_sessions/_login_form.html.haml +19 -25
  27. data/app/views/reader_sessions/new.html.haml +17 -15
  28. data/app/views/readers/_flasher.html.haml +2 -2
  29. data/app/views/readers/_form.html.haml +30 -36
  30. data/app/views/readers/edit.html.haml +17 -19
  31. data/app/views/readers/index.html.haml +5 -7
  32. data/app/views/readers/login.html.haml +6 -5
  33. data/app/views/readers/new.html.haml +21 -20
  34. data/app/views/readers/permission_denied.html.haml +13 -9
  35. data/app/views/readers/show.html.haml +12 -9
  36. data/config/initializers/radiant_config.rb +12 -0
  37. data/config/locales/en.yml +147 -0
  38. data/config/routes.rb +5 -6
  39. data/db/migrate/20101019094714_message_sent_date.rb +11 -0
  40. data/lib/reader_admin_ui.rb +25 -10
  41. data/lib/reader_helper.rb +0 -7
  42. data/lib/reader_tags.rb +15 -10
  43. data/public/images/admin/delta.png +0 -0
  44. data/public/stylesheets/sass/admin/reader.sass +72 -81
  45. data/radiant-reader-extension.gemspec +13 -19
  46. data/reader_extension.rb +6 -7
  47. data/spec/controllers/admin/messages_controller_spec.rb +26 -9
  48. data/spec/controllers/readers_controller_spec.rb +1 -1
  49. data/spec/models/message_spec.rb +1 -2
  50. data/spec/models/reader_notifier_spec.rb +1 -2
  51. metadata +16 -22
  52. data/app/controllers/admin/reader_settings_controller.rb +0 -92
  53. data/app/helpers/admin/reader_settings_helper.rb +0 -36
  54. data/app/views/admin/reader_settings/_setting.html.haml +0 -24
  55. data/app/views/admin/reader_settings/edit.html.haml +0 -10
  56. data/app/views/admin/reader_settings/index.html.haml +0 -35
  57. data/app/views/admin/reader_settings/show.html.haml +0 -1
  58. data/app/views/admin/readers/_list_head.html.haml +0 -9
  59. data/app/views/admin/readers/_listed.html.haml +0 -22
  60. data/app/views/reader_activations/_activation_required.html.haml +0 -34
  61. data/app/views/reader_activations/_on_activation.html.haml +0 -4
  62. data/app/views/readers/create.html.haml +0 -28
  63. data/app/views/wrappers/_field_errors.html.haml +0 -5
  64. data/config/settings.rb +0 -9
  65. data/pkg/radiant-reader-extension-0.9.0.gem +0 -0
  66. data/public/images/admin/new-message.png +0 -0
  67. data/public/images/admin/new-reader.png +0 -0
  68. data/public/javascripts/admin/messages.js +0 -13
@@ -10,29 +10,46 @@ describe Admin::MessagesController do
10
10
  it "should handle Messages" do
11
11
  controller.class.model_class.should == Message
12
12
  end
13
+
14
+ describe "on preview" do
15
+ before do
16
+ login_as :existing
17
+ end
18
+
19
+ it "should render a bare message" do
20
+ get :preview, :id => message_id(:taggy)
21
+ response.should be_success
22
+ response.should render_template('preview')
23
+ response.layout.should == nil
24
+ end
25
+
26
+ end
13
27
 
14
- describe "on index" do
28
+ describe "on deliver" do
15
29
  before do
16
30
  login_as :existing
17
31
  end
18
32
 
19
- it "should redirect to the settings page" do
20
- get :index
33
+ it "should trigger a sending" do
34
+ message = messages(:taggy)
35
+ Message.should_receive(:find).at_least(:once).and_return(message)
36
+ message.should_receive(:deliver).once
37
+ get :deliver, :id => message_id(:taggy), :delivery => 'all'
21
38
  response.should be_redirect
22
- response.should redirect_to(admin_reader_settings_url)
39
+ response.should redirect_to(admin_message_url(messages(:taggy)))
23
40
  end
24
41
  end
25
-
26
- describe "on update" do
42
+
43
+ describe "on update (and create)" do
27
44
  before do
28
45
  login_as :existing
29
46
  end
30
47
 
31
- it "should redirect to the settings page" do
48
+ it "should redirect to show the updated object" do
32
49
  put :update, :id => message_id(:normal), :subject => 'testing'
33
50
  response.should be_redirect
34
- response.should redirect_to(admin_reader_settings_url)
51
+ response.should redirect_to(admin_message_path(message_id(:normal)))
35
52
  end
36
53
  end
37
54
 
38
- end
55
+ end
@@ -91,7 +91,7 @@ describe ReadersController do
91
91
  it "should not show the edit page for another reader" do
92
92
  get :edit, :id => reader_id(:visible)
93
93
  response.should be_success
94
- flash[:error].should =~ /not allowed/
94
+ flash[:error].should =~ /cannot_edit_others/
95
95
  end
96
96
 
97
97
  it "should not remove this reader" do
@@ -40,9 +40,8 @@ describe Message do
40
40
 
41
41
  it "should render a fake sending" do
42
42
  @preview.should be_kind_of(TMail::Mail)
43
- @preview.from.should == [messages(:taggy).created_by.email]
43
+ @preview.from.should == ["admin@www.example.com"]
44
44
  @preview.subject.should == messages(:taggy).subject
45
- @preview.body.should =~ /From #{messages(:taggy).created_by.name}/
46
45
  end
47
46
  end
48
47
 
@@ -14,7 +14,7 @@ describe ReaderNotifier do
14
14
  it "should render a supplied message" do
15
15
  message = ReaderNotifier.create_message(readers(:normal), messages(:normal))
16
16
  message.to.should == [readers(:normal).email]
17
- message.from.should == [users(:existing).email]
17
+ message.from.should == ["admin@www.example.com"]
18
18
  message.body.should =~ /#{messages(:normal).filtered_body}/
19
19
  message.content_type.should == 'text/html'
20
20
  end
@@ -28,7 +28,6 @@ describe ReaderNotifier do
28
28
  message = ReaderNotifier.create_message(readers(:normal), messages(:taggy))
29
29
  message.body.should =~ /<title>#{messages(:taggy).subject}<\/title>/
30
30
  message.body.should =~ /To #{readers(:normal).name}/
31
- message.body.should =~ /From #{users(:existing).name}/
32
31
  end
33
32
 
34
33
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-reader-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - spanner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-04 00:00:00 +01:00
18
+ date: 2010-10-19 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -104,14 +104,13 @@ files:
104
104
  - Rakefile
105
105
  - VERSION
106
106
  - app/controllers/admin/messages_controller.rb
107
- - app/controllers/admin/reader_settings_controller.rb
107
+ - app/controllers/admin/reader_configuration_controller.rb
108
108
  - app/controllers/admin/readers_controller.rb
109
109
  - app/controllers/password_resets_controller.rb
110
110
  - app/controllers/reader_action_controller.rb
111
111
  - app/controllers/reader_activations_controller.rb
112
112
  - app/controllers/reader_sessions_controller.rb
113
113
  - app/controllers/readers_controller.rb
114
- - app/helpers/admin/reader_settings_helper.rb
115
114
  - app/models/message.rb
116
115
  - app/models/message_function.rb
117
116
  - app/models/message_reader.rb
@@ -120,17 +119,17 @@ files:
120
119
  - app/models/reader_session.rb
121
120
  - app/views/admin/messages/_form.html.haml
122
121
  - app/views/admin/messages/_help.html.haml
122
+ - app/views/admin/messages/_list_function.haml
123
123
  - app/views/admin/messages/_message_description.html.haml
124
124
  - app/views/admin/messages/edit.html.haml
125
+ - app/views/admin/messages/index.haml
125
126
  - app/views/admin/messages/new.html.haml
126
- - app/views/admin/reader_settings/_setting.html.haml
127
- - app/views/admin/reader_settings/edit.html.haml
128
- - app/views/admin/reader_settings/index.html.haml
129
- - app/views/admin/reader_settings/show.html.haml
127
+ - app/views/admin/messages/preview.html.haml
128
+ - app/views/admin/messages/show.html.haml
129
+ - app/views/admin/reader_configuration/edit.html.haml
130
+ - app/views/admin/reader_configuration/show.html.haml
130
131
  - app/views/admin/readers/_avatar.html.haml
131
132
  - app/views/admin/readers/_form.html.haml
132
- - app/views/admin/readers/_list_head.html.haml
133
- - app/views/admin/readers/_listed.html.haml
134
133
  - app/views/admin/readers/_password_fields.html.haml
135
134
  - app/views/admin/readers/edit.html.haml
136
135
  - app/views/admin/readers/index.html.haml
@@ -140,8 +139,6 @@ files:
140
139
  - app/views/password_resets/create.html.haml
141
140
  - app/views/password_resets/edit.html.haml
142
141
  - app/views/password_resets/new.html.haml
143
- - app/views/reader_activations/_activation_required.html.haml
144
- - app/views/reader_activations/_on_activation.html.haml
145
142
  - app/views/reader_activations/show.html.haml
146
143
  - app/views/reader_notifier/message.html.haml
147
144
  - app/views/reader_sessions/_login_form.html.haml
@@ -151,16 +148,15 @@ files:
151
148
  - app/views/readers/_extra_controls.html.haml
152
149
  - app/views/readers/_flasher.html.haml
153
150
  - app/views/readers/_form.html.haml
154
- - app/views/readers/create.html.haml
155
151
  - app/views/readers/edit.html.haml
156
152
  - app/views/readers/index.html.haml
157
153
  - app/views/readers/login.html.haml
158
154
  - app/views/readers/new.html.haml
159
155
  - app/views/readers/permission_denied.html.haml
160
156
  - app/views/readers/show.html.haml
161
- - app/views/wrappers/_field_errors.html.haml
157
+ - config/initializers/radiant_config.rb
158
+ - config/locales/en.yml
162
159
  - config/routes.rb
163
- - config/settings.rb
164
160
  - db/migrate/001_create_readers.rb
165
161
  - db/migrate/002_extend_sites.rb
166
162
  - db/migrate/003_reader_honorifics.rb
@@ -180,6 +176,7 @@ files:
180
176
  - db/migrate/20100922152338_lock_versions.rb
181
177
  - db/migrate/20100927095703_default_settings.rb
182
178
  - db/migrate/20101004074945_unlock_version.rb
179
+ - db/migrate/20101019094714_message_sent_date.rb
183
180
  - lib/config_extensions.rb
184
181
  - lib/controller_extensions.rb
185
182
  - lib/reader_admin_ui.rb
@@ -188,12 +185,9 @@ files:
188
185
  - lib/reader_tags.rb
189
186
  - lib/rfc822.rb
190
187
  - lib/tasks/reader_extension_tasks.rake
191
- - pkg/radiant-reader-extension-0.9.0.gem
192
188
  - public/images/admin/chk_off.png
193
189
  - public/images/admin/chk_on.png
194
- - public/images/admin/new-message.png
195
- - public/images/admin/new-reader.png
196
- - public/javascripts/admin/messages.js
190
+ - public/images/admin/delta.png
197
191
  - public/stylesheets/sass/admin/reader.sass
198
192
  - radiant-reader-extension.gemspec
199
193
  - reader_extension.rb
@@ -1,92 +0,0 @@
1
- class Admin::ReaderSettingsController < ApplicationController
2
- only_allow_access_to :show, :edit, :update,
3
- :when => [:admin],
4
- :denied_url => { :controller => 'admin/reader_settings', :action => 'index' },
5
- :denied_message => 'You must have admin privileges to edit reader settings.'
6
-
7
- before_filter :default_settings
8
- before_filter :get_setting, :only => [:show, :edit, :update]
9
-
10
- cattr_accessor :settable
11
- # this will need to be extensible
12
- @@settable = {
13
- 'reader.allow_registration?' => true,
14
- 'reader.require_confirmation?' => true,
15
- 'reader.layout' => 'unset',
16
- 'site.title' => 'Site Title',
17
- 'site.url' => 'Site URL',
18
- 'reader.mail_from_name' => 'Sender',
19
- 'reader.mail_from_address' => 'sender@example.com'
20
- }
21
-
22
- def self.make_settable(settings)
23
- @@settable.merge! settings
24
- end
25
-
26
- def index
27
-
28
- end
29
-
30
- def show
31
- respond_to do |format|
32
- format.html { }
33
- format.js { render :layout => false }
34
- end
35
- end
36
-
37
- def edit
38
- respond_to do |format|
39
- format.html { }
40
- format.js { render :layout => false }
41
- end
42
- end
43
-
44
- def update
45
- Rails.logger.warn "<< #{@setting.key} is #{@setting.value.inspect}"
46
-
47
- value = params[:value] || params[:radiant_config][:value]
48
-
49
- if @setting.boolean?
50
- @setting.value = (value == 'false' ? false : true)
51
- else
52
- @setting.value = value
53
- end
54
-
55
- Rails.logger.warn ">> and now #{@setting.key} is #{@setting.value.inspect}"
56
-
57
- @setting.save!
58
- respond_to do |format|
59
- format.html { render :action => 'show' }
60
- format.js { render :layout => false, :action => 'show' }
61
- end
62
- end
63
-
64
- private
65
-
66
- def settable?(key)
67
- self.class.settable.keys.include?(key)
68
- end
69
-
70
- # temporarily while I do this properly in radiant
71
-
72
- def default_settings
73
- self.class.settable.each do |k, v|
74
- Radiant::Config[k] = v if Radiant::Config[k].nil?
75
- end
76
- end
77
-
78
- def get_setting
79
- @setting = Radiant::Config.find(params[:id])
80
- unless settable?(@setting.key)
81
- respond_to do |format|
82
- format.html {
83
- flash['error'] = "Not settable"
84
- redirect_to :action => 'index'
85
- }
86
- format.js { render :status => 403, :text => 'Not settable' }
87
- end
88
- return false
89
- end
90
- end
91
-
92
- end
@@ -1,36 +0,0 @@
1
- module Admin::ReaderSettingsHelper
2
-
3
- def editable_setting(setting)
4
- setting = Radiant::Config.find_by_key(setting) unless setting.is_a? Radiant::Config
5
- domkey = setting.key.gsub('?', '_')
6
- containerid = "set_#{domkey}"
7
- link = link_to_remote setting.value,
8
- :url => edit_admin_reader_setting_url(setting.id),
9
- :method => 'get',
10
- :update => containerid,
11
- :loading => "$('#{containerid}').addClassName('waiting');",
12
- :loaded => "$('#{containerid}').removeClassName('waiting');"
13
- %{
14
- #{link}
15
- }
16
- end
17
-
18
- def checkbox_for_setting(setting, label)
19
- setting = Radiant::Config.find_by_key(setting) unless setting.is_a? Radiant::Config
20
- domkey = setting.key.gsub('?', '_')
21
- containerid = "set_#{domkey}"
22
- checkbox = check_box_tag setting.key.to_sym, 1, setting.value, :class => 'fancy', :id => domkey, :onchange => remote_function(
23
- :url => admin_reader_setting_path(setting.id),
24
- :with => %{'value=' + (this.checked ? 'true' : 'false')},
25
- :method => 'put',
26
- :loading => "$('#{containerid}').addClassName('waiting');",
27
- :success => "$('#{containerid}').removeClassName('waiting').toggleClassName('true').toggleClassName('false');"
28
- )
29
- %{
30
- #{checkbox}
31
- <label for="#{domkey}">#{label}</label>
32
- }
33
-
34
- end
35
-
36
- end
@@ -1,24 +0,0 @@
1
- - if setting || key
2
- - setting ||= Radiant::Config.find_by_key(key)
3
- - if setting
4
- - label ||= setting.key
5
- - notes ||= nil
6
- - domkey = setting.key.gsub('?', '_')
7
- - containerid = "set_#{domkey}"
8
-
9
- - if setting.key.ends_with?("?")
10
- %p.ruled
11
- %span{:id => containerid, :class => "checkbox #{setting.value.to_s}"}
12
- = checkbox_for_setting(setting, label)
13
-
14
- - else
15
- %p.ruled
16
- %label= label
17
- %span.inplace{:id => containerid}
18
- = editable_setting(setting)
19
-
20
- - else
21
- %p.haserror
22
- %strong
23
- = key
24
- is not defined.
@@ -1,10 +0,0 @@
1
- - domkey = @setting.key.gsub('?', '_')
2
- - domid = "set_#{domkey}"
3
-
4
- - remote_form_for @setting, :url => admin_reader_setting_path(@setting), :update => domid, :loading => "$('#{domid}').addClassName('waiting');", :loaded => "$('#{domid}').removeClassName('waiting');", :html => { :method => :put } do |f|
5
- - if @setting.key =~ /\.layout$/
6
- = f.select :value, Layout.all.collect {|l| [ l.name, l.name ] }
7
- - else
8
- = f.text_field :value
9
- = f.submit 'save'
10
- = link_to_remote 'cancel', {:url => admin_reader_setting_url(@setting.id), :method => 'get', :update => domid, :loading => "$('#{domid}').addClassName('waiting');", :loaded => "$('#{domid}').removeClassName('waiting');"}, {:class => 'cancel'}
@@ -1,35 +0,0 @@
1
- - body_classes << "reversed"
2
- - include_stylesheet('admin/reader')
3
-
4
- #reader_settings.box
5
- %h3 Reader administration
6
-
7
- - render_region :settings do |settings|
8
- - settings.registration do
9
- = render :partial => 'setting', :locals => {:key => 'reader.allow_registration?', :label => 'Allow visitors to register'}
10
- = render :partial => 'setting', :locals => {:key => 'reader.require_confirmation?', :label => 'Require email confirmation'}
11
- = render :partial => 'setting', :locals => {:key => 'reader.layout', :label => "Admin layout", :notes => "The radiant layout used to present reader-administration pages"}
12
-
13
- - settings.site do
14
- = render :partial => 'setting', :locals => {:key => 'site.title', :label => "Site title", :notes => "This is the name by which forms and emails refer to your site"}
15
- = render :partial => 'setting', :locals => {:key => 'site.url', :label => "Site url", :notes => "This is the address we use to build links in emails"}
16
-
17
- - settings.sender do
18
- = render :partial => 'setting', :locals => {:key => 'reader.mail_from_name', :label => "Email sender", :notes => "This is the name that automatic emails seem to come from"}
19
- = render :partial => 'setting', :locals => {:key => 'reader.mail_from_address', :label => "Email address", :notes => "This is the address that automatic emails seem to come from"}
20
-
21
- #message_settings.box
22
- %h3 Administrative messages
23
-
24
- - render_region :messages do |messages|
25
- - messages.administration do
26
- - MessageFunction.find_all.each do |func|
27
- - message = Message.for_function(func).shift
28
- %p.ruled
29
- %label= func.description
30
- - if message
31
- = link_to message.subject, edit_admin_message_url(message)
32
- - else
33
- = link_to image('plus') + " create message", new_admin_message_url(:function => func), :class => 'create'
34
-
35
-
@@ -1 +0,0 @@
1
- = editable_setting(@setting)
@@ -1,9 +0,0 @@
1
- %thead
2
- %tr
3
- - render_region :thead do |thead|
4
- - thead.title_header do
5
- %th.reader Name / Login
6
- - thead.description_header do
7
- %th.reader_description Self-description
8
- - thead.modify_header do
9
- %th.modify Modify
@@ -1,22 +0,0 @@
1
- %tr.node.level-1
2
- - render_region :tbody do |tbody|
3
- - tbody.title_cell do
4
- %td{:class => reader.activated? ? 'name activated' : 'name inactive'}
5
- = link_to image_tag(gravatar_url(reader.email, :size=>"32px"), :class=>"avatar avatar_32x32", :width=>32, :height=>32, :alt=>""), edit_admin_reader_url(reader)
6
- = link_to reader.name, edit_admin_reader_url(reader), :class => reader.trusted? ? '' : 'untrusted'
7
- %span.info
8
- = "(#{reader.login})"
9
- - unless reader.notes.blank?
10
- %p.admin_notes
11
- %strong
12
- note:
13
- = reader.notes
14
-
15
- - tbody.description_cell do
16
- %td.reader_description
17
- = truncate_and_textilize(reader.description, 24)
18
-
19
- - tbody.modify_cell do
20
- %td.remove
21
- - if admin?
22
- = link_to(image('remove', :alt => 'Remove Reader'), admin_reader_url(reader), :method => :delete, :confirm => "really delete reader #{reader.name}?")