diff options
author | Alex Legler <alex@a3li.li> | 2015-02-22 21:06:43 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2015-02-22 21:06:43 +0100 |
commit | b0086f9f9cb9be97d0cf2715330f57075ea843c0 (patch) | |
tree | eafd8b075a93dc4e0a9c87630dfd899da15cf306 | |
parent | Cache message counts (diff) | |
download | frontend-b0086f9f9cb9be97d0cf2715330f57075ea843c0.tar.gz frontend-b0086f9f9cb9be97d0cf2715330f57075ea843c0.tar.bz2 frontend-b0086f9f9cb9be97d0cf2715330f57075ea843c0.zip |
Move full archives list to a separate page
-rw-r--r-- | ag-web.rb | 6 | ||||
-rw-r--r-- | lib/helpers.rb | 1 | ||||
-rw-r--r-- | lib/index.rb | 20 | ||||
-rw-r--r-- | public/css/main.css | 16 | ||||
-rw-r--r-- | views/index.erb | 60 | ||||
-rw-r--r-- | views/indexentry.erb | 32 | ||||
-rw-r--r-- | views/layout.erb | 15 | ||||
-rw-r--r-- | views/lists.erb | 47 |
8 files changed, 149 insertions, 48 deletions
@@ -161,6 +161,12 @@ get '/:list/message/:msgid' do end end +get '/lists' do + @nav = :lists + erb :lists +end + get '/' do + @nav = :index erb :index end diff --git a/lib/helpers.rb b/lib/helpers.rb index 405975b..88b8f59 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -1,4 +1,3 @@ -require 'date' require 'rinku' require 'erb' diff --git a/lib/index.rb b/lib/index.rb index de3d4f0..3cc7537 100644 --- a/lib/index.rb +++ b/lib/index.rb @@ -24,6 +24,26 @@ def threads_in_month(list, year, month, page) ) end +def most_recent(list, n) + result = $es.search( + index: 'ml-' + list, + size: n, + body: { + sort: { + date: 'desc', + } + } + ) + + if result['hits']['total'] == 0 + return [] + else + return result['hits']['hits'] + end +rescue => e + [] +end + def messages_in_month(list, year, month, page) $es.search( index: 'ml-' + list, diff --git a/public/css/main.css b/public/css/main.css index bd52860..38d482b 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -6,11 +6,13 @@ } @media (min-width: 768px) { - .ag-message-table { + .ag-message-table, + .ag-mostrecent-table { width: 100%; table-layout: fixed; } + .ag-mostrecent-table td, .ag-message-table td { text-overflow: ellipsis; max-height: 1.2em; @@ -25,6 +27,18 @@ .ag-message-table-from { width: 18%; } + + .ag-mostrecent-table-author { + width: 30%; + } + + .ag-mostrecent-header { + margin-top: 5px; + } + + .ag-index-actions { + margin-top: 2em; + } } .ag-quote { diff --git a/views/index.erb b/views/index.erb index c2cee2c..0ca71c9 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1,47 +1,23 @@ <h1 class="first-header">Gentoo Mailing List Archives</h1> -<h2>Current Mailing Lists</h2> +<p class="lead"> + Here you can find the archives of our most important mailing lists. +</p> +<p> + For a complete list of available archives, see the <a href="/lists" class="btn btn-primary btn-xs"><i class="fa fa-fw fa-archive"></i> All Archives</a> section. +</p> -<div class="row"> - <div class="col-xs-12 col-md-6"> - <div class="list-group"> - <% $config['active_lists'].each do |list| %> - <a href="<%= h list %>/" class="list-group-item"> - <span class="fa fa-fw fa-archive"></span> - <%= h list %> - <span class="badge"><%= MessageCountCache.instance[list] %></span> - </a> - <% end %> - </div> - </div> - <div class="col-xs-12 col-md-6"> - <div class="alert alert-info" role="alert"> - <strong>How to Participate</strong><br> - Please see our <a href="https://www.gentoo.org/main/en/lists.xml" class="alert-link">Mailing List information page</a> for more information on - how you can subscribe and participate in the discussions. - </div> - </div> -</div> +<hr> -<h2>Frozen Archives</h2> +<%= partial :indexentry, locals: { list: 'gentoo-dev', blurb: '<tt>gentoo-dev</tt> is the main technical development mailing list of Gentoo.' } %> +<%= partial :indexentry, locals: { list: 'gentoo-project', blurb: '<tt>gentoo-project</tt> contains non-technical discussion and propositions for the Gentoo Council .' } %> +<%= partial :indexentry, locals: { list: 'gentoo-announce', blurb: 'Important news for all Gentoo stakeholders.' } %> +<%= partial :indexentry, locals: { list: 'gentoo-user', blurb: 'Our main support and Gentoo-related talk mailing list, <tt>gentoo-user</tt>.' } %> +<%= partial :indexentry, locals: { list: 'gentoo-commits', blurb: 'Commits. Lots of commits.' } %> +<%= partial :indexentry, locals: { list: 'gentoo-dev-announce', blurb: '<tt>gentoo-dev-announce</tt> conveys important changes to all developers and interested users.' } %> -<div class="row"> - <div class="col-xs-12 col-md-6"> - <div class="list-group"> - <% $config['frozen_lists'].each do |list| %> - <a href="<%= h list %>/" class="list-group-item"> - <span class="fa fa-fw fa-archive"></span> - <%= h list %> - <span class="badge"><%= MessageCountCache.instance[list] %></span> - </a> - <% end %> - </div> - </div> - <div class="col-xs-12 col-md-6"> - <div class="alert alert-warning" role="alert"> - <strong>Inactive Lists</strong><br> - These mailing lists are inactive. You can not post or subscribe to them any more. - Archives are provided for future reference. - </div> - </div> -</div> + +<h2>Other Lists</h2> +<p> + All other archives are available here: <a href="/lists" class="btn btn-primary"><i class="fa fa-fw fa-archive"></i> All Archives</a> +</p>
\ No newline at end of file diff --git a/views/indexentry.erb b/views/indexentry.erb new file mode 100644 index 0000000..6028ec9 --- /dev/null +++ b/views/indexentry.erb @@ -0,0 +1,32 @@ +<div class="row"> + <div class="col-xs-12 col-md-4"> + <h2 class="stick-top"><%= list %></h2> + <p> + <%= blurb %> + </p> + + <p class="ag-index-actions"> + <a class="btn btn-primary btn-block" href="/<%= list %>/threads/<%= DateTime.now.strftime '%Y-%m' %>/"><span class="fa fa-fw fa-inbox"></span> This Month's Archives</a> + <a class="btn btn-default btn-block" href="/<%= list %>/"><span class="fa fa-fw fa-inbox"></span> Complete Archives</a> + </p> + </div> + <div class="col-xs-12 col-md-8"> + <h3 class="ag-mostrecent-header">Most recent messages</h3> + <div class="table-responsive"> + <table class="table table-condensed table-hover ag-mostrecent-table"> + <tr> + <th>Subject</th> + <th class="ag-mostrecent-table-author">Author</th> + </tr> + <% most_recent(list, 5).each do |message| %> + <tr> + <td><a href="/<%= list %>/message/<%= message['_id'] %>"><%= h message['_source']['subject'] %></a></td> + <td><%= h message['_source']['from_realname'] %></td> + </tr> + <% end %> + </table> + </div> + </div> +</div> + +<hr>
\ No newline at end of file diff --git a/views/layout.erb b/views/layout.erb index 79d8794..67a7e8b 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -60,11 +60,18 @@ </div> <div class="collapse navbar-collapse navbar-main-collapse"> <ul class="nav navbar-nav"> - <% if params[:list] %> - <li><a href="/">Home</a></li> - <li class="active"><a href="/<%= params[:list] %>/"><%= params[:list] %></a></li> + <% if @nav == :index %> + <li class="active"><a href="/">Home</a></li> + <li><a href="/lists"><i class="fa fa-fw fa-archive"></i> All Archives</a></li> + <% elsif @nav == :lists %> + <li><a href="/">Home</a></li> + <li class="active"><a href="/lists"><i class="fa fa-fw fa-archive"></i> All Archives</a></li> + <% elsif params[:list] %> + <li><a href="/">Home</a></li> + <li><a href="/lists"><i class="fa fa-fw fa-archive"></i> All Archives</a></li> + <li class="active"><a href="/<%= h params[:list] %>/"><i class="fa fa-fw fa-inbox"></i> <%= h params[:list] %></a></li> <% else %> - <li class="active"><a href="/">Home</a></li> + <li><a href="/">Home</a></li> <% end %> </ul> </div> diff --git a/views/lists.erb b/views/lists.erb new file mode 100644 index 0000000..c2cee2c --- /dev/null +++ b/views/lists.erb @@ -0,0 +1,47 @@ +<h1 class="first-header">Gentoo Mailing List Archives</h1> + +<h2>Current Mailing Lists</h2> + +<div class="row"> + <div class="col-xs-12 col-md-6"> + <div class="list-group"> + <% $config['active_lists'].each do |list| %> + <a href="<%= h list %>/" class="list-group-item"> + <span class="fa fa-fw fa-archive"></span> + <%= h list %> + <span class="badge"><%= MessageCountCache.instance[list] %></span> + </a> + <% end %> + </div> + </div> + <div class="col-xs-12 col-md-6"> + <div class="alert alert-info" role="alert"> + <strong>How to Participate</strong><br> + Please see our <a href="https://www.gentoo.org/main/en/lists.xml" class="alert-link">Mailing List information page</a> for more information on + how you can subscribe and participate in the discussions. + </div> + </div> +</div> + +<h2>Frozen Archives</h2> + +<div class="row"> + <div class="col-xs-12 col-md-6"> + <div class="list-group"> + <% $config['frozen_lists'].each do |list| %> + <a href="<%= h list %>/" class="list-group-item"> + <span class="fa fa-fw fa-archive"></span> + <%= h list %> + <span class="badge"><%= MessageCountCache.instance[list] %></span> + </a> + <% end %> + </div> + </div> + <div class="col-xs-12 col-md-6"> + <div class="alert alert-warning" role="alert"> + <strong>Inactive Lists</strong><br> + These mailing lists are inactive. You can not post or subscribe to them any more. + Archives are provided for future reference. + </div> + </div> +</div> |