25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sitemap.py 918 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. import urllib
  5. import webnotes
  6. import webnotes.webutils
  7. from webnotes.utils import get_request_site_address
  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 l in webnotes.conn.sql("""select `tabWebsite Sitemap`.page_name, `tabWebsite Sitemap`.lastmod
  16. from `tabWebsite Sitemap`, `tabWebsite Sitemap Config`
  17. where
  18. `tabWebsite Sitemap`.website_sitemap_config = `tabWebsite Sitemap Config`.name
  19. and ifnull(`tabWebsite Sitemap Config`.no_sitemap, 0)=0""",
  20. as_dict=True):
  21. links.append({
  22. "loc": urllib.basejoin(host, urllib.quote(l.page_name.encode("utf-8"))),
  23. "lastmod": l.lastmod
  24. })
  25. return {"links":links}