active_scaffold_export 3.0.6 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e9f7f034474f62c9c156d57118a1cf6c36b8f704d3e3d39b9df7ca352c238d4a
4
+ data.tar.gz: f1d0c02ad1a4e503a00bc55459771a6853597cc99b5e1c869b22a11fc8539f43
5
+ SHA512:
6
+ metadata.gz: 428f1456d4c2c96d756bc1bc9007de918233d6fb5104e4915a329a64a9e09e434db5c0e29babec790ba7facc4539d928c02d890e48dc1416fe96a8315a9baccd
7
+ data.tar.gz: a4cd29b6d36228116cb2064592b8323a26aea1689fb27d6119432775b1f611474138adadfd1f27c2d147f44c69e8c4b16ba8855aa47e39cd1eac3c9306bceeae
@@ -1,5 +1,4 @@
1
- Copyright (c) 2010 MojoTech, LLC
2
- Copyright (c) 2011 vhochstein
1
+ Copyright (c) 2011 naaano
3
2
 
4
3
  Permission is hereby granted, free of charge, to any person obtaining
5
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,70 @@
1
+ # Active Scaffold Export
2
+ ### An [active scaffold](https://github.com/activescaffold/active_scaffold) addon to let it export data in CSV or XLSX format
3
+
4
+ ####How to?
5
+ Easy. First get [active scaffold](https://github.com/activescaffold/active_scaffold) if you haven't yet.
6
+ Then, add this to your Gemfile:
7
+ ```
8
+ gem 'active_scaffold_export'
9
+ ```
10
+ if you're using REE or Ruby 1.8.7, you need to add backports gem as well as fastercsv since REE lacks ruby 1.9 streaming features and fastercsv is in core in 1.9
11
+ ```
12
+ gem 'backports'
13
+ gem 'fastercsv'
14
+ ```
15
+ if you want xlsx format, add:
16
+ ```
17
+ gem 'axlsx_rails'
18
+ ```
19
+ if that gem is present, XLSX will be used by default.
20
+ You can change this by adding to active scaffold config:
21
+ ```
22
+ conf.export.default_file_format = 'csv' # or 'xlsx'
23
+ ```
24
+ read important notes at the bottom about xlsx.
25
+
26
+ Remember to bundle install.
27
+ Add to application.css:
28
+ ```
29
+ *= require active_scaffold_export
30
+ ```
31
+
32
+ Now let's add it to controller, inside active_scaffold config block:
33
+ ```ruby
34
+ conf.actions.add :export
35
+ # you can filter or sort columns if you want
36
+ conf.export.columns = %w(name last_name phone address)
37
+ # you can define a default values for the exporting form
38
+ conf.export.default_deselected_columns = %w(phone address)
39
+ conf.export.default_delimiter = ";"
40
+ conf.export.force_quotes = "true"
41
+ ```
42
+ And enjoy happy exporting :)
43
+
44
+ ### Security
45
+ It's controlled the same way as Active Scaffold. The extra actions added are:
46
+ * **:show_export** for the options form
47
+ * **:export** for retrieving the data
48
+ Tested with AS internal security and [Cancan](https://github.com/ryanb/cancan)
49
+
50
+ ### Translations
51
+ Go in the same active scaffold scope:
52
+ ```yaml
53
+ active_scaffold:
54
+ columns_for_export: Columnas para exportar
55
+ export_options: Opciones de exportación
56
+ this_page: esta página
57
+ all_pages: todas las páginas
58
+ ```
59
+
60
+ ### XLSX support
61
+ This support depends on axlsx_rails and axlsx of course.
62
+ header styling override will be added soon.
63
+ NOTE: There's NO streaming support for xlsx format. Only CSV. So if your data is huge, set default_file_format to 'csv' instead.
64
+ Streaming in xlsx will never be supported since the entire file needs to be serialized and zipped to be a valid OOXML file.
65
+ So, rather than streaming, background jobs will be the most likely future approach.
66
+ [Read axlsx issue about this](https://github.com/randym/axlsx/issues/169#issuecomment-13252750)
67
+
68
+ This gem has not been tested in other rubies than REE and Ruby 1.9.
69
+ For contact, help, support, comments, please use Active Scaffold official mailing list activescaffold@googlegroups.com
70
+
@@ -1,5 +1,5 @@
1
1
  .active-scaffold-header div.actions a.show_export {
2
- background-image: url(../../../images/active_scaffold/default/export.png);
2
+ background-image: url(<%= asset_path 'export.png' %>);
3
3
  background-position: 1px 50%;
4
4
  background-repeat: no-repeat;
5
5
  padding-left: 19px;
@@ -25,3 +25,12 @@
25
25
  .active-scaffold div.show_export-view label #delimiter {
26
26
  font-family: monospace;
27
27
  }
28
+
29
+ .as_touch .active-scaffold-header div.actions a.show_export {
30
+ padding: 7px 5px 7px 25px;
31
+ }
32
+
33
+ .as_touch .active-scaffold .active-scaffold-header div.actions > a.show_export {
34
+ padding: 7px 5px 7px 25px;
35
+ background-position: 5px 50%;
36
+ }
@@ -1,4 +1,6 @@
1
1
  <%
2
+ require 'csv' if RUBY_VERSION >= "1.9"
3
+
2
4
  fcsv_options = {
3
5
  :row_sep => "\n",
4
6
  :col_sep => params[:delimiter],
@@ -6,7 +8,8 @@
6
8
  :headers => @export_columns.collect { |column| format_export_column_header_name(column) }
7
9
  }
8
10
 
9
- data = CSV.generate(fcsv_options) do |csv|
11
+ csv_lib = Object.const_defined?('CSV') ? CSV : FasterCSV
12
+ data = csv_lib.generate(fcsv_options) do |csv|
10
13
  csv << fcsv_options[:headers] unless params[:skip_header] == 'true'
11
14
  @records.each do |record|
12
15
  csv << @export_columns.collect { |column|
@@ -0,0 +1,41 @@
1
+ <% export_config = active_scaffold_config.export %>
2
+ <h3><%=as_(:columns_for_export)%></h3>
3
+ <% if ActiveScaffold.js_framework == :jquery # TODO: use JS asset instead of inline JS %>
4
+ <%= link_to as_(:select_all), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", true); return false', class: 'active-scaffold-footer' %>
5
+ |
6
+ <%= link_to as_(:select_none), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", false); return false', class: 'active-scaffold-footer' %>
7
+ <% end %>
8
+ <div class="columns checkbox-list">
9
+ <% export_config.columns.each_column do |column| -%>
10
+ <div class="column checkbox-wrapper">
11
+ <%= content_tag(:label, check_box_tag("export_columns[#{column.name}]", 1, !export_config.default_deselected_columns.include?(column.name), :class => 'columnCheckbox') + "&nbsp;#{column.label}".html_safe) %>
12
+ </div>
13
+ <% end -%>
14
+ &nbsp;
15
+ </div>
16
+ <div class="separator"></div>
17
+ <h3><%=as_(:options)%></h3>
18
+ <div class="options checkbox-list">
19
+ <div class="option checkbox-wrapper">
20
+ <%= content_tag(:label, check_box_tag('skip_header', 1, export_config.default_skip_header) + " #{as_(:omit_header)}".html_safe) %>
21
+ </div>
22
+ <div class="option checkbox-wrapper">
23
+ <%= content_tag(:label, text_field_tag('delimiter', export_config.default_delimiter, :size => 1, :maxlength => 1) + " #{as_(:delimiter)}".html_safe) %>
24
+ </div>
25
+ <div class="separator"></div>
26
+ <div class="option checkbox-wrapper">
27
+ <%= 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 %>
28
+ </div>
29
+ <div class="option checkbox-wrapper">
30
+ <%= 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 %>
31
+ </div>
32
+ <div class="separator"></div>
33
+ <div class="option checkbox-wrapper">
34
+ <%= content_tag(:label, radio_button_tag('format', :xlsx, export_config.default_file_format.to_sym == :xlsx) + ' XLSX') %>
35
+ </div>
36
+ <div class="option checkbox-wrapper">
37
+ <%= content_tag(:label, radio_button_tag('format', :csv, export_config.default_file_format.to_sym == :csv) + ' CSV') %>
38
+ </div>
39
+ &nbsp;
40
+ </div>
41
+ <div class="separator"></div>
@@ -1,7 +1,8 @@
1
1
  <%= render :partial => "base_form", :locals => {:xhr => false,
2
2
  :form_action => :export,
3
- :url_options => params_for(:action => :export, :format => 'csv'),
3
+ :url_options => params_for(:action => :export),
4
4
  :method => :post,
5
5
  :cancel_link => true,
6
- :headline => as_('Columns to Export'),
7
- :body_partial => 'export_form_body'} %>
6
+ :headline => as_(:export),
7
+ :body_partial => 'export_form_body',
8
+ :loading => false} %>
@@ -1,21 +1,13 @@
1
1
  module ActiveScaffold::Actions
2
2
  module Export
3
3
  def self.included(base)
4
- base.before_filter :export_authorized?, :only => [:export]
5
- base.before_filter :init_session_var
6
-
7
- as_export_plugin_path = File.join(ActiveScaffold::Config::Export.plugin_directory, 'frontends', 'default' , 'views')
8
-
9
- base.add_active_scaffold_path as_export_plugin_path
10
- end
11
-
12
- def init_session_var
13
- session[:search] = params[:search] if !params[:search].nil? || params[:commit] == as_('Search')
4
+ base.before_action :export_authorized?, :only => [:export]
5
+ base.before_action :show_export_authorized?, :only => [:show_export]
14
6
  end
15
7
 
16
8
  # display the customization form or skip directly to export
17
9
  def show_export
18
- export_config = active_scaffold_config.export
10
+ @export_config = active_scaffold_config.export
19
11
  respond_to do |wants|
20
12
  wants.html do
21
13
  render(:partial => 'show_export', :layout => true)
@@ -31,9 +23,7 @@ module ActiveScaffold::Actions
31
23
  export_config = active_scaffold_config.export
32
24
  if params[:export_columns].nil?
33
25
  export_columns = {}
34
- export_config.columns.each { |col|
35
- export_columns[col.name.to_sym] = 1
36
- }
26
+ export_config.columns.each { |col| export_columns[col.to_sym] = 1 }
37
27
  options = {
38
28
  :export_columns => export_columns,
39
29
  :full_download => export_config.default_full_download.to_s,
@@ -43,33 +33,70 @@ module ActiveScaffold::Actions
43
33
  params.merge!(options)
44
34
  end
45
35
 
36
+ set_includes_for_columns(:export)
37
+ @export_config = export_config
38
+ # Make sure active_scaffold's find_page is dealing with the same list of
39
+ # columns. Prevents an invalid SQL query when exporting after filtering
40
+ # with field_search against a relation column, and that relation column is
41
+ # not included in the set of export columns.
42
+ @list_columns = @export_columns
43
+
46
44
  # this is required if you want this to work with IE
47
45
  if request.env['HTTP_USER_AGENT'] =~ /msie/i
48
46
  response.headers['Pragma'] = "public"
49
47
  response.headers['Cache-Control'] = "no-cache, must-revalidate, post-check=0, pre-check=0"
50
48
  response.headers['Expires'] = "0"
51
49
  end
52
-
53
- response.headers['Content-type'] = 'text/csv'
54
50
  response.headers['Content-Disposition'] = "attachment; filename=#{export_file_name}"
55
51
 
56
- @export_columns = export_config.columns.reject { |col| params[:export_columns][col.name.to_sym].nil? }
57
- includes_for_export_columns = @export_columns.collect{ |col| col.includes }.flatten.uniq.compact
58
- self.active_scaffold_includes.concat includes_for_export_columns
59
- @export_config = export_config
52
+ unless defined? Mime::XLSX
53
+ Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
54
+ end
60
55
 
61
- # start streaming output
62
- self.response_body = proc { |response, output|
63
- find_items_for_export do |records|
64
- @records = records
65
- str = render_to_string :partial => 'export', :layout => false
66
- output.write(str)
67
- params[:skip_header] = 'true' # skip header on the next run
56
+ respond_to do |format|
57
+ format.csv do
58
+ response.headers['Content-type'] = 'text/csv'
59
+ # start streaming output
60
+ self.response_body = Enumerator.new do |y|
61
+ find_items_for_export do |records|
62
+ @records = records
63
+ str = render_to_string :partial => 'export', :layout => false, :formats => [:csv]
64
+ y << str
65
+ params[:skip_header] = 'true' # skip header on the next run
66
+ end
67
+ end
68
68
  end
69
- }
69
+ format.xlsx do
70
+ response.headers['Content-type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
71
+ p = Axlsx::Package.new
72
+ header = p.workbook.styles.add_style sz: 11, b: true,:bg_color => "69B5EF", :fg_color => "FF", alignment: { horizontal: :center }
73
+ p.workbook.add_worksheet(name: active_scaffold_config.label) do |sheet|
74
+ sheet.add_row(@export_columns.collect { |column| view_context.format_export_column_header_name(column) }, style: header) unless params[:skip_header]
75
+ find_items_for_export do |records|
76
+ records.each do |record|
77
+ sheet.add_row @export_columns.collect { |column| view_context.get_export_column_value(record, column, false) }
78
+ end
79
+ end
80
+ end
81
+ stream = p.to_stream # when adding rows to sheet, they won't pass to this stream if declared before. axlsx issue?
82
+ self.response_body = Enumerator.new do |y|
83
+ y << stream.read
84
+ end
85
+ end
86
+
87
+ end
70
88
  end
71
89
 
72
90
  protected
91
+ def export_columns
92
+ return @export_columns if defined? @export_columns
93
+ @export_columns = active_scaffold_config.export.columns.reject { |col| params[:export_columns][col.to_sym].nil? }
94
+ sorting = active_scaffold_config.list.user.sorting || active_scaffold_config.list.sorting
95
+ sorting_columns = sorting.reject { |col, _| @export_columns.include?(col.name) }.map(&:first)
96
+ @export_columns.map! { |col| active_scaffold_config.columns[col] }
97
+ @export_columns += sorting_columns
98
+ end
99
+
73
100
  # The actual algorithm to do the export
74
101
  def find_items_for_export(&block)
75
102
  find_options = { :sorting =>
@@ -77,14 +104,13 @@ module ActiveScaffold::Actions
77
104
  active_scaffold_config.list.sorting : active_scaffold_config.list.user.sorting,
78
105
  :pagination => true
79
106
  }
80
- params[:search] = session[:search]
81
107
  do_search rescue nil
82
108
  params[:segment_id] = session[:segment_id]
83
109
  do_segment_search rescue nil
84
110
 
85
111
  if params[:full_download] == 'true'
86
112
  find_options.merge!({
87
- :per_page => 10000,
113
+ :per_page => 3000,
88
114
  :page => 1
89
115
  })
90
116
  find_page(find_options).pager.each do |page|
@@ -92,6 +118,7 @@ module ActiveScaffold::Actions
92
118
  end
93
119
  else
94
120
  find_options.merge!({
121
+ :pagination => active_scaffold_config.list.pagination,
95
122
  :per_page => active_scaffold_config.list.user.per_page,
96
123
  :page => active_scaffold_config.list.user.page
97
124
  })
@@ -102,7 +129,19 @@ module ActiveScaffold::Actions
102
129
  # The default name of the downloaded file.
103
130
  # You may override the method to specify your own file name generation.
104
131
  def export_file_name
105
- "#{self.controller_name}.csv"
132
+ filename = self.controller_name.clone
133
+
134
+ if params[:format]
135
+ if params[:format].to_sym == :xlsx
136
+ filename << '.xlsx'
137
+ elsif params[:format].to_sym == :csv
138
+ filename << '.csv'
139
+ end
140
+ else
141
+ filename << ".#{active_scaffold_config.export.default_file_format}"
142
+ end
143
+
144
+ return filename
106
145
  end
107
146
 
108
147
  # The default security delegates to ActiveRecordPermissions.
@@ -110,5 +149,10 @@ module ActiveScaffold::Actions
110
149
  def export_authorized?
111
150
  authorized_for?(:action => :read)
112
151
  end
152
+
153
+ def show_export_authorized?
154
+ export_authorized?
155
+ end
156
+
113
157
  end
114
158
  end
@@ -29,7 +29,7 @@ module ActiveScaffold::Config
29
29
  end
30
30
  end
31
31
 
32
- attr_writer :show_form, :allow_full_download, :force_quotes, :default_full_download, :default_delimiter, :default_skip_header, :default_deselected_columns
32
+ attr_writer :show_form, :allow_full_download, :force_quotes, :default_full_download, :default_delimiter, :default_skip_header, :default_deselected_columns, :default_file_format
33
33
  def show_form
34
34
  self.show_form = @core.export_show_form if @show_form.nil?
35
35
  @show_form
@@ -58,17 +58,19 @@ module ActiveScaffold::Config
58
58
  self.default_deselected_columns = [] if @default_deselected_columns.nil?
59
59
  @default_deselected_columns
60
60
  end
61
-
62
- # provides access to the list of columns specifically meant for this action to use
63
- def columns
64
- self.columns = @core.columns._inheritable unless @columns
65
- @columns
61
+ def default_file_format
62
+ if @core.export_xlsx_avaliable
63
+ self.default_file_format = @default_file_format || 'xlsx'
64
+ else
65
+ self.default_file_format = @default_file_format || @core.export_default_file_format
66
+ end
66
67
  end
67
- def columns=(val)
68
- @columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
69
- @columns.action = self
68
+ def xlsx_present?
69
+ Gem::Specification::find_all_by_name('axlsx_rails').any?
70
70
  end
71
71
 
72
+ columns_accessor :columns
73
+
72
74
  def multipart?
73
75
  false
74
76
  end
@@ -1,24 +1,7 @@
1
- # coding: utf-8
2
-
3
1
  module ActiveScaffold
4
2
  module Helpers
5
3
  # Helpers that assist with the rendering of a Export Column
6
4
  module ExportHelpers
7
- def self.included(base)
8
- base.alias_method_chain :active_scaffold_stylesheets, :export
9
- base.alias_method_chain :active_scaffold_ie_stylesheets, :export
10
- end
11
-
12
- # Provides stylesheets to include with +stylesheet_link_tag+
13
- def active_scaffold_stylesheets_with_export(frontend = :default)
14
- active_scaffold_stylesheets_without_export.to_a << ActiveScaffold::Config::Core.asset_path("export-stylesheet.css", frontend)
15
- end
16
-
17
- # Provides stylesheets for IE to include with +stylesheet_link_tag+
18
- def active_scaffold_ie_stylesheets_with_export(frontend = :default)
19
- active_scaffold_ie_stylesheets_without_export.to_a << ActiveScaffold::Config::Core.asset_path("export-stylesheet-ie.css", frontend)
20
- end
21
-
22
5
  ## individual columns can be overridden by defining
23
6
  # a helper method <column_name>_export_column(record)
24
7
  # You can customize the output of all columns by
@@ -26,20 +9,19 @@ module ActiveScaffold
26
9
  # format_export_column(raw_value)
27
10
  # format_singular_association_export_column(association_record)
28
11
  # format_plural_association_export_column(association_records)
29
- def get_export_column_value(record, column)
12
+ def get_export_column_value(record, column, csv = true)
30
13
  if export_column_override? column
31
14
  send(export_column_override(column), record)
32
15
  else
33
16
  raw_value = record.send(column.name)
34
17
 
35
18
  if column.association.nil? or column_empty?(raw_value)
36
- format_export_column(raw_value)
37
- else
38
- case column.association.macro
39
- when :has_one, :belongs_to
40
- format_singular_association_export_column(raw_value)
41
- when :has_many, :has_and_belongs_to_many
19
+ csv ? format_export_column(raw_value) : raw_value # xlsx needs original data type
20
+ elsif column.association
21
+ if column.association.collection?
42
22
  format_plural_association_export_column(raw_value)
23
+ else
24
+ format_singular_association_export_column(raw_value)
43
25
  end
44
26
  end
45
27
  end
@@ -54,7 +36,19 @@ module ActiveScaffold
54
36
  end
55
37
 
56
38
  def format_export_column(raw_value)
57
- format_value(raw_value)
39
+ format_value_for_csv(raw_value)
40
+ end
41
+
42
+ def format_value_for_csv(column_value)
43
+ value = if column_empty?(column_value)
44
+ active_scaffold_config.list.empty_field_text
45
+ elsif column_value.is_a?(Time) || column_value.is_a?(Date)
46
+ l(column_value, :format => :default)
47
+ elsif [FalseClass, TrueClass].include?(column_value.class)
48
+ as_(column_value.to_s.to_sym)
49
+ else
50
+ column_value.to_s
51
+ end
58
52
  end
59
53
 
60
54
  def format_singular_association_export_column(association_record)
@@ -63,15 +57,16 @@ module ActiveScaffold
63
57
 
64
58
  def format_plural_association_export_column(association_records)
65
59
  firsts = association_records.first(4).collect { |v| v.to_label }
66
- firsts[4] = "…" if firsts.length == 4
60
+ firsts[3] = ' ' if firsts.length == 4
67
61
  format_value(firsts.join(','))
68
62
  end
69
63
 
70
64
  ## This helper can be overridden to change the way that the headers
71
65
  # are formatted. For instance, you might want column.name.to_s.humanize
72
66
  def format_export_column_header_name(column)
73
- column.name.to_s
67
+ column.label
74
68
  end
69
+
75
70
  end
76
71
  end
77
72
  end
@@ -1,20 +1,8 @@
1
- require "csv"
2
- if CSV.const_defined? :Reader
3
- # Ruby 1.8 compatible
4
- begin
5
- require 'fastercsv'
6
- Object.send(:remove_const, :CSV)
7
- CSV = FasterCSV
8
- rescue Gem::LoadError
9
- raise "For ruby 1.8, the 'fastercsv' gem is required"
10
- end
11
- else
12
- # CSV is now FasterCSV in ruby 1.9
13
- end
14
-
15
- # Make sure that ActiveScaffold has already been included
1
+ ACTIVE_SCAFFOLD_EXPORT_GEM = true
16
2
  ActiveScaffold rescue throw "should have included ActiveScaffold plug in first. Please make sure that this plug-in comes alphabetically after the ActiveScaffold plug-in"
17
3
 
4
+ require 'active_scaffold_export/engine'
5
+ require 'active_scaffold_export/version'
18
6
 
19
7
  # Load our overrides
20
8
  require "active_scaffold_export/config/core.rb"
@@ -39,18 +27,4 @@ module ActiveScaffold
39
27
  end
40
28
  end
41
29
 
42
- # Register our helper methods
43
30
  ActionView::Base.send(:include, ActiveScaffold::Helpers::ExportHelpers)
44
-
45
-
46
- ##
47
- ## Run the install assets script, too, just to make sure
48
- ## But at least rescue the action in production
49
- ##
50
- if defined?(ACTIVE_SCAFFOLD_EXPORT_PLUGIN)
51
- ActiveScaffoldAssets.copy_to_public(ActiveScaffoldExport.root)
52
- else
53
- Rails::Application.initializer("active_scaffold_export.install_assets", :after => "active_scaffold.install_assets") do
54
- ActiveScaffoldAssets.copy_to_public(ActiveScaffoldExport.root)
55
- end
56
- end
@@ -1,6 +1,6 @@
1
1
  # Need to open the AS module carefully due to Rails 2.3 lazy loading
2
2
  ActiveScaffold::Config::Core.class_eval do
3
- # For some unobvious reasons, the class variables need to be defined
3
+ # For some note obvious reasons, the class variables need to be defined
4
4
  # *before* the cattr !!
5
5
  self.send :class_variable_set, :@@export_show_form, true
6
6
  self.send :class_variable_set, :@@export_allow_full_download, true
@@ -8,11 +8,13 @@ ActiveScaffold::Config::Core.class_eval do
8
8
  self.send :class_variable_set, :@@export_force_quotes, false
9
9
  self.send :class_variable_set, :@@export_default_skip_header, false
10
10
  self.send :class_variable_set, :@@export_default_delimiter, ','
11
+ self.send :class_variable_set, :@@export_default_file_format, Gem::Specification::find_all_by_name('axlsx_rails').any? ? 'xlsx' : 'csv'
11
12
 
12
13
  cattr_accessor :export_show_form, :export_allow_full_download,
13
14
  :export_force_quotes, :export_default_full_download,
14
- :export_default_delimiter, :export_default_skip_header
15
+ :export_default_delimiter, :export_default_skip_header,
16
+ :export_default_file_format, :export_xlsx_avaliable
15
17
 
16
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:show_export] = :get
17
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:export] = :post
18
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:show_export] = :get
19
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:export] = :post
18
20
  end
