diff options
author | 2015-03-14 16:24:34 +0100 | |
---|---|---|
committer | 2015-03-14 16:24:34 +0100 | |
commit | f1bd68a8734085d101a2aea18fa2220201a6ca60 (patch) | |
tree | f3b054fac94322ab087fad249de0b83ad8703f65 | |
parent | Prepend GLSA (diff) | |
download | security-f1bd68a8734085d101a2aea18fa2220201a6ca60.tar.gz security-f1bd68a8734085d101a2aea18fa2220201a6ca60.tar.bz2 security-f1bd68a8734085d101a2aea18fa2220201a6ca60.zip |
Rework date handling
-rw-r--r-- | lib/glsav1.rb | 5 | ||||
-rw-r--r-- | lib/helpers.rb | 8 | ||||
-rw-r--r-- | views/glsa/glsav1.erb | 4 | ||||
-rw-r--r-- | views/index.erb | 2 | ||||
-rw-r--r-- | views/layout.erb | 2 |
5 files changed, 14 insertions, 7 deletions
diff --git a/lib/glsav1.rb b/lib/glsav1.rb index 789de2b..0ecea87 100644 --- a/lib/glsav1.rb +++ b/lib/glsav1.rb @@ -1,3 +1,5 @@ +require 'date' + # A version 1 GLSA class GLSAv1 attr_reader :id, :title, :synopsis, :product, :date, :revised, :revision, :bugs, :access, :packages, @@ -8,9 +10,10 @@ class GLSAv1 @title = xml.xpath('/glsa/title/text()').first.content @synopsis = xml.xpath('/glsa/synopsis/text()').first.content @product = xml.xpath('/glsa/product/text()').first.content - @date = xml.xpath('/glsa/announced/text()').first.content + @date = DateTime.parse(xml.xpath('/glsa/announced/text()').first.content) @revised, @revision = xml.xpath('/glsa/revised/text()').first.content.split(': ') + @revised = DateTime.parse(@revised) @bugs = xml.xpath('/glsa/bug/text()').map {|bug_node| bug_node.content.to_i } @access = xml.xpath('/glsa/access/text()').first.content diff --git a/lib/helpers.rb b/lib/helpers.rb index 34ed17f..9a2f0f1 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -31,6 +31,10 @@ helpers do text.gsub('<code>', '<pre>').gsub('</code>', '</pre>').gsub(/ +/, ' ').chomp end + def date_format(d) + d.strftime('%B %d, %Y') + end + # Returns the comparator in the format needed for the XML def xml_comp(val) COMP_MAP[val] @@ -47,13 +51,13 @@ helpers do maker.channel.link = "https://security.gentoo.org/glsa" maker.channel.description = "This feed contains new Gentoo Linux Security Advisories. Contact security@gentoo.org with questions." maker.channel.title = "Gentoo Linux Security Advisories" - maker.channel.updated = Time.now.to_s + maker.channel.updated = items.first.revised.to_s items.each do |input_item| maker.items.new_item do |item| item.link = BASE_URL + 'glsa/' + input_item.id item.title = "GLSA %s: %s" % [input_item.id, input_item.title] - item.updated = Time.now.to_s + item.updated = input_item.revised.to_s end end end.to_s diff --git a/views/glsa/glsav1.erb b/views/glsa/glsav1.erb index f779ead..d274fa0 100644 --- a/views/glsa/glsav1.erb +++ b/views/glsa/glsav1.erb @@ -57,12 +57,12 @@ <p> <strong>Release Date</strong> <br> - <%= h @glsa.date %> + <%= date_format @glsa.date %> </p> <p> <strong>Latest Revision</strong> <br> - <%= h @glsa.revised %>: <%= h @glsa.revision %> + <%= date_format @glsa.revised %>: <%= h @glsa.revision %> </p> <p> <strong>Severity</strong> diff --git a/views/index.erb b/views/index.erb index 26d8ce5..56e81ea 100644 --- a/views/index.erb +++ b/views/index.erb @@ -32,7 +32,7 @@ <tr> <th><a href="/glsa/<%= h id %>">GLSA <%= h id %></a></th> <td><%= h GLSARepository.instance[id].title %></td> - <td><%= h GLSARepository.instance[id].date %></td> + <td><%= date_format GLSARepository.instance[id].date %></td> </tr> <% end %> </table> diff --git a/views/layout.erb b/views/layout.erb index c55548e..443313b 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -5,7 +5,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="theme-color" content="#54487a"> - <meta name="description" content="The Gentoo Mailing List Archives"> + <meta name="description" content="Gentoo Security Database"> <link href="https://1b9a50f4f9de4348cd9f-e703bc50ba0aa66772a874f8c7698be7.ssl.cf5.rackcdn.com/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="https://1b9a50f4f9de4348cd9f-e703bc50ba0aa66772a874f8c7698be7.ssl.cf5.rackcdn.com/tyrian.min.css" rel="stylesheet" media="screen"> <link href="/css/main.css" rel="stylesheet" media="screen"> |