summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-05-25 13:31:07 +0200
committerMichał Górny <mgorny@gentoo.org>2018-05-25 13:32:41 +0200
commit1852a5892e2f4b0555f47118cd02500c0dd08071 (patch)
tree00ca72913d8e353948f0683246f2ba9af27cc1a8
parentReplace redirect on no threads with inline display (diff)
downloadfrontend-1852a5892e2f4b0555f47118cd02500c0dd08071.tar.gz
frontend-1852a5892e2f4b0555f47118cd02500c0dd08071.tar.bz2
frontend-1852a5892e2f4b0555f47118cd02500c0dd08071.zip
Remove the awful redirect on no messages in month
The redirect when no messages are found in month is awfully irritating, given that it rewrites the whole URL. Furthermore, it logically can only happen when someone types the URL manually which makes redirecting really silly. Instead, just display the 'no messages' message along with empty message list. Implicitly, this also adds a message when someone goes beyond last page. Currently, he seems only blank list. Bug: https://bugs.gentoo.org/656386
-rw-r--r--ag-web.rb9
-rw-r--r--views/listindex.erb8
-rw-r--r--views/listmonth.erb12
3 files changed, 10 insertions, 19 deletions
diff --git a/ag-web.rb b/ag-web.rb
index 701a951..24111b3 100644
--- a/ag-web.rb
+++ b/ag-web.rb
@@ -125,10 +125,6 @@ get '/:list/threads/:year-:month/:page?' do
if result['hits']['total'] == 0
result = messages_in_month(params[:list], params[:year], params[:month], current_page)
no_threads = true
- if result['hits']['total'] == 0
- redirect '/%s/?no_messages=1' % params[:list]
- return
- end
end
max_pages = (result['hits']['total'].to_f / PER_PAGE).ceil
@@ -163,11 +159,6 @@ 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],
diff --git a/views/listindex.erb b/views/listindex.erb
index 30a0a17..32df615 100644
--- a/views/listindex.erb
+++ b/views/listindex.erb
@@ -1,11 +1,5 @@
<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>
@@ -18,4 +12,4 @@
<td><%= month['doc_count'] %></td>
</tr>
<% end %>
-</table> \ No newline at end of file
+</table>
diff --git a/views/listmonth.erb b/views/listmonth.erb
index b7ef11c..020c340 100644
--- a/views/listmonth.erb
+++ b/views/listmonth.erb
@@ -6,10 +6,16 @@
<%= partial :views, locals: { list: list, mode: mode } %>
-<% if no_threads %>
-<div class="alert alert-info">
- There were no threads that started this month, showing you all messages instead.
+<% if results['hits']['total'] == 0 %>
+<div class="alert alert-warning">
+ There are no messages in the archive for the requested month.
</div>
+<% else %>
+ <% if no_threads %>
+ <div class="alert alert-info">
+ There were no threads that started this month, showing you all messages instead.
+ </div>
+ <% end %>
<% end %>
<div class="table-responsive">