You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 line
970 B

  1. # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. import urllib
  5. import frappe
  6. from frappe.utils import get_request_site_address, get_datetime, nowdate
  7. from frappe.website.router import get_pages, get_all_page_context_from_doctypes
  8. no_cache = 1
  9. no_sitemap = 1
  10. base_template_path = "templates/pages/sitemap.xml"
  11. def get_context(context):
  12. """generate the sitemap XML"""
  13. host = get_request_site_address()
  14. links = []
  15. for route, page in get_pages().iteritems():
  16. if not page.no_sitemap:
  17. links.append({
  18. "loc": urllib.basejoin(host, urllib.quote(page.name.encode("utf-8"))),
  19. "lastmod": nowdate()
  20. })
  21. for route, data in get_all_page_context_from_doctypes().iteritems():
  22. links.append({
  23. "loc": urllib.basejoin(host, urllib.quote((route or "").encode("utf-8"))),
  24. "lastmod": get_datetime(data.get("modified")).strftime("%Y-%m-%d")
  25. })
  26. return {"links":links}