Hi Gael, That's great! Thanks very much.
I wonder how I can then create a URL like http://www.mydomain.com/sitemap.txt instead of http://www.mydomain.com/init/default/sitemap.txt On Tuesday, October 20, 2015 at 5:30:03 PM UTC+8, Gael Princivalle wrote: > > Hello Joe. > > I use the Scheduler for that, for making every day a new updated sitemap. > I use txt sitemaps because I've saw that if an XML sitemap is too long > Google don't take care of it. In txt yes. > > Here is an example: > > def sitemap_txt_auto(): > import os > from gluon.myregex import regex_expose > # Statics URLs > exclusions = ['download', 'call', 'data', 'upload', 'browse', 'delete'] > ctldir = os.path.join(request.folder,"controllers") > ctls=os.listdir(ctldir) > if 'appadmin.py' in ctls: ctls.remove('appadmin.py') > if 'manage.py' in ctls: ctls.remove('manage.py') > if 'default.py.1' in ctls: ctls.remove('default.py.1') > sitemap='http://www.yourdomain.com' > for ctl in ctls: > if ctl.endswith(".bak") == False: > filename = os.path.join(ctldir,ctl) > data = open(filename, 'r').read() > functions = regex_expose.findall(data) > for f in functions: > if not any(f in s for s in exclusions): # if function is > not in exclustions > sitemap += '\r\n' > sitemap += 'http://www.yourdomain.com/%s' % (f) > # Dynamic URLs > # News > news = db(db.news.on_line == True).select(db.news.ALL) > for item in news: > sitemap += '\r\n' > sitemap += 'http://www.yourdomain.com/news?id=%s' % (str(item.id)) > # And other dynamic urls > file = open('%s/static/sitemaps/sitemap.txt' %request.folder, 'w') > file.write(sitemap) > file.close() > #FOr being sure that the sitemap have been made. > email_sent = mail.send( > to = '[email protected] <javascript:>', > subject = 'Sitemap youdomain', > message = 'The sitemap have been generated with > success.') > db.commit() > > from gluon.scheduler import Scheduler > Scheduler(db,dict(sitemap_txt_auto=sitemap_txt_auto)) > > Il giorno sabato 10 ottobre 2015 03:55:13 UTC+2, Joe ha scritto: >> >> What is the best way to implement a sitemap for a Web2py site? Is there a >> Web2py code to generate the sitemap or I should use a third party sitemap >> generator? If so, should I place the XML file in the static folder? >> I'd appreciate some advise on this. >> Thanks very much. >> Cheers, >> Joe >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

