active_scaffold_export 3.2.2 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "active_scaffold_export"
8
- s.version = "3.2.2"
8
+ s.version = "3.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Volker Hochstein", "Sergio Cambra", "Hernan Astudillo"]
12
- s.date = "2012-03-06"
12
+ s.date = "2012-12-13"
13
13
  s.description = "Exporting Records with ActiveScaffold"
14
14
  s.email = "activescaffold@googlegroups.com"
15
15
  s.extra_rdoc_files = [
@@ -21,15 +21,15 @@ Gem::Specification.new do |s|
21
21
  "LICENSE.txt",
22
22
  "README",
23
23
  "Rakefile",
24
+ "init.rb",
24
25
  "active_scaffold_export.gemspec",
25
26
  "app/assets/images/export.png",
26
27
  "app/assets/stylesheets/active_scaffold_export.css.erb",
27
28
  "app/assets/stylesheets/export-stylesheet-ie.css",
28
- "frontends/default/views/_export.csv.erb",
29
- "frontends/default/views/_export_form_body.html.erb",
30
- "frontends/default/views/_show_export.html.erb",
31
- "frontends/default/views/show_export.html.erb",
32
- "init.rb",
29
+ "app/views/active_scaffold_overrides/_export.csv.erb",
30
+ "app/views/active_scaffold_overrides/_export_form_body.html.erb",
31
+ "app/views/active_scaffold_overrides/_show_export.html.erb",
32
+ "app/views/active_scaffold_overrides/show_export.html.erb",
33
33
  "lib/active_scaffold/actions/export.rb",
34
34
  "lib/active_scaffold/config/export.rb",
35
35
  "lib/active_scaffold/helpers/export_helpers.rb",
@@ -53,14 +53,14 @@ Gem::Specification.new do |s|
53
53
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
54
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
55
55
  s.add_development_dependency(%q<rcov>, [">= 0"])
56
- s.add_runtime_dependency(%q<active_scaffold>, [">= 3.1"])
56
+ s.add_runtime_dependency 'active_scaffold', '>= 3.3.0.rc'
57
57
  else
58
58
  s.add_dependency(%q<active_scaffold>, [">= 0"])
59
59
  s.add_dependency(%q<shoulda>, [">= 0"])
60
60
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
61
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
62
62
  s.add_dependency(%q<rcov>, [">= 0"])
63
- s.add_dependency(%q<active_scaffold>, [">= 3.1"])
63
+ s.add_runtime_dependency 'active_scaffold', '>= 3.3.0.rc'
64
64
  end
65
65
  else
66
66
  s.add_dependency(%q<active_scaffold>, [">= 0"])
@@ -68,7 +68,7 @@ Gem::Specification.new do |s|
68
68
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
69
69
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
70
70
  s.add_dependency(%q<rcov>, [">= 0"])
71
- s.add_dependency(%q<active_scaffold>, ["~> 3.1"])
71
+ s.add_runtime_dependency 'active_scaffold', '>= 3.3.0.rc'
72
72
  end
73
73
  end
74
74
 
@@ -1,6 +1,5 @@
1
1
  .active-scaffold-header div.actions a.show_export {
2
2
  background-image: url(<%= asset_path 'export.png' %>);
3
- background-image: url(../../../images/active_scaffold/default/export.png);
4
3
  background-position: 1px 50%;
5
4
  background-repeat: no-repeat;
6
5
  padding-left: 19px;
@@ -1,4 +1,5 @@
1
1
  <% export_config = active_scaffold_config.export %>
2
+ <h3><%=as_(:columns_for_export)%></h3>
2
3
  <div class="columns checkbox-list">
3
4
  <% export_config.columns.each do |column| -%>
4
5
  <div class="column checkbox-wrapper">
@@ -8,20 +9,20 @@
8
9
  &nbsp;
9
10
  </div>
10
11
  <div class="separator"></div>
11
- <h3><%=as_('Options')%></h3>
12
+ <h3><%=as_(:options)%></h3>
12
13
  <div class="options checkbox-list">
13
14
  <div class="option checkbox-wrapper">
14
- <%= content_tag(:label, check_box_tag('skip_header', 1, export_config.default_skip_header) + " #{as_('Omit Header')}".html_safe) %>
15
+ <%= content_tag(:label, check_box_tag('skip_header', 1, export_config.default_skip_header) + " #{as_(:omit_header)}".html_safe) %>
15
16
  </div>
16
17
  <div class="option checkbox-wrapper">
17
- <%= content_tag(:label, text_field_tag('delimiter', export_config.default_delimiter, :size => 1, :maxlength => 1) + " #{as_('Delimiter')}".html_safe) %>
18
+ <%= content_tag(:label, text_field_tag('delimiter', export_config.default_delimiter, :size => 1, :maxlength => 1) + " #{as_(:delimiter)}".html_safe) %>
18
19
  </div>
19
20
  <div class="separator"></div>
20
21
  <div class="option checkbox-wrapper">
21
- <%= content_tag(:label, radio_button_tag('full_download', false, !export_config.default_full_download) + " #{as_('This Page')}".html_safe) if export_config.allow_full_download %>
22
+ <%= content_tag(:label, radio_button_tag('full_download', false, !export_config.default_full_download) + " #{as_(:this_page)}".html_safe) if export_config.allow_full_download %>
22
23
  </div>
23
24
  <div class="option checkbox-wrapper">
24
- <%= content_tag(:label, radio_button_tag('full_download', true, export_config.default_full_download) + " #{as_('All Pages')}".html_safe) if export_config.allow_full_download %>
25
+ <%= content_tag(:label, radio_button_tag('full_download', true, export_config.default_full_download) + " #{as_(:all_pages)}".html_safe) if export_config.allow_full_download %>
25
26
  </div>
26
27
  &nbsp;
27
28
  </div>
@@ -3,5 +3,5 @@
3
3
  :url_options => params_for(:action => :export, :format => 'csv'),
4
4
  :method => :post,
5
5
  :cancel_link => true,
6
- :headline => as_('Columns to Export'),
6
+ :headline => as_(:export),
7
7
  :body_partial => 'export_form_body'} %>
@@ -4,10 +4,6 @@ module ActiveScaffold::Actions
4
4
  base.before_filter :export_authorized?, :only => [:export]
5
5
  base.before_filter :show_export_authorized?, :only => [:show_export]
6
6
  base.before_filter :init_session_var
7
-
8
- as_export_plugin_path = File.join(ActiveScaffold::Config::Export.plugin_directory, 'frontends', 'default' , 'views')
9
-
10
- base.add_active_scaffold_path as_export_plugin_path
11
7
  end
12
8
 
13
9
  def init_session_var
@@ -44,38 +40,61 @@ module ActiveScaffold::Actions
44
40
  params.merge!(options)
45
41
  end
46
42
 
47
- find_items_for_export
43
+ # this is required if you want this to work with IE
44
+ if request.env['HTTP_USER_AGENT'] =~ /msie/i
45
+ response.headers['Pragma'] = "public"
46
+ response.headers['Cache-Control'] = "no-cache, must-revalidate, post-check=0, pre-check=0"
47
+ response.headers['Expires'] = "0"
48
+ end
48
49
 
50
+ response.headers['Content-type'] = 'text/csv'
49
51
  response.headers['Content-Disposition'] = "attachment; filename=#{export_file_name}"
50
- render :partial => 'export', :layout => false, :content_type => Mime::CSV, :status => response_status
52
+
53
+ @export_columns = export_config.columns.reject { |col| params[:export_columns][col.name.to_sym].nil? }
54
+ includes_for_export_columns = @export_columns.collect{ |col| col.includes }.flatten.uniq.compact
55
+ self.active_scaffold_includes.concat includes_for_export_columns
56
+ @export_config = export_config
57
+
58
+ # start streaming output
59
+ self.response_body = Enumerator.new do |y|
60
+ find_items_for_export do |records|
61
+ @records = records
62
+ str = render_to_string :partial => 'export', :layout => false, :formats => [:csv]
63
+ y << str
64
+ params[:skip_header] = 'true' # skip header on the next run
65
+ end
66
+ end
51
67
  end
52
68
 
53
69
  protected
54
-
55
70
  # The actual algorithm to do the export
56
- def find_items_for_export
57
- export_config = active_scaffold_config.export
58
- export_columns = export_config.columns.reject { |col| params[:export_columns][col.name.to_sym].nil? }
59
-
60
- includes_for_export_columns = export_columns.collect{ |col| col.includes }.flatten.uniq.compact
61
- self.active_scaffold_includes.concat includes_for_export_columns
62
-
63
- find_options = { :sorting => active_scaffold_config.list.user.sorting }
71
+ def find_items_for_export(&block)
72
+ find_options = { :sorting =>
73
+ active_scaffold_config.list.user.sorting.nil? ?
74
+ active_scaffold_config.list.sorting : active_scaffold_config.list.user.sorting,
75
+ :pagination => true
76
+ }
64
77
  params[:search] = session[:search]
65
78
  do_search rescue nil
66
79
  params[:segment_id] = session[:segment_id]
67
80
  do_segment_search rescue nil
68
- unless params[:full_download] == 'true'
81
+
82
+ if params[:full_download] == 'true'
83
+ find_options.merge!({
84
+ :per_page => 3000,
85
+ :page => 1
86
+ })
87
+ find_page(find_options).pager.each do |page|
88
+ yield page.items
89
+ end
90
+ else
69
91
  find_options.merge!({
70
92
  :pagination => active_scaffold_config.list.pagination,
71
93
  :per_page => active_scaffold_config.list.user.per_page,
72
94
  :page => active_scaffold_config.list.user.page
73
95
  })
96
+ yield find_page(find_options).items
74
97
  end
75
-
76
- @export_config = export_config
77
- @export_columns = export_columns
78
- @records = find_page(find_options).items
79
98
  end
80
99
 
81
100
  # The default name of the downloaded file.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-03-06 00:00:00.000000000 Z
14
+ date: 2012-12-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: active_scaffold
18
- requirement: &9653600 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,15 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *9653600
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: shoulda
29
- requirement: &9653080 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
30
35
  none: false
31
36
  requirements:
32
37
  - - ! '>='
@@ -34,10 +39,15 @@ dependencies:
34
39
  version: '0'
35
40
  type: :development
36
41
  prerelease: false
37
- version_requirements: *9653080
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: bundler
40
- requirement: &9652460 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ~>
@@ -45,10 +55,15 @@ dependencies:
45
55
  version: 1.0.0
46
56
  type: :development
47
57
  prerelease: false
48
- version_requirements: *9652460
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: 1.0.0
49
64
  - !ruby/object:Gem::Dependency
50
65
  name: jeweler
51
- requirement: &9667340 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ~>
@@ -56,10 +71,15 @@ dependencies:
56
71
  version: 1.6.4
57
72
  type: :development
58
73
  prerelease: false
59
- version_requirements: *9667340
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 1.6.4
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: rcov
62
- requirement: &9664500 !ruby/object:Gem::Requirement
82
+ requirement: !ruby/object:Gem::Requirement
63
83
  none: false
64
84
  requirements:
65
85
  - - ! '>='
@@ -67,18 +87,28 @@ dependencies:
67
87
  version: '0'
68
88
  type: :development
69
89
  prerelease: false
70
- version_requirements: *9664500
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
71
96
  - !ruby/object:Gem::Dependency
72
97
  name: active_scaffold
73
- requirement: &9662440 !ruby/object:Gem::Requirement
98
+ requirement: !ruby/object:Gem::Requirement
74
99
  none: false
75
100
  requirements:
76
101
  - - ! '>='
77
102
  - !ruby/object:Gem::Version
78
- version: '3.1'
103
+ version: 3.3.0.rc
79
104
  type: :runtime
80
105
  prerelease: false
81
- version_requirements: *9662440
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: 3.3.0.rc
82
112
  description: Exporting Records with ActiveScaffold
83
113
  email: activescaffold@googlegroups.com
84
114
  executables: []
@@ -91,15 +121,15 @@ files:
91
121
  - LICENSE.txt
92
122
  - README
93
123
  - Rakefile
124
+ - init.rb
94
125
  - active_scaffold_export.gemspec
95
126
  - app/assets/images/export.png
96
127
  - app/assets/stylesheets/active_scaffold_export.css.erb
97
128
  - app/assets/stylesheets/export-stylesheet-ie.css
98
- - frontends/default/views/_export.csv.erb
99
- - frontends/default/views/_export_form_body.html.erb
100
- - frontends/default/views/_show_export.html.erb
101
- - frontends/default/views/show_export.html.erb
102
- - init.rb
129
+ - app/views/active_scaffold_overrides/_export.csv.erb
130
+ - app/views/active_scaffold_overrides/_export_form_body.html.erb
131
+ - app/views/active_scaffold_overrides/_show_export.html.erb
132
+ - app/views/active_scaffold_overrides/show_export.html.erb
103
133
  - lib/active_scaffold/actions/export.rb
104
134
  - lib/active_scaffold/config/export.rb
105
135
  - lib/active_scaffold/helpers/export_helpers.rb
@@ -128,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
158
  version: '0'
129
159
  requirements: []
130
160
  rubyforge_project:
131
- rubygems_version: 1.8.10
161
+ rubygems_version: 1.8.24
132
162
  signing_key:
133
163
  specification_version: 3
134
164
  summary: Ability to export records to CSV with ActiveScaffold