commit:     35278c94afd68d99416398e4dff1a9a5499db8f4
Author:     Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Sun Feb 22 00:28:54 2015 +0000
Commit:     Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 00:28:54 2015 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/ag-web.git;a=commit;h=35278c94

show raw mesages if there are no threads

---
 ag-web.rb           | 5 +++++
 views/listmonth.erb | 6 ++++++
 2 files changed, 11 insertions(+)

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>

Reply via email to