commit: 43d37380314a9066b1e20255bf152b8d0ca6fc5b
Author: Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Mon Feb 23 00:11:38 2015 +0000
Commit: Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 00:11:38 2015 +0000
URL:
http://sources.gentoo.org/gitweb/?p=proj/ag-web.git;a=commit;h=43d37380
Redirect back to the main list page if there are no messages at all in a given
month
---
ag-web.rb | 5 +++++
views/listindex.erb | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/ag-web.rb b/ag-web.rb
index 071246d..fd11ba4 100644
--- a/ag-web.rb
+++ b/ag-web.rb
@@ -130,6 +130,11 @@ get '/:list/messages/:year-:month/:page?' do
result = messages_in_month(params[:list], params[:year], params[:month],
current_page)
max_pages = (result['hits']['total'].to_f / PER_PAGE).ceil
+ if result['hits']['total'] == 0
+ redirect "/%s/?no_messages=1" % params[:list]
+ return
+ end
+
erb :listmonth, locals: { results: result, list: params[:list],
current_page: current_page, max_pages: max_pages, mode: :messages }
rescue => e
$stderr.puts e.to_s
diff --git a/views/listindex.erb b/views/listindex.erb
index ecf6ab7..30a0a17 100644
--- a/views/listindex.erb
+++ b/views/listindex.erb
@@ -1,5 +1,11 @@
<h1 class="first-header">Gentoo Archives: <%= list %></h1>
+<% if params[:no_messages] %>
+<div class="alert alert-warning">
+ There are no messages in the archive for the requested month.
+</div>
+<% end %>
+
<table class="table">
<tr>
<th>Month</th>