aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2007-11-14 00:11:31 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2007-11-14 00:11:31 +0000
commit968f8cbe8941af5419cc173fc7ea937df6ba0038 (patch)
tree17346e9c2c25b22131a92cb53fc57d0aa89782b7 /web
parentAdd correct timestamp to feeds (diff)
downloadpackages-968f8cbe8941af5419cc173fc7ea937df6ba0038.tar.gz
packages-968f8cbe8941af5419cc173fc7ea937df6ba0038.tar.bz2
packages-968f8cbe8941af5419cc173fc7ea937df6ba0038.zip
Refactor lastupdated timestamps, so that RSS and HTML have the same page timestamp.
Diffstat (limited to 'web')
-rw-r--r--web/controller.py21
-rw-r--r--web/lib/headers.py5
-rw-r--r--web/templates/index.xml3
-rw-r--r--web/templates/layout.html3
4 files changed, 16 insertions, 16 deletions
diff --git a/web/controller.py b/web/controller.py
index 156b8d9..78ca356 100644
--- a/web/controller.py
+++ b/web/controller.py
@@ -79,7 +79,6 @@ class Root(object):
day_list = latest_per_day(latest_entries, left_daycount)
latest_entry = entry_filter.latest_entry()
- updated = lastmodified_rightcontent(latest_entry)
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
@@ -90,7 +89,7 @@ class Root(object):
kwds = sanitize_query_string(kwds)
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
- lastupdate = updated, safeqs = kwds,
+ lastupdate = latest_entry, safeqs = kwds,
pagetitle = pagetitle)
@cherrypy.expose
@@ -133,13 +132,12 @@ class Root(object):
pagetitle = "/verbump/"
latest_entry = entry_filter.latest_entry()
- updated = lastmodified_rightcontent(latest_entry)
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
- lastupdate = updated, pagetitle = pagetitle,
+ lastupdate = latest_entry, pagetitle = pagetitle,
safeqs = kwds)
@cherrypy.expose
@@ -172,13 +170,12 @@ class Root(object):
pagetitle = "/newpackage/"
latest_entry = entry_filter.latest_entry()
- updated = lastmodified_rightcontent(latest_entry)
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
- lastupdate = updated, pagetitle = pagetitle,
+ lastupdate = latest_entry, pagetitle = pagetitle,
safeqs = kwds)
@cherrypy.expose
@@ -231,13 +228,12 @@ class Root(object):
pagetitle += "/%s/" % (mode, )
latest_entry = entry_filter.latest_entry()
- updated = lastmodified_rightcontent(latest_entry)
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
- lastupdate = updated, pagetitle = pagetitle,
+ lastupdate = latest_entry, pagetitle = pagetitle,
safeqs = kwds)
@cherrypy.expose
@@ -284,7 +280,6 @@ class Root(object):
day_list = latest_per_day(latest_entries, left_daycount)
latest_entry = entry_filter.latest_entry()
- updated = lastmodified_rightcontent(latest_entry)
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
@@ -293,7 +288,7 @@ class Root(object):
kwds = sanitize_query_string(kwds)
return template.render(arches = arches,
daylist = day_list, center_categories = rows,
- lastupdate = updated, safeqs = kwds, sums = sums,
+ lastupdate = latest_entry, safeqs = kwds, sums = sums,
pagetitle = pagetitle)
@cherrypy.expose
@@ -340,13 +335,12 @@ class Root(object):
pagetitle = "/category/%s/" % (category, )
latest_entry = entry_filter.latest_entry()
- updated = lastmodified_rightcontent(latest_entry)
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
- lastupdate = updated, pagetitle = pagetitle,
+ lastupdate = latest_entry, pagetitle = pagetitle,
safeqs = kwds)
@cherrypy.expose
@@ -398,13 +392,12 @@ class Root(object):
day_list = latest_per_day(left_entrylist, left_daycount)
latest_entry = entry_filter.latest_entry()
- updated = lastmodified_rightcontent(latest_entry)
http_lastmodified = lastmodified_httpheader(latest_entry)
cherrypy.response.headers['Last-Modified'] = http_lastmodified
kwds = sanitize_query_string(kwds)
return template.render(arches = arches,
daylist = day_list, center_pkgs = center_pkgs,
- lastupdate = updated, pagetitle = pagetitle,
+ lastupdate = latest_entry, pagetitle = pagetitle,
safeqs = kwds)
@cherrypy.expose
diff --git a/web/lib/headers.py b/web/lib/headers.py
index 2fce8b1..5f7986a 100644
--- a/web/lib/headers.py
+++ b/web/lib/headers.py
@@ -15,6 +15,11 @@ def lastmodified_httpheader(latest_entry):
fmt = '%a, %d %b %Y %H:%M:%S UTC'
return _lastmodified_strftime(fmt, latest_entry)
+def lastmodified_rss(latest_entry):
+ """return a RSS time string of the latest entry"""
+ fmt = '%Y-%m-%dT%H:%M:%SZ'
+ return _lastmodified_strftime(fmt, latest_entry)
+
def pageexpire_timestamp():
expire_ts = int(time())
# Work out when the LAST 30 minute window was
diff --git a/web/templates/index.xml b/web/templates/index.xml
index f559fb1..10bd93c 100644
--- a/web/templates/index.xml
+++ b/web/templates/index.xml
@@ -3,6 +3,7 @@
from genshi import HTML
import web.model as model
import web.lib.links as links
+from web.lib.headers import lastmodified_rss
def absurl(path=''):
return links.absurl(path, safeqs)
def relurl(path=''):
@@ -19,7 +20,7 @@ from datetime import datetime
<generator url="http://packages.gentoo.org/">Gentoo Packages2</generator>
<link rel="alternate" href="${absurl(self)}" type="text/html"/>
<link rel="self" href="${absurl(pagerss)}" type="application/atom+xml"/>
- <updated>${datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")}</updated>
+ <updated>${lastmodified_rss(lastupdate)}</updated>
<entry py:for="pkg in center_pkgs">
<title>${pkg.atom.cpvstr}</title>
diff --git a/web/templates/layout.html b/web/templates/layout.html
index 154238b..7a17b27 100644
--- a/web/templates/layout.html
+++ b/web/templates/layout.html
@@ -2,6 +2,7 @@
<?python from genshi import HTML ?>
<?python import web.model as model ?>
<?python import web.lib.links as links ?>
+<?python from web.lib.headers import lastmodified_rightcontent ?>
<?python
def absurl(path='',qs=''):
if qs == '':
@@ -53,7 +54,7 @@ def alpha_url(baseurl):
<py:match path="rightcontent" once="true">
<div id="rightcontent">
<p class="update">
- Last update:<br />${HTML(lastupdate)}
+ Last update:<br />${HTML(lastmodified_rightcontent(lastupdate))}
</p>
<div>