mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-13 13:12:42 +00:00
Include last modified date in sitemap
This commit is contained in:
@ -12,7 +12,7 @@ class Version(PgModel, models.Model):
|
|||||||
relnotes = models.CharField(max_length=32, null=False, blank=False)
|
relnotes = models.CharField(max_length=32, null=False, blank=False)
|
||||||
current = models.BooleanField(null=False, blank=False, default=False)
|
current = models.BooleanField(null=False, blank=False, default=False)
|
||||||
supported = models.BooleanField(null=False, blank=False, default=True)
|
supported = models.BooleanField(null=False, blank=False, default=True)
|
||||||
docsloaded = models.DateTimeField(null=True, blank=True, help_text="The timestamp of the latest docs load. Really only used for developer docs for now, but set for all of them.")
|
docsloaded = models.DateTimeField(null=True, blank=True, help_text="The timestamp of the latest docs load. Used to control indexing and info on developer docs.")
|
||||||
firstreldate = models.DateField(null=False, blank=False, help_text="The date of the .0 release in this tree")
|
firstreldate = models.DateField(null=False, blank=False, help_text="The date of the .0 release in this tree")
|
||||||
eoldate = models.DateField(null=False, blank=False, help_text="The planned EOL date for this tree")
|
eoldate = models.DateField(null=False, blank=False, help_text="The planned EOL date for this tree")
|
||||||
|
|
||||||
|
@ -138,8 +138,10 @@ def sitemap(request):
|
|||||||
pages+=1
|
pages+=1
|
||||||
x.startElement('url', {})
|
x.startElement('url', {})
|
||||||
x.add_xml_element('loc', 'http://www.postgresql.org/%s' % urllib.quote(p[0]))
|
x.add_xml_element('loc', 'http://www.postgresql.org/%s' % urllib.quote(p[0]))
|
||||||
if p[1]:
|
if len(p) > 1 and p[1]:
|
||||||
x.add_xml_element('priority', unicode(p[1]))
|
x.add_xml_element('priority', unicode(p[1]))
|
||||||
|
if len(p) > 2 and p[2]:
|
||||||
|
x.add_xml_element('lastmod', p[2].isoformat() + "Z")
|
||||||
x.endElement('url')
|
x.endElement('url')
|
||||||
x.endElement('urlset')
|
x.endElement('urlset')
|
||||||
x.endDocument()
|
x.endDocument()
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
from models import DocPage
|
from django.db import connection
|
||||||
from core.models import Version
|
from core.models import Version
|
||||||
|
|
||||||
def get_struct():
|
def get_struct():
|
||||||
now = date.today()
|
now = date.today()
|
||||||
currentversion = Version.objects.get(current=True)
|
currentversion = Version.objects.get(current=True)
|
||||||
|
|
||||||
for d in DocPage.objects.all().extra(where=['version in (select tree from core_version where supported)']):
|
# Can't use a model here, because we don't (for some reason) have a
|
||||||
yield ('docs/%s/static/%s' % (d.version, d.file),
|
# hard link to the versions table here
|
||||||
None)
|
curs = connection.cursor()
|
||||||
|
curs.execute("SELECT d.version, d.file, v.docsloaded FROM docs d INNER JOIN core_version v ON v.tree=d.version WHERE v.supported")
|
||||||
|
for version, filename, loaded in curs.fetchall():
|
||||||
|
yield ('docs/%s/static/%s' % (version, filename),
|
||||||
|
None, loaded)
|
||||||
#FIXME ^ do something smart with priorities on older
|
#FIXME ^ do something smart with priorities on older
|
||||||
#versions
|
#versions
|
||||||
if d.version == currentversion.tree:
|
if version == currentversion.tree:
|
||||||
yield ('docs/current/static/%s' % d.file,
|
yield ('docs/current/static/%s' % filename,
|
||||||
1.0)
|
1.0, loaded)
|
||||||
|
@ -4,7 +4,7 @@ def get_all_pages_struct():
|
|||||||
"""
|
"""
|
||||||
Return an iterator over all distinct pages on the site.
|
Return an iterator over all distinct pages on the site.
|
||||||
Each page is returned as a tuple consisting of:
|
Each page is returned as a tuple consisting of:
|
||||||
(url, search weight)
|
(url, search weight, last_modified)
|
||||||
|
|
||||||
It will do so by looking for the module "struct" in all
|
It will do so by looking for the module "struct" in all
|
||||||
installed applications, and calling the get_struct() function
|
installed applications, and calling the get_struct() function
|
||||||
|
Reference in New Issue
Block a user