radiant-reader-extension 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. data/.gitignore +2 -0
  2. data/README.md +89 -0
  3. data/Rakefile +140 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/admin/messages_controller.rb +20 -0
  6. data/app/controllers/admin/reader_settings_controller.rb +92 -0
  7. data/app/controllers/admin/readers_controller.rb +28 -0
  8. data/app/controllers/password_resets_controller.rb +64 -0
  9. data/app/controllers/reader_action_controller.rb +84 -0
  10. data/app/controllers/reader_activations_controller.rb +60 -0
  11. data/app/controllers/reader_sessions_controller.rb +56 -0
  12. data/app/controllers/readers_controller.rb +131 -0
  13. data/app/helpers/admin/reader_settings_helper.rb +36 -0
  14. data/app/models/message.rb +108 -0
  15. data/app/models/message_function.rb +37 -0
  16. data/app/models/message_reader.rb +13 -0
  17. data/app/models/reader.rb +146 -0
  18. data/app/models/reader_notifier.rb +34 -0
  19. data/app/models/reader_session.rb +3 -0
  20. data/app/views/admin/messages/_form.html.haml +29 -0
  21. data/app/views/admin/messages/_help.html.haml +41 -0
  22. data/app/views/admin/messages/_message_description.html.haml +3 -0
  23. data/app/views/admin/messages/edit.html.haml +16 -0
  24. data/app/views/admin/messages/new.html.haml +16 -0
  25. data/app/views/admin/reader_settings/_setting.html.haml +24 -0
  26. data/app/views/admin/reader_settings/edit.html.haml +10 -0
  27. data/app/views/admin/reader_settings/index.html.haml +35 -0
  28. data/app/views/admin/reader_settings/show.html.haml +1 -0
  29. data/app/views/admin/readers/_avatar.html.haml +3 -0
  30. data/app/views/admin/readers/_form.html.haml +50 -0
  31. data/app/views/admin/readers/_list_head.html.haml +9 -0
  32. data/app/views/admin/readers/_listed.html.haml +22 -0
  33. data/app/views/admin/readers/_password_fields.html.haml +18 -0
  34. data/app/views/admin/readers/edit.html.haml +8 -0
  35. data/app/views/admin/readers/index.html.haml +17 -0
  36. data/app/views/admin/readers/new.html.haml +7 -0
  37. data/app/views/admin/readers/remove.html.haml +18 -0
  38. data/app/views/admin/sites/_choose_reader_layout.html.haml +7 -0
  39. data/app/views/password_resets/create.html.haml +13 -0
  40. data/app/views/password_resets/edit.html.haml +71 -0
  41. data/app/views/password_resets/new.html.haml +31 -0
  42. data/app/views/reader_activations/_activation_required.html.haml +34 -0
  43. data/app/views/reader_activations/_on_activation.html.haml +4 -0
  44. data/app/views/reader_activations/show.html.haml +41 -0
  45. data/app/views/reader_notifier/message.html.haml +1 -0
  46. data/app/views/reader_sessions/_login_form.html.haml +59 -0
  47. data/app/views/reader_sessions/new.html.haml +38 -0
  48. data/app/views/readers/_contributions.html.haml +2 -0
  49. data/app/views/readers/_controls.html.haml +25 -0
  50. data/app/views/readers/_extra_controls.html.haml +0 -0
  51. data/app/views/readers/_flasher.html.haml +6 -0
  52. data/app/views/readers/_form.html.haml +73 -0
  53. data/app/views/readers/create.html.haml +28 -0
  54. data/app/views/readers/edit.html.haml +47 -0
  55. data/app/views/readers/index.html.haml +16 -0
  56. data/app/views/readers/login.html.haml +15 -0
  57. data/app/views/readers/new.html.haml +41 -0
  58. data/app/views/readers/permission_denied.html.haml +23 -0
  59. data/app/views/readers/show.html.haml +35 -0
  60. data/app/views/wrappers/_field_errors.html.haml +5 -0
  61. data/config/routes.rb +22 -0
  62. data/config/settings.rb +9 -0
  63. data/db/migrate/001_create_readers.rb +31 -0
  64. data/db/migrate/002_extend_sites.rb +17 -0
  65. data/db/migrate/003_reader_honorifics.rb +12 -0
  66. data/db/migrate/004_user_readers.rb +11 -0
  67. data/db/migrate/005_last_login.rb +15 -0
  68. data/db/migrate/007_adapt_for_authlogic.rb +27 -0
  69. data/db/migrate/20090921125653_reader_messages.rb +27 -0
  70. data/db/migrate/20090924164413_functional_messages.rb +9 -0
  71. data/db/migrate/20090925081225_standard_messages.rb +106 -0
  72. data/db/migrate/20091006102438_message_visibility.rb +9 -0
  73. data/db/migrate/20091010083503_registration_config.rb +10 -0
  74. data/db/migrate/20091019124021_message_functions.rb +9 -0
  75. data/db/migrate/20091020133533_forenames.rb +9 -0
  76. data/db/migrate/20091020135152_contacts.rb +23 -0
  77. data/db/migrate/20091111090819_ensure_functional_messages_visible.rb +9 -0
  78. data/db/migrate/20091119092936_messages_have_layout.rb +9 -0
  79. data/db/migrate/20100922152338_lock_versions.rb +9 -0
  80. data/db/migrate/20100927095703_default_settings.rb +14 -0
  81. data/db/migrate/20101004074945_unlock_version.rb +9 -0
  82. data/lib/config_extensions.rb +5 -0
  83. data/lib/controller_extensions.rb +77 -0
  84. data/lib/reader_admin_ui.rb +64 -0
  85. data/lib/reader_helper.rb +36 -0
  86. data/lib/reader_site.rb +10 -0
  87. data/lib/reader_tags.rb +297 -0
  88. data/lib/rfc822.rb +29 -0
  89. data/lib/tasks/reader_extension_tasks.rake +28 -0
  90. data/pkg/radiant-reader-extension-0.9.0.gem +0 -0
  91. data/public/images/admin/chk_off.png +0 -0
  92. data/public/images/admin/chk_on.png +0 -0
  93. data/public/images/admin/new-message.png +0 -0
  94. data/public/images/admin/new-reader.png +0 -0
  95. data/public/javascripts/admin/messages.js +13 -0
  96. data/public/stylesheets/sass/admin/reader.sass +95 -0
  97. data/radiant-reader-extension.gemspec +184 -0
  98. data/reader_extension.rb +55 -0
  99. data/spec/controllers/admin/messages_controller_spec.rb +38 -0
  100. data/spec/controllers/admin/readers_controller_spec.rb +14 -0
  101. data/spec/controllers/password_resets_controller_spec.rb +140 -0
  102. data/spec/controllers/reader_activations_controller_spec.rb +45 -0
  103. data/spec/controllers/readers_controller_spec.rb +193 -0
  104. data/spec/datasets/messages_dataset.rb +49 -0
  105. data/spec/datasets/reader_layouts_dataset.rb +26 -0
  106. data/spec/datasets/reader_sites_dataset.rb +10 -0
  107. data/spec/datasets/readers_dataset.rb +51 -0
  108. data/spec/lib/reader_admin_ui_spec.rb +35 -0
  109. data/spec/lib/reader_site_spec.rb +18 -0
  110. data/spec/matchers/reader_login_system_matcher.rb +35 -0
  111. data/spec/models/message_spec.rb +109 -0
  112. data/spec/models/reader_notifier_spec.rb +34 -0
  113. data/spec/models/reader_spec.rb +155 -0
  114. data/spec/spec.opts +5 -0
  115. data/spec/spec_helper.rb +48 -0
  116. metadata +267 -0
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,22 @@
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}?")
@@ -0,0 +1,18 @@
1
+ %p#display_password{:style=> (@reader.new_record? or !@reader.valid?) ? "display: none" : nil}
2
+ %label= t('password')
3
+ %span.value
4
+ •••••
5
+ %a.action{:href=>"#", :onclick=>" $('display_password').hide(); $('change_password').show()"}= t('change')
6
+ .set#change_password{:style=> (!@reader.new_record? && @reader.valid?) ? "display: none" : nil}
7
+ %p
8
+ = f.label :password, t('new_password')
9
+ = f.password_field "password", :class => "textbox big", :value => "", :size => 15, :maxlength => 40
10
+ %p
11
+ = f.label :password_confirmation, t('password_confirmation')
12
+ = f.password_field "password_confirmation", :class => "textbox big", :value => "", :size => 15, :maxlength => 40
13
+ - unless @reader.new_record?
14
+ %span
15
+ = t('or')
16
+ %a{:href=>"#", :onclick=>" $('display_password').show(); $('change_password').hide()"}= t('cancel')
17
+
18
+
@@ -0,0 +1,8 @@
1
+ - @page_title = @reader.name + ' ' + t('account') + ' - ' + default_page_title
2
+ - body_classes << 'edit_user'
3
+
4
+ - render_region :main do |main|
5
+ - main.edit_header do
6
+ %h1 Edit Reader
7
+ - main.edit_form do
8
+ = render :partial => 'form'
@@ -0,0 +1,17 @@
1
+ - include_stylesheet('admin/reader')
2
+ = render_region :top
3
+
4
+ #readers_table.outset
5
+ %table#readers.index{:cellspacing=>"0", :border=>"0", :cellpadding=>"0"}
6
+ %thead
7
+ = render :partial => 'list_head'
8
+ %tbody
9
+ - @readers.each do |reader|
10
+ = render :partial => 'listed', :locals => {:reader => reader}
11
+
12
+ - render_region :bottom do |bottom|
13
+ - bottom.buttons do
14
+ #actions
15
+ = pagination_for @readers
16
+ %ul
17
+ %li= link_to image('plus') + " " + "new reader", new_admin_reader_url
@@ -0,0 +1,7 @@
1
+ - include_stylesheet('admin/reader')
2
+ - render_region :main do |main|
3
+ - main.edit_header do
4
+ %h1 Invite a reader
5
+ %p This will cause an invitation (and activation) message to be sent to the email address that you specify.
6
+ - main.edit_form do
7
+ = render :partial => 'form'
@@ -0,0 +1,18 @@
1
+ %h1 Remove Reader
2
+
3
+ %p
4
+ Are you sure you want to
5
+ %strong.warning permanently remove
6
+ the following reader?
7
+
8
+ %table.index#readers{:cellpadding=>0, :cellspacing=>0, :border=>0}
9
+ %tbody
10
+ %tr.node.level-1
11
+ %td.reader
12
+ %span.title= @reader.name
13
+
14
+ - form_for [:admin, @reader], :html => { :method => :delete } do
15
+ %p.buttons
16
+ %input.button{:type=>"submit", :value=>"Delete Reader"}/
17
+ or
18
+ = link_to 'Cancel', admin_readers_path
@@ -0,0 +1,7 @@
1
+ - layouts = @site.respond_to?(:layouts) ? @site.layouts : Layout.find(:all)
2
+ %p.subtitle
3
+ %label{:for=>"site_reader_layout_id", :class => "admin_only"}
4
+ Layout for readers
5
+ = select :site, :reader_layout_id, layouts.map { |l| [l.name, l.id] }
6
+ %br
7
+ %span.formnote currently you have to be logged into the site to see its layouts here. will fix.
@@ -0,0 +1,13 @@
1
+ %p
2
+ Thank you. A message has been sent to
3
+ %strong
4
+ = params[:email]
5
+ containing the instructions for setting a new password.
6
+ Remember, it hasn't changed yet and won't until you follow the instructions in the message.
7
+
8
+ - content_for :breadcrumbs do
9
+ = link_to 'Home', '/'
10
+ &gt; Reset password
11
+
12
+ - content_for :pagetitle do
13
+ Reset message sent
@@ -0,0 +1,71 @@
1
+ .mainform
2
+ - if @reader
3
+
4
+ %p
5
+ %strong
6
+ Hello
7
+ = @reader.name + '.'
8
+ Thank you for persevering with the authorization process.
9
+ %br
10
+ Please enter and confirm the new password you would like to use. It must be at least four characters long, nothing obvious or typical and ideally a mixture of numbers and letters.
11
+
12
+
13
+ - form_for @reader, :url => password_reset_path, :method => :put, :html => {:class => 'friendly', :autocomplete => "off"} do |f|
14
+
15
+ - if @reader.errors.any?
16
+ %p.haserror
17
+ %strong
18
+ Sorry: there was a problem.
19
+ = @reader.errors.full_messages.to_sentence
20
+
21
+ = hidden_field_tag :id, params[:id]
22
+ = hidden_field_tag :confirmation_code, @reader.perishable_token
23
+
24
+ %p{:class => @reader.errors.any? ? 'haserror' : ''}
25
+ = f.label :password, "New password", :class => 'required'
26
+ %br
27
+ = f.password_field :password, :class => 'titular'
28
+
29
+ %p{:class => @reader.errors.any? ? 'haserror' : ''}
30
+ = f.label :password_confirmation, "Repeat for confirmation", :class => 'required'
31
+ %br
32
+ = f.password_field :password_confirmation, :class => 'titular'
33
+ %p
34
+ = f.submit "Update my password and log me in"
35
+
36
+ %p
37
+ Your password hasn't changed yet, so if you've just remembered it you can still
38
+ = link_to "log in.", reader_login_url
39
+
40
+ - content_for :pagetitle do
41
+ Change my password
42
+
43
+ - else
44
+
45
+ %p.haserror
46
+ Sorry: the system can't find you. That link must have been garbled somewhere along the line.
47
+ Please paste the 20-character confirmation code into the box below and we'll try again.
48
+
49
+ - form_tag edit_password_reset_path, :method => 'GET', :class => 'friendly', :autocomplete => "off" do
50
+ = hidden_field_tag :id, params[:id]
51
+ %p
52
+ %label{:for => "confirmation_code"}
53
+ confirmation code
54
+ %br
55
+ = text_field_tag 'confirmation_code', '', :class => 'titular'
56
+
57
+ %p
58
+ = submit_tag 'try again'
59
+
60
+ %p
61
+ The confirmation code only works for ten minutes, but you can always
62
+ = link_to "enter your email address again", new_password_reset_url
63
+ and we'll send a new one.
64
+
65
+ - content_for :pagetitle do
66
+ Please enter confirmation code
67
+
68
+ - content_for :breadcrumbs do
69
+ = link_to 'Home', '/'
70
+ &gt; Reset password
71
+
@@ -0,0 +1,31 @@
1
+ - include_stylesheet 'reader'
2
+
3
+ %p
4
+ Please enter your email address below. If we recognise it, we'll send you a message with a confirmation link (or if your account is not yet active, we'll send the activation message again).
5
+ %strong
6
+ Your password will not change until you fill in that form,
7
+ so only you can complete this process.
8
+
9
+ - if @error
10
+ %p.haserror
11
+ = @error
12
+
13
+ .password_form
14
+
15
+ - email = current_reader.email if current_reader
16
+ - form_tag password_reset_path, :class => 'friendly' do
17
+ %p
18
+ %label{:for => "email"}
19
+ Email address
20
+ %br
21
+ = text_field_tag 'email', email, :class => 'titular'
22
+
23
+ %p
24
+ = submit_tag 'send me instructions'
25
+
26
+ - content_for :breadcrumbs do
27
+ = link_to 'Home', '/'
28
+ &gt; Reset password
29
+
30
+ - content_for :pagetitle do
31
+ Reset your password
@@ -0,0 +1,34 @@
1
+ - purpose ||= false
2
+ - no_title ||= false
3
+
4
+
5
+ %div.activation_required
6
+ - unless no_title
7
+ %h2
8
+ - if purpose
9
+ = purpose + ','
10
+ please
11
+ - else
12
+ Please
13
+ activate your account
14
+
15
+ %p
16
+ Hello
17
+ = current_reader.name + '.'
18
+ - if current_reader
19
+ We've sent an email to
20
+ %strong
21
+ = current_reader.email
22
+ containing a link that will automatically activate your account and log you in. If you can't find the message, we can
23
+ = link_to("send it again", new_reader_activation_url) + '.'
24
+ - else
25
+ You should have received an email message
26
+ containing a link that will automatically activate your account and log you in. If you can't find the message, we can
27
+ = link_to("send it again", new_password_reset_url) + ':'
28
+ just put your email address in the password reminder form, and if your account has not been activated you'll receive another activation message.
29
+
30
+ - if Radiant::Config['reader.allow_registration?']
31
+ %p
32
+ If you've put the wrong email address in, the easiest thing to do is just to
33
+ = link_to 'register again', new_reader_url
34
+ with the right one. The failed registration will be purged after a week or so.
@@ -0,0 +1,4 @@
1
+ - if session[:return_to]
2
+ %p
3
+ Would you like to
4
+ = link_to ("return to the page you were looking at before you started registering", session[:return_to]) + '?'
@@ -0,0 +1,41 @@
1
+ = render :partial => 'readers/flasher'
2
+
3
+ - if current_reader && current_reader.activated?
4
+
5
+ %p
6
+ Thank you very much for persevering with the registration process. Your account is now active.
7
+
8
+ = render :partial => 'on_activation'
9
+
10
+ - content_for :pagetitle do
11
+ Hello
12
+ = current_reader.name
13
+
14
+ - else
15
+ %div.activation
16
+ %p
17
+ - if current_reader
18
+ Thank you for registering. Now please check your email. We have sent a message to
19
+ %strong
20
+ = current_reader.email
21
+ containing a link that will automatically activate your account and log you in. If you can't find the message, we can
22
+ = link_to("send it again", new_reader_activation_url) + '.'
23
+ - else
24
+ Please check your email. You should have received a message containing a link that will automatically activate your account and log you in. If you can't find the message, we can
25
+ = link_to("send it again", new_password_reset_url) + ':'
26
+ just put your email address in the password reminder form, and if your account has not been activated you'll receive another activation message.
27
+
28
+ - if Radiant::Config['reader.allow_registration?']
29
+ %p
30
+ If you think you might have put the wrong email address in, the easiest thing to do is
31
+ = link_to 'register again', new_reader_url
32
+ with the right one. The failed registration attempt will be purged after a week or so.
33
+
34
+ - content_for :pagetitle do
35
+ Activation message sent
36
+
37
+ - content_for :breadcrumbs do
38
+ = link_to 'Home', '/'
39
+ &gt;
40
+ Activate your account
41
+
@@ -0,0 +1 @@
1
+ = @message
@@ -0,0 +1,59 @@
1
+ - @reader_session ||= ReaderSession.new
2
+ - no_title ||= false
3
+ - purpose ||= false
4
+
5
+ .login_form
6
+ - cssclass = "compact friendly"
7
+ - cssclass << " inline" if @inline
8
+ - form_for @reader_session, :url => reader_session_path, :html => {:class => cssclass} do |f|
9
+
10
+ - unless no_title
11
+ %h2
12
+ - if purpose
13
+ = purpose + ','
14
+ please
15
+ - else
16
+ Please
17
+ log in or
18
+ = link_to "register", new_reader_url
19
+
20
+ - if @error
21
+ %p.haserror
22
+ Sorry: we don't recognise that combination of username and password.
23
+ %br
24
+ If you've forgotten your password we can always
25
+ = link_to 'make you a new one', repassword_url
26
+
27
+ %p{ :class => @reader_session.errors.on(:login) ? 'haserror' : '' }
28
+ %label{:for => "reader_session_login"}
29
+ Username
30
+ %br
31
+ = f.text_field :login, :class => 'login'
32
+ - if @reader_session.errors.on(:login)
33
+ %br
34
+ This
35
+ = @reader_session.errors.on(:login).to_a.to_sentence
36
+
37
+ %p{ :class => @reader_session.errors.on(:password) ? 'haserror' : '' }
38
+ %label{:for => "reader_session_password"}
39
+ Password
40
+ %br
41
+ = f.password_field :password, :class => 'login'
42
+ - if @reader_session.errors.on(:password)
43
+ %br
44
+ This
45
+ = @reader_session.errors.on(:password).to_a.to_sentence
46
+
47
+ %p.buttons
48
+ = f.submit ' Log in '
49
+ = f.check_box :remember_me
50
+ %label.paranthetical{:for => "reader_session_remember_me"}
51
+ Remember me
52
+
53
+ %p.quiet
54
+ - if Radiant::Config['reader.allow_registration?']
55
+ If you haven't already, you will need to
56
+ = link_to "register", new_reader_url
57
+ before you can log in. It only takes a moment.
58
+ If you've forgotten your password, you can enter your email address to
59
+ = link_to("set a new one", new_password_reset_url) + '.'
@@ -0,0 +1,38 @@
1
+ = render :partial => 'readers/flasher'
2
+
3
+ - if current_reader
4
+ %p
5
+ You are currently logged in as
6
+ %strong
7
+ = current_reader.name
8
+ - unless current_reader.activated?
9
+ but your account is not yet activated. Please check your email for our activation message.
10
+
11
+ - if current_reader.activated?
12
+ %p
13
+ If that's not you, or you want to log in with another account, please
14
+ = link_to "log out", reader_logout_url
15
+ - else
16
+ %p
17
+ If you can't find the message, we can
18
+ = link_to("send it again", new_reader_activation_url) + '.'
19
+ %p
20
+ If you're not
21
+ = current_reader.name
22
+ or you think you might have put the wrong email address in, please
23
+ = link_to "log out", reader_logout_url
24
+ and you will be able to register or log in normally.
25
+
26
+ - else
27
+ - if flash[:explanation]
28
+ %p
29
+ = flash[:explanation]
30
+
31
+ = render :partial => 'login_form', :locals => {:no_title => true}
32
+
33
+ - content_for :breadcrumbs do
34
+ = link_to 'Readers', '/readers'
35
+ &gt; Log in
36
+
37
+ - content_for :pagetitle do
38
+ Log in
@@ -0,0 +1,2 @@
1
+ // this page will be overridden in other extensions
2
+ // if there are ever more than a couple, a list of partials may be required
@@ -0,0 +1,25 @@
1
+ %div#reader_links
2
+ - if current_reader
3
+ - if current_reader.activated?
4
+ %p
5
+ %strong
6
+ Hello
7
+ = current_reader.name
8
+ %br
9
+ = link_to 'your page', reader_url(current_reader)
10
+ |
11
+ = link_to 'preferences', edit_reader_url(current_reader)
12
+ |
13
+ - if current_reader.is_user?
14
+ = link_to 'admin', admin_pages_url
15
+ |
16
+ = link_to 'log out', reader_logout_url
17
+ -else
18
+ %p
19
+ please check your email for an activation message
20
+ - else
21
+ %p
22
+ To take part, please
23
+ = link_to 'log in', reader_login_url
24
+ or
25
+ = link_to 'register', new_reader_url