@@ -0,0 +1,8 @@
1
+ module ActiveScaffoldExport
2
+ #do not use module Rails... cause Rails.logger will fail
3
+ # not sure if it is a must though...
4
+ #module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ #end
8
+ end
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffoldExport
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 0
5
- PATCH = 6
4
+ MINOR = 4
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,177 +1,77 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_export
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
6
- segments:
7
- - 3
8
- - 0
9
- - 6
10
- version: 3.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.4.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Volker Hochstein
14
- - Mojo Tech, LLC
15
- - see commits
16
- autorequire:
8
+ - Sergio Cambra
9
+ - Hernan Astudillo
10
+ autorequire:
17
11
  bindir: bin
18
12
  cert_chain: []
19
-
20
- date: 2011-03-26 00:00:00 -04:00
21
- default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
24
- type: :development
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
34
- name: shoulda
35
- version_requirements: *id001
36
- prerelease: false
37
- - !ruby/object:Gem::Dependency
38
- type: :development
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 23
45
- segments:
46
- - 1
47
- - 0
48
- - 0
49
- version: 1.0.0
50
- name: bundler
51
- version_requirements: *id002
52
- prerelease: false
53
- - !ruby/object:Gem::Dependency
54
- type: :development
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 7
61
- segments:
62
- - 1
63
- - 5
64
- - 2
65
- version: 1.5.2
66
- name: jeweler
67
- version_requirements: *id003
68
- prerelease: false
69
- - !ruby/object:Gem::Dependency
70
- type: :development
71
- requirement: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
13
+ date: 2020-12-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: active_scaffold
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
74
19
  - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- version: "0"
