forked from 0x2620/pandora
include overview text in sitemap.xml
This commit is contained in:
parent
9d6a29a4f4
commit
4445a9086c
4 changed files with 28 additions and 7 deletions
|
@ -163,6 +163,22 @@ def update_sitemap(base_url):
|
|||
el = ET.SubElement(video, "video:duration")
|
||||
el.text = "%s" % int(duration)
|
||||
|
||||
if Text.objects.filter(name='').exclude(text='').exists():
|
||||
t = Text.objects.filter(name='')[0]
|
||||
url = ET.SubElement(urlset, "url")
|
||||
# URL of the page. This URL must begin with the protocol (such as http)
|
||||
loc = ET.SubElement(url, "loc")
|
||||
loc.text = absolute_url('/texts')
|
||||
# This date should be in W3C Datetime format, can be %Y-%m-%d
|
||||
lastmod = ET.SubElement(url, "lastmod")
|
||||
lastmod.text = t.modified.strftime("%Y-%m-%d")
|
||||
# always, hourly, daily, weekly, monthly, yearly, never
|
||||
changefreq = ET.SubElement(url, "changefreq")
|
||||
changefreq.text = 'monthly'
|
||||
# priority of page on site values 0.1 - 1.0
|
||||
priority = ET.SubElement(url, "priority")
|
||||
priority.text = '1.0'
|
||||
|
||||
for t in Text.objects.filter(Q(status='featured')|Q(status='public')):
|
||||
url = ET.SubElement(urlset, "url")
|
||||
# URL of the page. This URL must begin with the protocol (such as http)
|
||||
|
|
|
@ -56,6 +56,9 @@ class Text(models.Model):
|
|||
|
||||
@classmethod
|
||||
def get(cls, id):
|
||||
if id == '':
|
||||
return cls.objects.get(name='')
|
||||
else:
|
||||
id = id.split(':')
|
||||
username = id[0]
|
||||
name = ":".join(id[1:])
|
||||
|
|
|
@ -437,12 +437,12 @@ def upload(request):
|
|||
response = json_response(status=400, text='this request requires POST')
|
||||
return render_to_json_response(response)
|
||||
|
||||
def text(request, id):
|
||||
def text(request, id=''):
|
||||
id = id.replace('_', ' ').replace('\t', '_')
|
||||
try:
|
||||
|
||||
text = models.Text.get(id)
|
||||
if not text.accessible(request.user):
|
||||
if id != '' and not text.accessible(request.user):
|
||||
raise
|
||||
template = 'text.html'
|
||||
context = RequestContext(request, {
|
||||
|
@ -454,7 +454,7 @@ def text(request, id):
|
|||
'title': ox.strip_tags(text.name),
|
||||
'url': request.build_absolute_uri(text.get_absolute_url()),
|
||||
})
|
||||
except models.Text.DoesNotExist:
|
||||
except:
|
||||
template = 'index.html'
|
||||
context = RequestContext(request, {
|
||||
'base_url': request.build_absolute_uri('/'),
|
||||
|
|
|
@ -37,6 +37,8 @@ urlpatterns = patterns('',
|
|||
(r'^text/(?P<id>.*?)/icon(?P<size>\d*).jpg$', 'text.views.icon'),
|
||||
(r'^texts/(?P<id>.*?)/text.pdf$', 'text.views.pdf'),
|
||||
(r'^texts/(?P<id>.*?)/text.pdf.html$', 'text.views.pdf_viewer'),
|
||||
(r'^texts/$', 'text.views.text'),
|
||||
(r'^texts/(?P<id>.*?)/\d+$', 'text.views.text'),
|
||||
(r'^texts/(?P<id>.*?)$', 'text.views.text'),
|
||||
(r'^robots.txt$', serve_static_file, {'location': os.path.join(settings.STATIC_ROOT, 'robots.txt'), 'content_type': 'text/plain'}),
|
||||
(r'^favicon.ico$', serve_static_file, {'location': os.path.join(settings.STATIC_ROOT, 'png/icon.16.png'), 'content_type': 'image/x-icon'}),
|
||||
|
|
Loading…
Reference in a new issue