radiant-reader-extension 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,10 +17,10 @@ class AccountsController < ReaderActionController
17
17
  render :template => 'readers/index'
18
18
  }
19
19
  format.csv {
20
- send_data generate_csv(@readers), :type => 'text/csv; charset=utf-8; header=present', :filename => "everyone.csv"
20
+ send_data Reader.csv_for(@readers), :type => 'text/csv; charset=utf-8; header=present', :filename => "everyone.csv"
21
21
  }
22
22
  format.vcard {
23
- send_data @readers.map(&:vcard).join("\n"), :filename => "everyone.vcf"
23
+ send_data Reader.vcards_for(@readers), :filename => "everyone.vcf"
24
24
  }
25
25
  end
26
26
  end
@@ -13,10 +13,10 @@ class GroupsController < ReaderActionController
13
13
  respond_to do |format|
14
14
  format.html
15
15
  format.csv {
16
- send_data generate_csv(@readers), :type => 'text/csv; charset=utf-8; header=present', :filename => "#{@group.filename}.csv"
16
+ send_data Reader.csv_for(@readers), :type => 'text/csv; charset=utf-8; header=present', :filename => "#{@group.filename}.csv"
17
17
  }
18
18
  format.vcard {
19
- send_data generate_vcard(@readers), :filename => "#{@group.filename}.vcf"
19
+ send_data Reader.vcards_for(@readers), :filename => "everyone.vcf"
20
20
  }
21
21
  end
22
22
  end
@@ -34,4 +34,16 @@ private
34
34
  end
35
35
  end
36
36
 
37
+ def generate_csv(readers=[])
38
+ columns = %w{forename surname email phone mobile postal_address}
39
+ table = FasterCSV.generate do |csv|
40
+ csv << columns.map { |f| t("activerecord.attributes.reader.#{f}") }
41
+ readers.each { |r| csv << columns.map{ |f| r.send(f.to_sym) } }
42
+ end
43
+ end
44
+
45
+ def generate_vcard(readers=[])
46
+ readers.map(&:vcard).join("\n")
47
+ end
48
+
37
49
  end
@@ -1,6 +1,5 @@
1
1
  require 'sanitize'
2
2
  require "sanitize/config/generous"
3
- require "fastercsv"
4
3
  require "snail_helpers"
5
4
 
6
5
  module ReaderHelper
@@ -155,15 +154,4 @@ EOM
155
154
  mail_to address, nil, :encode => :hex, :replace_at => ' at ', :class => 'mailto'
156
155
  end
157
156
 
158
- def generate_csv(readers=[])
159
- columns = %w{forename surname email phone mobile postal_address}
160
- table = FasterCSV.generate do |csv|
161
- csv << columns.map { |f| t("activerecord.attributes.reader.#{f}") }
162
- readers.each { |r| csv << columns.map{ |f| r.send(f.to_sym) } }
163
- end
164
- end
165
-
166
- def generate_vcard(readers=[])
167
- readers.map(&:vcard).join("\n")
168
- end
169
157
  end
data/app/models/reader.rb CHANGED
@@ -2,6 +2,7 @@ require 'authlogic'
2
2
  require 'digest/sha1'
3
3
  require 'snail'
4
4
  require 'vcard'
5
+ require "fastercsv"
5
6
 
6
7
  class Reader < ActiveRecord::Base
7
8
  @@user_columns = [:name, :email, :login, :created_at, :password, :notes]
@@ -261,6 +262,24 @@ class Reader < ActiveRecord::Base
261
262
  end
262
263
  end
263
264
 
265
+ # Generates a csv file listing the supplied group of readers.
266
+ # No access checks are performed here.
267
+ #
268
+ def self.csv_for(readers=[])
269
+ columns = %w{forename surname email phone mobile postal_address}
270
+ FasterCSV.generate do |csv|
271
+ csv << columns.map { |f| I18n.t("activerecord.attributes.reader.#{f}") }
272
+ readers.each { |r| csv << columns.map{ |f| r.send(f.to_sym) } }
273
+ end
274
+ end
275
+
276
+ # Generates a vcard file containing the supplied group of readers.
277
+ # No access checks are performed here.
278
+ #
279
+ def self.vcards_for(readers=[])
280
+ readers.map(&:vcard).join("\n")
281
+ end
282
+
264
283
  private
265
284
 
266
285
  def email_must_not_be_in_use
@@ -4,7 +4,7 @@
4
4
  - form_for reader, :html => {:class => 'friendly'} do |f|
5
5
  %input{:type => :hidden, :name => :authentication_type, :value => :user}
6
6
 
7
- - if 1 || Radiant::Config['reader.use_honorifics?']
7
+ - if Radiant.config['reader.use_honorifics?']
8
8
  %p
9
9
  = f.label :honorific, nil, :class => 'optional'
10
10
  %br
@@ -29,7 +29,7 @@
29
29
  %br
30
30
  %span.formnote= t('reader_extension.form_notes.account.post_country')
31
31
 
32
- - if Radiant::Config['reader.postal.use_organisation?']
32
+ - if Radiant.config['reader.postal.use_organisation?']
33
33
  %p
34
34
  = f.label :post_organisation, nil, :class => 'optional'
35
35
  = f.text_field :post_organisation, :class => 'standard'
@@ -55,7 +55,7 @@
55
55
  %p
56
56
  = f.label :description, nil, :class => 'optional'
57
57
  %br
58
- = f.text_area :description, :class => Radiant::Config['forum.toolbar?'] ? 'rte' : 'standard'
58
+ = f.text_area :description, :class => Radiant.config['forum.toolbar?'] ? 'rte' : 'standard'
59
59
  %span.formnote= t('reader_extension.form_notes.account.description')
60
60
 
61
61
  %p
@@ -1 +1 @@
1
- Mime::Type.register "text/x-vcard", :vcard unless Mime::Type.lookup(:vcard)
1
+ Mime::Type.register "text/x-vcard", :vcard
@@ -1,5 +1,5 @@
1
1
  module RadiantReaderExtension
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  SUMMARY = %q{Reader/viewer/visitor registration, login and access-control for Radiant CMS}
4
4
  DESCRIPTION = %q{Provides reader/member/user registration and management functions including password-reminder, group-based page access control and administrative email.}
5
5
  URL = "http://radiant.spanner.org/reader"
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: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 0
10
- version: 3.0.0
9
+ - 1
10
+ version: 3.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - William Ross
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-06 00:00:00 +01:00
18
+ date: 2011-09-07 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -322,7 +322,6 @@ files:
322
322
  - public/stylesheets/sass/admin/reader.sass
323
323
  - public/stylesheets/sass/admin/reader_group.sass
324
324
  - public/stylesheets/sass/reader.sass
325
- - radiant-reader-extension-3.0.0.gem
326
325
  - radiant-reader-extension.gemspec
327
326
  - Rakefile
328
327
  - reader_extension.rb
@@ -351,7 +350,7 @@ has_rdoc: true
351
350
  homepage: http://radiant.spanner.org/reader
352
351
  licenses: []
353
352
 
354
- post_install_message: "\n Add this to your radiant project with:\n\n config.gem 'radiant-reader-extension', :version => '~> 3.0.0'\n\n and if you haven't already, remember to enable ActionMailer in your\n project's config/environment.rb.\n "
353
+ post_install_message: "\n Add this to your radiant project with:\n\n config.gem 'radiant-reader-extension', :version => '~> 3.0.1'\n\n and if you haven't already, remember to enable ActionMailer in your\n project's config/environment.rb.\n "
355
354
  rdoc_options: []
356
355
 
357
356
  require_paths: