Skip to content

Commit

Permalink
Merge pull request #1170 from openSUSE/hellcp/remove-patterns
Browse files Browse the repository at this point in the history
Remove pattern support from download section
  • Loading branch information
hennevogel authored Mar 29, 2022
2 parents ce89977 + 3b35015 commit ce99b8e
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 60 deletions.
4 changes: 0 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ def valid_package_name?(name)
name =~ /^[[:alnum:]][-+~\w.:@]*$/
end

def valid_pattern_name?(name)
name =~ /^[[:alnum:]][-_+\w.:]*$/
end

def valid_project_name?(name)
name =~ /^[[:alnum:]][-+\w.:]+$/
end
Expand Down
40 changes: 0 additions & 40 deletions app/controllers/download_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,46 +78,6 @@ def package
render_page :package
end

def pattern
@project = params[:project]
@pattern = params[:pattern]

cache_key = "soo_download_#{@project}_#{@pattern}"
@data = Rails.cache.fetch(cache_key, expires_in: 10.minutes) do
# api_result = ApiConnect::get("/search/published/pattern/id?match=project='#{@project}'+and+filename='#{@pattern}.ymp'")
# TODO: workaround - the line above does not return a thing - see https://lists.opensuse.org/opensuse-buildservice/2011-07/msg00088.html
# so we search for all files of the project and filter for *.ymp below
api_result = ApiConnect.get("/search/published/pattern/id?match=project='#{@project}'")
xpath = '/collection/pattern'
# logger.debug doc

if api_result
doc = REXML::Document.new api_result.body
data = {}
doc.elements.each(xpath) do |e|
next if e.attributes['filename'] != "#{@pattern}.ymp"

distro = e.attributes['repository']
next if data.key?(distro)

data[distro] = {
repo: "https://download.opensuse.org/repositories/#{@project}/#{distro}/",
package: {}
}
data[distro][:flavor] = set_distro_flavor get_project(distro, e.attributes['baseproject'])
case e.attributes['baseproject']
when /^(DISCONTINUED:)?openSUSE:/, /^(DISCONTINUED:)?SUSE:SLE-/
data[distro][:ymp] = "https://download.opensuse.org/repositories/#{e.attributes['filepath']}"
end
end
data
end
end
set_flavors
@page_title = format(_('Install pattern %s / %s'), @project, @pattern)
render_page :package
end

def ymp_with_arch_and_version
path = "/published/#{params[:project]}/#{params[:repository]}/#{params[:arch]}/#{params[:binary]}?view=ymp"
res = Rails.cache.fetch("ymp_#{path}", expires_in: 1.hour) do
Expand Down
6 changes: 0 additions & 6 deletions app/views/download/doc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@

<iframe src="<%= url_for :controller => :download, :action => :package, :project => "openSUSE:Tools", :package => "osc", :format => "iframe", :protocol => "https" %>" width="100%" height="700px" frameBorder="0" ></iframe>

<h3>Creating a download page for a pattern</h3>

<p>Linking to a pattern is similar to the way described above for a package, just change the url to use <i>pattern</i>:</p>

<pre>https://software.opensuse.org/download/pattern?project=<b>&lt;projectname&gt;</b>&amp;pattern=<b>&lt;patternname&gt;</b></pre>

<h3>Creating a download page for an appliance</h3>

<p>If your OBS project is building appliances, you can also link to those with: </p>
Expand Down
11 changes: 3 additions & 8 deletions app/views/download/package.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
<div class="container" id="content">
<div class="soo_download_#{@project}_#{@package}">
<% if @data.blank? %>
<h1 class="my-5"><%= _("No data for %s / %s") % [ @project, @package.nil? ? @pattern : @package] %></h1>
<h1 class="my-5"><%= _("No data for %s / %s") % [ @project, @package] %></h1>
<% else %>
<% unless @flavors.blank? %>
<h1 class="font-weight-normal">
<% package = @package.nil? ? @pattern : @package %>
<%= _("<b>#{package}</b> from <b>#{project_url(@project)}</b> project") %></h1>
<%= _("<b>#{@package}</b> from <b>#{project_url(@project)}</b> project") %></h1>
<h2 class="my-4"><%= _("Select Your Operating System") %></h2>
<div class="row py-3">
<% @flavors.each do |flavor| %>
Expand Down Expand Up @@ -69,11 +68,7 @@ pacman -Sy <%= repo_name %>/<%= @package %></pre>
<pre><%=
case v[:flavor]
when 'openSUSE', 'SLE'
if @package.nil?
"zypper addrepo #{v[:repo]}#{@project}.repo\nzypper refresh\nzypper install -t pattern #{@pattern}"
else
"zypper addrepo #{v[:repo]}#{@project}.repo\nzypper refresh\nzypper install #{@package}"
end
when 'Fedora'
version = k.split("_").last
if version == "Rawhide" or Integer(version) >= 22
Expand Down Expand Up @@ -128,7 +123,7 @@ pacman -Sy <%= repo_name %>/<%= @package %></pre>
</div>
</div>
<% else %>
<p><%= _("No downloads found for %s in project %s") % [ @package.nil? ? @pattern : @package, @project] %>.</p>
<p><%= _("No downloads found for %s in project %s") % [ @package, @project] %>.</p>
<% end %>
<% end %>
</div>
Expand Down
3 changes: 1 addition & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
namespace 'download' do
get 'appliance', constraints: ->(request) { request.params[:project].present? }
get 'package', constraints: ->(request) { request.params[:project].present? && request.params[:package].present? }
get 'pattern', constraints: ->(request) { request.params[:project].present? && request.params[:pattern].present? }

# Show documentation if contraints are not met
%w(doc appliance package pattern).each do |path|
%w(doc appliance package).each do |path|
get path, action: :doc
end
end
Expand Down

0 comments on commit ce99b8e

Please sign in to comment.