summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2020-03-11 09:46:47 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2020-03-11 09:54:54 -0400
commit95bcf2b078ade1e557e99518b5d7c053c72c9f48 (patch)
treee17f99d69dfa8c41b996f62fa87bb04fd9730aa7
parenta521832e45ce02147b05c4616aa905281dc1ee93 (diff)
better regex and 'none' message for downloads pageparabola
-rw-r--r--app/controllers/downloads_controller.rb9
-rw-r--r--app/views/downloads/index.html.erb6
-rw-r--r--config/initializers/constants.rb2
3 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/downloads_controller.rb b/app/controllers/downloads_controller.rb
index 9075de9e0..4de8476aa 100644
--- a/app/controllers/downloads_controller.rb
+++ b/app/controllers/downloads_controller.rb
@@ -26,8 +26,8 @@ class DownloadsController < ApplicationController
if all_params_satisfied?
redirect
else
- @qemu_images = collect_images RELEASES_DIR , '/*/*image.img.sig' , RELEASES_URL
- @preview_images = collect_images PREVIEWS_DIR , '/*/*.sig' , PREVIEWS_URL
+ @qemu_images = collect_images RELEASES_DIR , RELEASES_GLOB , RELEASES_URL
+ @preview_images = collect_images PREVIEWS_DIR , PREVIEWS_GLOB , PREVIEWS_URL
render :index , :layout => 'download'
end
@@ -103,7 +103,8 @@ private
end
def collect_images base_dir , glob , base_url
- (Dir.glob "#{base_dir}#{glob}").map do | sig |
+ images_sigs = Dir.glob "#{base_dir}#{glob}"
+ images_data = images_sigs.map do | sig |
file_path = sig.gsub SIGS_REGEX , '\1'
{
@@ -112,6 +113,8 @@ private
:size => (File.size "#{base_dir}/#{file_path}")
}
end
+
+ (images_data.empty?) ? [ {} ] : images_data
end
end
diff --git a/app/views/downloads/index.html.erb b/app/views/downloads/index.html.erb
index 560a33946..41c25be06 100644
--- a/app/views/downloads/index.html.erb
+++ b/app/views/downloads/index.html.erb
@@ -33,8 +33,12 @@
<% image_name = image_data [:name] %>
<% image_size = image_data [:size] %>
<tr>
+ <% if image_url.present? && image_name.present? && image_size.present? %>
<td class="releases-image-td"><a href="<%= image_url %>"><%= image_name %></a></td>
<td>(<%= image_size / 1000000 %> MB)</td>
+ <% else %>
+ <td>none available</td>
+ <% end %>
</tr>
<% end %>
</table>
@@ -88,7 +92,7 @@
<div id="releases-previews-div" class="releases-div">
<h2 class="releases-h2">Preview/Experimental Images</h2>
<p>This section is an exhibit of new features, software, and desktop environments currently in the experimental, testing, or pre-release development stages. Theses are works in progress; but most normal functionality is expected to behave properly.</p>
- <p>Please do try them out and report any bugs that you may find to the <a href="https://labs.parabola.nu/projects/isos/issues?sort=updated_on%3Adesc%2Cid%3Adesc&tracker_id=1">Installation Media" bug tracker</a>.</p>
+ <p>Please do try them out and report any bugs that you may find to the <a href="https://labs.parabola.nu/projects/isos/issues?sort=updated_on%3Adesc%2Cid%3Adesc&tracker_id=1">Installation Media bug tracker</a>.</p>
<% images_table @preview_images %>
</div>
diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb
index 5e040713b..fa6ed2ae4 100644
--- a/config/initializers/constants.rb
+++ b/config/initializers/constants.rb
@@ -7,6 +7,8 @@ RELEASES_DIRNAME = 'iso'
PREVIEWS_DIRNAME = 'iso-nightly'
RELEASES_DIR = "/srv/repo/main/#{RELEASES_DIRNAME}"
PREVIEWS_DIR = "/srv/repo/http/#{PREVIEWS_DIRNAME}"
+RELEASES_GLOB = '/*/parabola-*image.img.sig'
+PREVIEWS_GLOB = '/*/parabola-*.sig'
SIGS_REGEX = /.*\/([^\/]+\/parabola-.+).sig/
RELEASES_URL = "https://redirector.parabola.nu/#{RELEASES_DIRNAME}"
PREVIEWS_URL = "https://repo.parabola.nu/#{PREVIEWS_DIRNAME}"