80
- name: rcov
81
- version_requirements: *id004
82
- prerelease: false
83
- - !ruby/object:Gem::Dependency
20
+ - !ruby/object:Gem::Version
21
+ version: 3.6.0.pre
84
22
  type: :runtime
85
- requirement: &id005 !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 31
91
- segments:
92
- - 3
93
- - 0
94
- - 12
95
- version: 3.0.12
96
- name: active_scaffold
97
- version_requirements: *id005
98
23
  prerelease: false
99
- - !ruby/object:Gem::Dependency
100
- type: :runtime
101
- requirement: &id006 !ruby/object:Gem::Requirement
102
- none: false
103
- requirements:
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
104
26
  - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
110
- name: fastercsv
111
- version_requirements: *id006
112
- prerelease: false
113
- description: This Active Scaffold plugin provides a configurable CSV 'Export' action for Active Scaffold controllers
27
+ - !ruby/object:Gem::Version
28
+ version: 3.6.0.pre
29
+ description: Exporting Records with ActiveScaffold
114
30
  email: activescaffold@googlegroups.com
115
31
  executables: []
116
-
117
32
  extensions: []
118
-
119
- extra_rdoc_files:
120
- - README.markdown
121
- files:
122
- - .document
123
- - Gemfile
124
- - MIT-LICENSE
125
- - README.markdown
126
- - Rakefile
127
- - active_scaffold_export.gemspec
128
- - frontends/default/images/export.png
129
- - frontends/default/stylesheets/export-stylesheet-ie.css
130
- - frontends/default/stylesheets/export-stylesheet.css
131
- - frontends/default/views/_export.csv.erb
132
- - frontends/default/views/_export_form_body.html.erb
133
- - frontends/default/views/_show_export.html.erb
134
- - frontends/default/views/show_export.html.erb
135
- - init.rb
33
+ extra_rdoc_files:
34
+ - LICENSE.txt
35
+ - README.md
36
+ files:
37
+ - LICENSE.txt
38
+ - README.md
39
+ - app/assets/images/export.png
40
+ - app/assets/stylesheets/active_scaffold_export.css.erb
41
+ - app/assets/stylesheets/export-stylesheet-ie.css
42
+ - app/views/active_scaffold_overrides/_export.csv.erb
43
+ - app/views/active_scaffold_overrides/_export_form_body.html.erb
44
+ - app/views/active_scaffold_overrides/_show_export.html.erb
45
+ - app/views/active_scaffold_overrides/show_export.html.erb
136
46
  - lib/active_scaffold/actions/export.rb
