summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ag-web.rb14
-rw-r--r--views/listmonth.erb4
2 files changed, 12 insertions, 6 deletions
diff --git a/ag-web.rb b/ag-web.rb
index 2dc8fe7..701a951 100644
--- a/ag-web.rb
+++ b/ag-web.rb
@@ -120,19 +120,25 @@ get '/:list/threads/:year-:month/:page?' do
@title = params[:list]
current_page = [(params[:page] || 1).to_i, 1].max
result = threads_in_month(params[:list], params[:year], params[:month], current_page)
- max_pages = (result['hits']['total'].to_f / PER_PAGE).ceil
+ no_threads = false
if result['hits']['total'] == 0
- redirect '/%s/messages/%s-%s/?no_threads=1' % [params[:list], params[:year], params[:month]]
- return
+ 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
erb :listmonth, locals: {
results: result,
list: params[:list],
current_page: current_page,
max_pages: max_pages,
- mode: :threads
+ mode: :threads,
+ no_threads: no_threads
}
rescue => e
$stderr.puts e.to_s
diff --git a/views/listmonth.erb b/views/listmonth.erb
index 9f137f0..b7ef11c 100644
--- a/views/listmonth.erb
+++ b/views/listmonth.erb
@@ -6,7 +6,7 @@
<%= partial :views, locals: { list: list, mode: mode } %>
-<% if params[:no_threads] %>
+<% if no_threads %>
<div class="alert alert-info">
There were no threads that started this month, showing you all messages instead.
</div>
@@ -29,4 +29,4 @@
</table>
</div>
-<%= partial :pagination, locals: { current_page: current_page, max_pages: max_pages } %> \ No newline at end of file
+<%= partial :pagination, locals: { current_page: current_page, max_pages: max_pages } %>