Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

57 rader
1.9 KiB

  1. # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. #
  3. # MIT License (MIT)
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a
  6. # copy of this software and associated documentation files (the "Software"),
  7. # to deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom the
  10. # Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. #
  22. # to generate sitemaps
  23. frame_xml = """<?xml version="1.0" encoding="UTF-8"?>
  24. <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">%s
  25. </urlset>"""
  26. link_xml = """\n<url><loc>%s</loc><lastmod>%s</lastmod></url>"""
  27. # generate the sitemap XML
  28. def generate(domain):
  29. global frame_xml, link_xml
  30. import urllib
  31. import webnotes
  32. # settings
  33. max_doctypes = 10
  34. max_items = 1000
  35. site_map = ''
  36. page_list = []
  37. if domain:
  38. # list of all Guest pages (static content)
  39. for r in webnotes.conn.sql("""SELECT distinct t1.name, t1.modified
  40. FROM tabPage t1, `tabPage Role` t2
  41. WHERE t1.name = t2.parent
  42. and t2.role = 'Guest'
  43. ORDER BY modified DESC"""):
  44. page_url = domain + '#!' + urllib.quote(r[0])
  45. site_map += link_xml % (page_url, r[1].strftime('%Y-%m-%d'))
  46. return frame_xml % site_map