mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
updates to website: removed webnotes.cms
This commit is contained in:
38
website/helpers/sitemap.py
Normal file
38
website/helpers/sitemap.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd.
|
||||
# License: GNU General Public License (v3). For more information see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
frame_xml = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">%s
|
||||
</urlset>"""
|
||||
|
||||
link_xml = """\n<url><loc>%s</loc><lastmod>%s</lastmod></url>"""
|
||||
|
||||
# generate the sitemap XML
|
||||
def generate(domain):
|
||||
global frame_xml, link_xml
|
||||
import urllib, os
|
||||
import webnotes
|
||||
import website.utils
|
||||
|
||||
# settings
|
||||
max_doctypes = 10
|
||||
max_items = 1000
|
||||
|
||||
site_map = ''
|
||||
page_list = []
|
||||
|
||||
if domain:
|
||||
# list of all pages in web cache
|
||||
for doctype in website.utils.page_map:
|
||||
d = website.utils.page_map[doctype];
|
||||
pages = webnotes.conn.sql("""select page_name, `modified`
|
||||
from `tab%s` where ifnull(%s,0)=1
|
||||
order by modified desc""" % (doctype, d.condition_field))
|
||||
|
||||
for p in pages:
|
||||
page_url = os.path.join(domain, urllib.quote(p[0]) + '.html')
|
||||
modified = p[1].strftime('%Y-%m-%d')
|
||||
site_map += link_xml % (page_url, modified)
|
||||
|
||||
return frame_xml % site_map
|
||||
Reference in New Issue
Block a user