137
47
  - lib/active_scaffold/config/export.rb
138
48
  - lib/active_scaffold/helpers/export_helpers.rb
139
49
  - lib/active_scaffold_export.rb
140
50
  - lib/active_scaffold_export/config/core.rb
51
+ - lib/active_scaffold_export/engine.rb
141
52
  - lib/active_scaffold_export/version.rb
142
- has_rdoc: true
143
- homepage: http://github.com/mojotech/active_scaffold_export
144
- licenses:
53
+ homepage: http://github.com/active_scaffold/active_scaffold_export
54
+ licenses:
145
55
  - MIT
146
- post_install_message:
56
+ metadata: {}
57
+ post_install_message:
147
58
  rdoc_options: []
148
-
149
- require_paths:
59
+ require_paths:
150
60
  - lib
151
- required_ruby_version: !ruby/object:Gem::Requirement
152
- none: false
153
- requirements:
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
154
63
  - - ">="
155
- - !ruby/object:Gem::Version
156
- hash: 3
157
- segments:
158
- - 0
159
- version: "0"
160
- required_rubygems_version: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
163
68
  - - ">="
164
- - !ruby/object:Gem::Version
165
- hash: 3
166
- segments:
167
- - 0
168
- version: "0"
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
169
71
  requirements: []
170
-
171
- rubyforge_project:
172
- rubygems_version: 1.6.2
173
- signing_key:
174
- specification_version: 3
175
- summary: Exporting Records with ActiveScaffold
72
+ rubyforge_project:
73
+ rubygems_version: 2.7.9
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Ability to export records to CSV/XLSX with ActiveScaffold
176
77
  test_files: []
