Feature #32372 » 32372-experimental.patch
| app/controllers/imports_controller.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
if request.get?
|
||
|
file_path = @import.filepath
|
||
|
file_encoding = @import.settings['encoding']
|
||
|
@preview_content = File.open(file_path, "r:#{file_encoding}:UTF-8") do |f|
|
||
|
# Read only the header and the first 3 lines
|
||
|
# Same as the default value of the Import#first_rows
|
||
|
f.each_line.first(4).join
|
||
|
end
|
||
|
end
|
||
|
rescue CSV::MalformedCSVError, EncodingError => e
|
||
|
if e.is_a?(CSV::MalformedCSVError) && !e.message.include?('Invalid byte sequence')
|
||
|
flash.now[:error] = l(:error_invalid_csv_file_or_settings, e.message)
|
||
| app/views/imports/settings.html.erb | ||
|---|---|---|
|
</fieldset>
|
||
|
<p><%= submit_tag l(:label_next).html_safe + " »".html_safe, :name => nil %></p>
|
||
|
<% end %>
|
||
|
<fieldset class="box">
|
||
|
<legend><%= l(:label_file_content_preview) %></legend>
|
||
|
<pre><%= @preview_content %></pre>
|
||
|
</fieldset>
|
||