From: Sascha Peilicke
It is needed there and Models shouldn't include helpers. Also fixing the
definition of 'viewable' file.
---
src/webui/app/helpers/application_helper.rb | 8 --------
src/webui/app/models/package.rb | 10 +++++++++-
src/webui/app/views/shared/_sourcediff.html.erb | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/webui/app/helpers/application_helper.rb b/src/webui/app/helpers/application_helper.rb
index 910302f..a0a6748 100644
--- a/src/webui/app/helpers/application_helper.rb
+++ b/src/webui/app/helpers/application_helper.rb
@@ -424,14 +424,6 @@ module ApplicationHelper
end
end
- def is_binary(filename)
- binary_extensions = %w{.bz2 .dll .exe .gem .gif .gz .jar .jpeg .jpg .lzma .ogg .pdf .pk3 .png .ps .rpm .svgz .tar .taz .tb2 .tbz .tbz2 .tgz .tlz .txz .xpm .xz .z .zip .ttf .0 .otf .ccf}
- binary_extensions.each do |ext|
- return true if filename.downcase.ends_with?(ext)
- end
- return false
- end
-
def sorted_filenames_and_bugs_from_sourcediff(xml_element)
# Sort files into categories by their ending and add all of them to a hash. We
# will later use the sorted and concatenated categories as key index into the per action file hash.
diff --git a/src/webui/app/models/package.rb b/src/webui/app/models/package.rb
index 9fca326..6c9c048 100644
--- a/src/webui/app/models/package.rb
+++ b/src/webui/app/models/package.rb
@@ -305,7 +305,7 @@ class Package < ActiveXML::Base
@serviceinfo = dir.serviceinfo if dir.has_element? 'serviceinfo'
dir.each_entry do |entry|
file = Hash[*[:name, :size, :mtime, :md5].map {|x| [x, entry.send(x.to_s)]}.flatten]
- file[:viewable] = !is_binary(file[:name]) || file[:size].to_i < 2**20 # max. 1 MB
+ file[:viewable] = !Package.is_binary_file?(file[:name]) && file[:size].to_i < 2**20 # max. 1 MB
file[:editable] = file[:viewable] && !file[:name].match(/^_service[_:]/)
file[:srcmd5] = dir.srcmd5
files << file
@@ -330,5 +330,13 @@ class Package < ActiveXML::Base
end
end
+ def self.is_binary_file?(filename)
+ binary_extensions = %w{.bz2 .dll .exe .gem .gif .gz .jar .jpeg .jpg .lzma .ogg .pdf .pk3 .png .ps .rpm .svgz .tar .taz .tb2 .tbz .tbz2 .tgz .tlz .txz .xpm .xz .z .zip .ttf .0 .otf .ccf}
+ binary_extensions.each do |ext|
+ return true if filename.downcase.ends_with?(ext)
+ end
+ return false
+ end
+
end
diff --git a/src/webui/app/views/shared/_sourcediff.html.erb b/src/webui/app/views/shared/_sourcediff.html.erb
index 2edbcb1..cd7549a 100644
--- a/src/webui/app/views/shared/_sourcediff.html.erb
+++ b/src/webui/app/views/shared/_sourcediff.html.erb
@@ -74,7 +74,7 @@
<% rev = source[:rev] %>
<% rev = (rev.to_i - 1).to_s if file_element.state == 'deleted' %>
<%# TODO: drop this check for '/' once we can 'view' files inside tarballs: %>
- <%= link_to_unless(is_binary(filename) || filename.include?('/'), filename, :controller => 'package', :action => 'view_file', :project => source[:project], :package => source[:package], :file => filename, :rev => rev) %>
+ <%= link_to_unless(Package.is_binary_file?(filename) || filename.include?('/'), filename, :controller => 'package', :action => 'view_file', :project => source[:project], :package => source[:package], :file => filename, :rev => rev) %>
</td>
</tr>
<% if file_diff_text.length > 0 %>
--
1.7.7
--
To unsubscribe, e-mail: obs-commits+unsubscribe@opensuse.org
To contact the owner, e-mail: obs-commits+owner@opensuse.org