radiant-reader-extension 1.1.1 → 1.2.0

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.
data/README.md CHANGED
@@ -10,10 +10,10 @@ The purpose of this extension is to provide a common core that supports other vi
10
10
 
11
11
  ## Latest
12
12
 
13
- * **currently requires the `preconfiguration` branch of radiant**
14
- * public interface internationalized
15
- * New configuration interface
16
- * Messaging much simplified: now intended to be purely administrative.
13
+ * everything updated for 0.9.x
14
+ * public interface internationalized;
15
+ * Uses the new configuration interface;
16
+ * Messaging much simplified and now intended to be purely administrative.
17
17
 
18
18
  ## Status
19
19
 
@@ -21,7 +21,7 @@ Compatible with radiant 0.9.2, which isn't out yet. You can use the preconfigura
21
21
 
22
22
  ## Requirements
23
23
 
24
- Radiant 0.9.2. The [layouts](http://github.com/squaretalent/radiant-layouts-extension) and [mailer_layouts](http://github.com/spanner/radiant-mailer_layouts-extension) extensions.
24
+ Radiant 0.9.2 (or currently, edge). The [layouts](http://github.com/squaretalent/radiant-layouts-extension) and [mailer_layouts](http://github.com/spanner/radiant-mailer_layouts-extension) extensions.
25
25
 
26
26
  You also need three gems (in addition to those that radiant requires): authlogic, gravtastic and sanitize. They're declared in the extension so you should be able just to run
27
27
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.2.0
@@ -1,4 +1,5 @@
1
1
  class Admin::MessagesController < Admin::ResourceController
2
+ helper :reader
2
3
  skip_before_filter :load_model
3
4
  before_filter :load_model, :except => :index # we want the filter to run before :show too
4
5
  before_filter :set_function, :only => :new
@@ -1,3 +1,4 @@
1
1
  class Admin::ReaderConfigurationController < Admin::ConfigurationController
2
+ helper :reader
2
3
 
3
4
  end
@@ -1,4 +1,5 @@
1
1
  class Admin::ReadersController < Admin::ResourceController
2
+ helper :reader
2
3
  paginate_models
3
4
  before_filter :redirect_to_user, :only => :edit
4
5
 
@@ -1,4 +1,5 @@
1
1
  class MessagesController < ReaderActionController
2
+ helper :reader
2
3
 
3
4
  before_filter :require_reader
4
5
  before_filter :get_messages, :only => [:index]
@@ -1,4 +1,5 @@
1
1
  class PasswordResetsController < ApplicationController
2
+ helper :reader
2
3
 
3
4
  # rest gone mad! but it works, and keeps the processes well-defined.
4
5
 
@@ -1,4 +1,5 @@
1
1
  class ReaderActionController < ApplicationController
2
+ helper :reader
2
3
  helper_method :current_site, :current_site=, :logged_in?, :logged_in_user?, :logged_in_admin?
3
4
 
4
5
  no_login_required
@@ -1,4 +1,5 @@
1
1
  class ReaderActivationsController < ReaderActionController
2
+ helper :reader
2
3
 
3
4
  no_login_required
4
5
  skip_before_filter :require_reader
@@ -1,4 +1,5 @@
1
1
  class ReaderSessionsController < ReaderActionController
2
+ helper :reader
2
3
 
3
4
  before_filter :require_reader, :only => :destroy
4
5
  radiant_layout { |controller| Radiant::Config['reader.layout'] }
@@ -1,4 +1,6 @@
1
1
  class ReadersController < ReaderActionController
2
+ helper :reader
3
+
2
4
  @@extended_form_partials = []
3
5
  cattr_accessor :extended_form_partials
4
6
 
@@ -51,7 +53,7 @@ class ReadersController < ReaderActionController
51
53
  unless @reader.email.blank?
52
54
  flash[:error] = t('please_avoid_spam_trap')
53
55
  @reader.email = ''
54
- @reader.errors.add(:trap, "must_be_empty")
56
+ @reader.errors.add(:trap, t("must_be_empty"))
55
57
  render :action => 'new' and return
56
58
  end
57
59
 
@@ -75,7 +77,7 @@ class ReadersController < ReaderActionController
75
77
  @reader.attributes = params[:reader]
76
78
  @reader.clear_password = params[:reader][:password] if params[:reader][:password]
77
79
  if @reader.save
78
- flash[:notice] = 'account_updated'
80
+ flash[:notice] = t('account_updated')
79
81
  redirect_to url_for(@reader)
80
82
  else
81
83
  render :action => 'edit'
@@ -89,7 +91,7 @@ protected
89
91
  end
90
92
 
91
93
  def restrict_to_self
92
- flash[:error] = "cannot_edit_others" if params[:id] && params[:id] != current_reader.id
94
+ flash[:error] = t("cannot_edit_others") if params[:id] && params[:id] != current_reader.id
93
95
  @reader = current_reader
94
96
  end
95
97
 
@@ -100,19 +102,19 @@ protected
100
102
  @reader.attributes = params[:reader]
101
103
  @reader.valid?
102
104
 
103
- flash[:error] = 'password_incorrect'
105
+ flash[:error] = t('password_incorrect')
104
106
  @reader.errors.add(:current_password, "not_correct")
105
107
  render :action => 'edit' and return false
106
108
  end
107
109
 
108
110
  def no_removing
109
- flash[:error] = 'cannot_delete_readers'
111
+ flash[:error] = t('cannot_delete_readers')
110
112
  redirect_to admin_readers_url
111
113
  end
112
114
 
113
115
  def check_registration_allowed
114
116
  unless Radiant::Config['reader.allow_registration?']
115
- flash[:error] = "registration_disallowed"
117
+ flash[:error] = t("registration_disallowed")
116
118
  redirect_to reader_login_url
117
119
  false
118
120
  end
@@ -1,6 +1,5 @@
1
1
  require 'authlogic'
2
2
  require 'digest/sha1'
3
- require 'gravtastic'
4
3
 
5
4
  class Reader < ActiveRecord::Base
6
5
  @@user_columns = [:name, :email, :login, :created_at, :password, :notes]
@@ -10,7 +9,6 @@ class Reader < ActiveRecord::Base
10
9
 
11
10
  is_site_scoped if respond_to? :is_site_scoped
12
11
 
13
- is_gravtastic :with => :email, :rating => 'PG', :size => 48
14
12
  acts_as_authentic do |config|
15
13
  config.validations_scope = :site_id if defined? Site
16
14
  config.transition_from_restful_authentication = true
@@ -1,14 +1,13 @@
1
1
  - body_classes << "reversed"
2
2
  - include_stylesheet('admin/reader')
3
3
 
4
- #reader_settings.box
5
- %h3
6
- .actions
7
- = button_to t("edit"), edit_admin_reader_configuration_url, :method => :get
8
- =t("reader_admin")
9
-
10
- - render_region :settings do |settings|
11
- - settings.registration do
4
+ - render_region :settings do |settings|
5
+ - settings.administration do
6
+ #reader_settings.box
7
+ %h3
8
+ .actions
9
+ = button_to t("edit"), edit_admin_reader_configuration_url, :method => :get
10
+ =t("reader_admin")
12
11
  %p.ruled
13
12
  = show_config 'reader.allow_registration?'
14
13
  %p.ruled
@@ -17,8 +16,6 @@
17
16
  = show_config 'reader.use_honorifics?'
18
17
  %p.ruled
19
18
  = show_config 'reader.layout'
20
-
21
- - settings.sender do
22
19
  %p.ruled
23
20
  = show_config 'email.name'
24
21
  %p.ruled
@@ -28,12 +25,12 @@
28
25
  %p.ruled
29
26
  = show_config 'email.layout'
30
27
 
31
- #message_settings.box
32
- %h4
33
- =t("reader_emails")
28
+ - render_region :messages do |messages|
29
+ - messages.administration do
30
+ #message_settings.box
31
+ %h3
32
+ =t("reader_emails")
34
33
 
35
- - render_region :messages do |messages|
36
- - messages.administration do
37
34
  - MessageFunction.find_all.each do |func|
38
35
  - message = Message.functional(func)
39
36
  %p.ruled
@@ -0,0 +1,4 @@
1
+ %h2
2
+ = t('activation_required_header')
3
+ %p
4
+ = t('activation_required_explanation')
@@ -16,7 +16,7 @@
16
16
  %div.activation
17
17
  - if @error
18
18
  %p.errornotice
19
- = t(@error)
19
+ = @error
20
20
  %p
21
21
  = t('thanks_and_activation_instructions')
22
22
  = link_to("resend_activation", new_reader_activation_url) + '.'
@@ -3,7 +3,7 @@
3
3
 
4
4
  - if current_reader
5
5
  %p
6
- = t('logged_in_as')
6
+ = t('reader_logged_in_as')
7
7
  %strong
8
8
  = current_reader.name
9
9
  - unless current_reader.activated?
@@ -35,11 +35,12 @@
35
35
  %br
36
36
  = f.text_field :email, :class => 'standard'
37
37
 
38
- %p
39
- = f.label :description, t('your_description'), :class => 'optional'
40
- %span.formnote= t('description_notes')
41
- %br
42
- = f.text_area :description, :class => 'standard', :rows => 8
38
+ - if Radiant::Config['reader.use_description?']
39
+ %p
40
+ = f.label :description, t('your_description'), :class => 'optional'
41
+ %span.formnote= t('description_notes')
42
+ %br
43
+ = f.text_area :description, :class => 'standard', :rows => 8
43
44
 
44
45
  %p
45
46
  = f.label :login, t('login_name'), :class => 'optional'
@@ -42,4 +42,4 @@
42
42
  = t('account_settings')
43
43
 
44
44
  - content_for :title do
45
- = t('account_settings')
45
+ = t('account')
@@ -5,6 +5,8 @@ en:
5
5
  activate_account: "Activate your account"
6
6
  activation_complete: "Thank you very much for persevering with the registration process. Your account is now active."
7
7
  activation_message_sent: "Account activation instructions have been emailed to you."
8
+ activation_required_header: "Please check your email"
9
+ activation_required_explanation: "You should have received a confirmation message containing a link that will activate your account."
8
10
  activation_sent: "Activation message sent"
9
11
  already_active: "Your account is already active."
10
12
  already_logged_in: "You're already logged in!"
@@ -50,6 +52,7 @@ en:
50
52
  honorific: "Title or rank"
51
53
  honorific_notes: ""
52
54
  invitation_message: "Invitation message"
55
+ invite_description: '<a href="%{url}">Edit your preferences to put some text about yourself here.'
53
56
  if_cant_find: "If you can't find the message, we can"
54
57
  if_mistake_see_admin: "If this is a mistake, please talk to the site administrator about your account."
55
58
  is_free_and_quick: " is free and only takes a moment"
@@ -64,7 +67,7 @@ en:
64
67
  new_account: "Register"
65
68
  new_password: "New password"
66
69
  new_password_instructions: "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."
67
- no: "no"
70
+ 'no': "no"
68
71
  no_description: "No description available"
69
72
  notes: "notes"
70
73
  page_permission_denied: "You don't have permission to see the page that you have requested."
@@ -90,6 +93,7 @@ en:
90
93
  reader_admin: "Reader administration"
91
94
  reader_emails: "Administrative messages"
92
95
  reader: 'Reader'
96
+ reader_logged_in_as: "You are logged in as %{name}."
93
97
  readers: 'Readers'
94
98
  register: "register"
95
99
  registration: "registration"
@@ -116,7 +120,7 @@ en:
116
120
  welcome_back: "Welcome back"
117
121
  welcome_message: "Welcome message"
118
122
  wrong_email: "you think you might have put the wrong email address in,"
119
- yes: "yes"
123
+ 'yes': "yes"
120
124
  your_description: "A little about yourself"
121
125
  your_email: "Your email address"
122
126
  your_name: "Your name"
@@ -41,7 +41,7 @@ module ReaderAdminUI
41
41
  def load_default_reader_configuration_regions
42
42
  returning OpenStruct.new do |reader_configuration|
43
43
  reader_configuration.show = Radiant::AdminUI::RegionSet.new do |show|
44
- show.settings.concat %w{registration sender}
44
+ show.settings.concat %w{administration}
45
45
  show.messages.concat %w{administration}
46
46
  end
47
47
  reader_configuration.edit = Radiant::AdminUI::RegionSet.new do |edit|
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-reader-extension}
8
- s.version = "1.1.1"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["spanner"]
12
- s.date = %q{2010-11-01}
12
+ s.date = %q{2010-11-15}
13
13
  s.description = %q{Centralises reader/member/user registration and management tasks for the benefit of other extensions}
14
14
  s.email = %q{will@spanner.org}
15
15
  s.extra_rdoc_files = [
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
59
59
  "app/views/password_resets/create.html.haml",
60
60
  "app/views/password_resets/edit.html.haml",
61
61
  "app/views/password_resets/new.html.haml",
62
+ "app/views/reader_activations/_activation_required.haml",
62
63
  "app/views/reader_activations/show.html.haml",
63
64
  "app/views/reader_notifier/message.html.haml",
64
65
  "app/views/reader_sessions/_login_form.html.haml",
@@ -94,13 +95,10 @@ Gem::Specification.new do |s|
94
95
  "db/migrate/20091111090819_ensure_functional_messages_visible.rb",
95
96
  "db/migrate/20091119092936_messages_have_layout.rb",
96
97
  "db/migrate/20100922152338_lock_versions.rb",
97
- "db/migrate/20100927095703_default_settings.rb",
98
98
  "db/migrate/20101004074945_unlock_version.rb",
99
99
  "db/migrate/20101019094714_message_sent_date.rb",
100
- "lib/config_extensions.rb",
101
100
  "lib/controller_extensions.rb",
102
101
  "lib/reader_admin_ui.rb",
103
- "lib/reader_helper.rb",
104
102
  "lib/reader_site.rb",
105
103
  "lib/reader_tags.rb",
106
104
  "lib/rfc822.rb",
@@ -1,32 +1,27 @@
1
1
  require_dependency 'application_controller'
2
2
 
3
3
  class ReaderExtension < Radiant::Extension
4
- version "1.1.1"
4
+ version "1.2.0"
5
5
  description "Provides reader/member/user registration and management functions"
6
6
  url "http://spanner.org/radiant/reader"
7
7
 
8
8
  extension_config do |config|
9
9
  config.gem 'authlogic'
10
10
  config.gem 'sanitize'
11
- config.gem 'will_paginate'
12
11
  end
13
12
 
14
13
  def activate
15
14
  Reader
16
15
  ApplicationController.send :include, ControllerExtensions # hooks up reader authentication and layout-chooser
17
- ApplicationHelper.send :include, ReaderHelper # display usefulness including error-wrapper
16
+ ApplicationHelper.send :include, ReaderHelper # display usefulness included generally so as to bavailable in sitecontroller
18
17
  Site.send :include, ReaderSite if defined? Site # adds site scope and site-based layout-chooser
19
18
  Page.send :include, ReaderTags # a few mailmerge-like radius tags for use in messages, or for greeting readers on (uncached) pages
20
- Radiant::Config.send :include, ConfigExtensions # .boolean?
21
19
  UserActionObserver.instance.send :add_observer!, Reader
22
20
  UserActionObserver.instance.send :add_observer!, Message
23
21
 
24
22
  unless defined? admin.reader
25
23
  Radiant::AdminUI.send :include, ReaderAdminUI
26
24
  Radiant::AdminUI.load_reader_extension_regions
27
- if defined? admin.sites
28
- admin.sites.edit.add :form, "admin/sites/choose_reader_layout", :after => "edit_homepage"
29
- end
30
25
  end
31
26
 
32
27
  if respond_to?(:tab)
@@ -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 =~ /cannot_edit_others/
94
+ flash[:error].should =~ /other people's accounts/
95
95
  end
96
96
 
97
97
  it "should not remove this reader" do
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: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
8
+ - 2
9
+ - 0
10
+ version: 1.2.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-11-01 00:00:00 +00:00
18
+ date: 2010-11-15 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -142,6 +142,7 @@ files:
142
142
  - app/views/password_resets/create.html.haml
143
143
  - app/views/password_resets/edit.html.haml
144
144
  - app/views/password_resets/new.html.haml
145
+ - app/views/reader_activations/_activation_required.haml
145
146
  - app/views/reader_activations/show.html.haml
146
147
  - app/views/reader_notifier/message.html.haml
147
148
  - app/views/reader_sessions/_login_form.html.haml
@@ -177,13 +178,10 @@ files:
177
178
  - db/migrate/20091111090819_ensure_functional_messages_visible.rb
178
179
  - db/migrate/20091119092936_messages_have_layout.rb
179
180
  - db/migrate/20100922152338_lock_versions.rb
180
- - db/migrate/20100927095703_default_settings.rb
181
181
  - db/migrate/20101004074945_unlock_version.rb
182
182
  - db/migrate/20101019094714_message_sent_date.rb
183
- - lib/config_extensions.rb
184
183
  - lib/controller_extensions.rb
185
184
  - lib/reader_admin_ui.rb
186
- - lib/reader_helper.rb
187
185
  - lib/reader_site.rb
188
186
  - lib/reader_tags.rb
189
187
  - lib/rfc822.rb
@@ -1,14 +0,0 @@
1
- class DefaultSettings < ActiveRecord::Migration
2
- def self.up
3
- Radiant::Config['reader.allow_registration?'] ||= true
4
- Radiant::Config['reader.require_confirmation?'] ||= true
5
- Radiant::Config['site.url'] ||= 'www.example.com'
6
- Radiant::Config['site.title'] ||= 'Your site name here'
7
- Radiant::Config['reader.mail_from_name'] ||= "Administrator"
8
- Radiant::Config['reader.mail_from_address'] ||= "admin@example.com"
9
- Radiant::Config['reader.layout'] ||= 'undefined'
10
- end
11
-
12
- def self.down
13
- end
14
- end
@@ -1,5 +0,0 @@
1
- module ConfigExtensions # for inclusion into Radiant::Config
2
- def boolean?
3
- key.ends_with? "?"
4
- end
5
- end
@@ -1,35 +0,0 @@
1
- require 'sanitize'
2
- module ReaderHelper
3
- def self.included(base)
4
-
5
- base.module_eval do
6
- def gravatar_for(reader, gravatar_options={}, img_options ={})
7
- size = gravatar_options[:size]
8
- img_options[:size] = "#{size}x#{size}" if size
9
- image_tag reader.gravatar_url(gravatar_options), img_options
10
- end
11
-
12
- def clean_textilize(text)
13
- Sanitize.clean(textilize(text), Sanitize::Config::RELAXED)
14
- end
15
-
16
- def clean_textilize_without_paragraph(text)
17
- textiled = clean_textilize(text)
18
- if textiled[0..2] == "<p>" then textiled = textiled[3..-1] end
19
- if textiled[-4..-1] == "</p>" then textiled = textiled[0..-5] end
20
- return textiled
21
- end
22
-
23
- def truncate_words(text='', length=64, omission="...")
24
- return '' if text.blank?
25
- words = text.split
26
- omission = '' unless words.size > length
27
- words[0..(length-1)].join(" ") + omission
28
- end
29
-
30
- def truncate_and_textilize(text, length=64)
31
- clean_textilize( truncate_words(text, length) )
32
- end
33
- end
34
- end
35
- end