[sitemap] [fixes]
This commit is contained in:
parent
69b410a2ed
commit
09480e2241
@ -14,25 +14,40 @@ def generate(domain):
|
|||||||
import urllib, os
|
import urllib, os
|
||||||
import webnotes
|
import webnotes
|
||||||
import webnotes.webutils
|
import webnotes.webutils
|
||||||
|
from webnotes.utils import nowdate
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
max_doctypes = 10
|
|
||||||
max_items = 1000
|
max_items = 1000
|
||||||
|
count = 0
|
||||||
|
|
||||||
site_map = ''
|
site_map = ''
|
||||||
page_list = []
|
|
||||||
|
|
||||||
if domain:
|
if domain:
|
||||||
# list of all pages in web cache
|
today = nowdate()
|
||||||
for doctype in webnotes.webutils.page_map:
|
|
||||||
d = webnotes.webutils.page_map[doctype];
|
# generated pages
|
||||||
|
for doctype, opts in webnotes.webutils.get_generators().items():
|
||||||
pages = webnotes.conn.sql("""select page_name, `modified`
|
pages = webnotes.conn.sql("""select page_name, `modified`
|
||||||
from `tab%s` where ifnull(%s,0)=1
|
from `tab%s` where ifnull(%s,0)=1
|
||||||
order by modified desc""" % (doctype, d.condition_field))
|
order by modified desc""" % (doctype, opts.get("condition_field")))
|
||||||
|
|
||||||
for p in pages:
|
for p in pages:
|
||||||
|
if count >= max_items: break
|
||||||
page_url = os.path.join(domain, urllib.quote(p[0]))
|
page_url = os.path.join(domain, urllib.quote(p[0]))
|
||||||
modified = p[1].strftime('%Y-%m-%d')
|
modified = p[1].strftime('%Y-%m-%d')
|
||||||
site_map += link_xml % (page_url, modified)
|
site_map += link_xml % (page_url, modified)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
if count >= max_items: break
|
||||||
|
|
||||||
|
# standard pages
|
||||||
|
for page, opts in webnotes.get_config()["web"]["pages"].items():
|
||||||
|
if "no_cache" in opts:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if count >= max_items: break
|
||||||
|
page_url = os.path.join(domain, urllib.quote(page))
|
||||||
|
modified = today
|
||||||
|
site_map += link_xml % (page_url, modified)
|
||||||
|
count += 1
|
||||||
|
|
||||||
return frame_xml % site_map
|
return frame_xml % site_map
|
||||||
|
Loading…
x
Reference in New Issue
Block a user