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