summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2015-02-22 01:28:54 +0100
committerAlex Legler <alex@a3li.li>2015-02-22 01:28:54 +0100
commit35278c94afd68d99416398e4dff1a9a5499db8f4 (patch)
tree1b981a241b45d0360c7162498e646353c17d7722
parentgenerify captcha error message (diff)
downloadfrontend-35278c94afd68d99416398e4dff1a9a5499db8f4.tar.gz
frontend-35278c94afd68d99416398e4dff1a9a5499db8f4.tar.bz2
frontend-35278c94afd68d99416398e4dff1a9a5499db8f4.zip
show raw mesages if there are no threads
-rw-r--r--ag-web.rb5
-rw-r--r--views/listmonth.erb6
2 files changed, 11 insertions, 0 deletions
diff --git a/ag-web.rb b/ag-web.rb
index b178b71..182d269 100644
--- a/ag-web.rb
+++ b/ag-web.rb
@@ -106,6 +106,11 @@ get '/:list/threads/:year-:month/:page?' do
result = threads_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 to("/%s/messages/%s-%s?no_threads=1" % [params[:list], params[:year], params[:month]])
+ return
+ end
+
erb :listmonth, locals: { results: result, list: params[:list], current_page: current_page, max_pages: max_pages, mode: :threads }
rescue => e
$stderr.puts e.to_s
diff --git a/views/listmonth.erb b/views/listmonth.erb
index 4cdabe3..a986eb8 100644
--- a/views/listmonth.erb
+++ b/views/listmonth.erb
@@ -6,6 +6,12 @@
<%= partial :views, locals: { list: list, mode: mode } %>
+<% if params[:no_threads] %>
+<div class="alert alert-info">
+ There were no threads that started this month, showing you all messages instead.
+</div>
+<% end %>
+
<table class="table table-condensed table-hover ag-message-table">
<tr>
<th class="ag-message-table-subject">Subject</th>