177
-
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- MIT-LICENSE
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in foo.gemspec
4
- group :development do
5
- gem "shoulda", ">= 0"
6
- gem "bundler", "~> 1.0.0"
7
- gem "jeweler", "~> 1.5.2"
8
- gem "rcov", ">= 0"
9
- end
10
-
@@ -1,65 +0,0 @@
1
- active_scaffold_export
2
- ======================
3
-
4
- Active Scaffold plugin for CSV exports.
5
-
6
- Introduction
7
- ------------
8
-
9
- This Active Scaffold plugin provides a configurable CSV 'Export'
10
- action for Active Scaffold controllers.
11
-
12
- Installation
13
- ------------
14
-
15
- You can use active_scaffold_export with the latest Rails 3, but you'll
16
- need to also install the vhochstein port of active_scaffold.
17
-
18
- $ rails plugin install git://github.com/vhochstein/active_scaffold.git
19
-
20
- In your Gemfile:
21
-
22
- gem "active_scaffold_export"
23
-
24
- Features
25
- --------
26
-
27
- * Uses FasterCSV for CSV generation
28
- * Works with Rails 3 (thanks vhochstein!)
29
- * Scales to many, many records (thanks Alexander Malysh!)
30
- * Let the user pick which columns to export.
31
- * Download full lists or just a single page.
32
- * Don't like commas? No problem, uses your favorite delimiter!
33
- * Don't need no stinkin' headers? Drop 'em.
34
-
35
- Usage
36
- -----
37
-
38
- active_scaffold :users do |config|
39
- actions.add :export # this is required, all other configuration is optional
40
-
41
- export.columns = [ :id, :email, :created_at ] # uses list columns by default
42
- export.allow_full_download = false # defaults to true
43
- export.show_form = true # whether to show customization form or not, default to true
44
- export.force_quotes = true # defaults to false
45
- export.default_deselected_columns = [ :created_at ] # optional
46
- export.default_delimiter = ';' # defaults to ','
47
- export.default_skip_header = true # defaults to false
48
- export.default_full_download = false # defaults to true
49
- end
50
-
51
- Note on Patches/Pull Requests
52
- -----------------------------
53
-
54
- * Fork the project.
55
- * Make your feature addition or bug fix.
56
- * Add tests for it. This is important so I don't break it in a
57
- future version unintentionally.
58
- * Commit, do not mess with rakefile, version, or history.
59
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
60
- * Send me a pull request. Bonus points for topic branches.
61
-
62
- Copyright
63
- ---------
64
-
65
- Copyright (c) 2010 Mojo Tech, LLC. See MIT-LICENSE for details.
data/Rakefile DELETED
@@ -1,58 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- require 'jeweler'
13
- require './lib/active_scaffold_export/version.rb'
14
-
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "active_scaffold_export"
18
- gem.version = ActiveScaffoldExport::Version::STRING
19
- gem.homepage = "http://github.com/mojotech/active_scaffold_export"
20
- gem.license = "MIT"
21
- gem.summary = %Q{Exporting Records with ActiveScaffold}
22
- gem.description = %Q{This Active Scaffold plugin provides a configurable CSV 'Export' action for Active Scaffold controllers}
23
- gem.email = "activescaffold@googlegroups.com"
24
- gem.authors = ["Volker Hochstein", "Mojo Tech, LLC", "see commits"]
25
- gem.add_runtime_dependency 'active_scaffold', '>= 3.0.12'
26
- if RUBY_VERSION < "1.9"
27
- gem.add_runtime_dependency "fastercsv"
28
- end
29
- # Include your dependencies below. Runtime dependencies are required when using your gem,
30
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
31
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
32
- # gem.add_development_dependency 'rspec', '> 1.2.3'
33
- end
34
- Jeweler::RubygemsDotOrgTasks.new
35
-
36
- require 'rake/testtask'
37
- Rake::TestTask.new(:test) do |test|
38
- test.libs << 'lib' << 'test'
39
- test.pattern = 'test/**/test_*.rb'
40
- test.verbose = true
41
- end
42
-
43
- require 'rcov/rcovtask'
44
- Rcov::RcovTask.new do |test|
45
- test.libs << 'test'
46
- test.pattern = 'test/**/test_*.rb'
47
- test.verbose = true
48
- end
49
-
50
- task :default => :test
51
-
52
- require 'rake/rdoctask'
53
- Rake::RDocTask.new do |rdoc|
54
- rdoc.rdoc_dir = 'rdoc'
55
- rdoc.title = "active_scaffold_export #{ActiveScaffoldExport::Version::STRING}"
56
- rdoc.rdoc_files.include('README*')
57
- rdoc.rdoc_files.include('lib/**/*.rb')
58
- end
@@ -1,73 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{active_scaffold_export}
8
- s.version = "3.0.6"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Volker Hochstein", "Mojo Tech, LLC", "see commits"]
12
- s.date = %q{2011-03-26}
13
- s.description = %q{This Active Scaffold plugin provides a configurable CSV 'Export' action for Active Scaffold controllers}
14
- s.email = %q{activescaffold@googlegroups.com}
15
- s.extra_rdoc_files = [
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".document",
20
- "Gemfile",
21
- "MIT-LICENSE",
22
- "README.markdown",
23
- "Rakefile",
24
- "active_scaffold_export.gemspec",
25
- "frontends/default/images/export.png",
26
- "frontends/default/stylesheets/export-stylesheet-ie.css",
27
- "frontends/default/stylesheets/export-stylesheet.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",
33
- "lib/active_scaffold/actions/export.rb",
34
- "lib/active_scaffold/config/export.rb",
35
- "lib/active_scaffold/helpers/export_helpers.rb",
36
- "lib/active_scaffold_export.rb",
37
- "lib/active_scaffold_export/config/core.rb",
38
- "lib/active_scaffold_export/version.rb"
39
- ]
40
- s.homepage = %q{http://github.com/mojotech/active_scaffold_export}
41
- s.licenses = ["MIT"]
42
- s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.6.2}
44
- s.summary = %q{Exporting Records with ActiveScaffold}
45
-
46
- if s.respond_to? :specification_version then
47
- s.specification_version = 3
48
-
49
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_development_dependency(%q<shoulda>, [">= 0"])
51
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
- s.add_development_dependency(%q<rcov>, [">= 0"])
54
- s.add_runtime_dependency(%q<active_scaffold>, [">= 3.0.12"])
55
- s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
56
- else
57
- s.add_dependency(%q<shoulda>, [">= 0"])
58
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
60
- s.add_dependency(%q<rcov>, [">= 0"])
61
- s.add_dependency(%q<active_scaffold>, [">= 3.0.12"])
62
- s.add_dependency(%q<fastercsv>, [">= 0"])
63
- end
64
- else
65
- s.add_dependency(%q<shoulda>, [">= 0"])
66
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
68
- s.add_dependency(%q<rcov>, [">= 0"])
69
- s.add_dependency(%q<active_scaffold>, [">= 3.0.12"])
70
- s.add_dependency(%q<fastercsv>, [">= 0"])
71
- end
72
- end
73
-
@@ -1,28 +0,0 @@
1
- <% export_config = active_scaffold_config.export %>
2
- <div class="columns checkbox-list">
3
- <% export_config.columns.each do |column| -%>
4
- <div class="column checkbox-wrapper">
5
- <%= content_tag(:label, check_box_tag("export_columns[#{column.name}]", 1, !export_config.default_deselected_columns.include?(column.name)) + "&nbsp;#{column.label}".html_safe) %>
6
- </div>
7
- <% end -%>
8
- &nbsp;
9
- </div>
10
- <div class="separator"></div>
11
- <h3><%=as_('Options')%></h3>
12
- <div class="options checkbox-list">
13
- <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
- </div>
16
- <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
- </div>
19
- <div class="separator"></div>
20
- <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
- </div>
23
- <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
- </div>
26
- &nbsp;
27
- </div>
28
- <div class="separator"></div>
data/init.rb DELETED
@@ -1,2 +0,0 @@
1
- ACTIVE_SCAFFOLD_EXPORT_PLUGIN = true
2
- require 'active_scaffold_export'