X-Git-Url: https://source.tree.se/git?p=treecutter.git;a=blobdiff_plain;f=treecutter%2Fsitemap.py;h=688cb0cdaad079970c8e7657cf38efab1e5893f0;hp=e7a2e4b3b99a0c8e7cee21f8e2c11f53073f4601;hb=0eed3d6adc33701f2eab5dd7c564ef8833bdbb60;hpb=8e8fa071433cb48cc230ba74facbcfb644fa54c2 diff --git a/treecutter/sitemap.py b/treecutter/sitemap.py index e7a2e4b..688cb0c 100644 --- a/treecutter/sitemap.py +++ b/treecutter/sitemap.py @@ -20,6 +20,10 @@ class Sitemap(): self._tranlang = {} self._tmptarget = tempfile.mkdtemp()+'/' + # The sitemap uses a trie structure to keep track of links + # A link represents the path to the document and the link + # representing the text on the site. + # A link can have several pages in different languages. def add_link(self, link): tokens = filter(None,re.split(r'(^/[\w-]*/|[\w-]*/)',link)) self._tree.add(tokens,Link(link)) @@ -39,9 +43,13 @@ class Sitemap(): except IOError, what_error: print 'INFO: Could not read sitemap.txt - one will be created' + # Create a set of the current tree for comparison with the + # directory scan def set(self): return set(link.link() for link in self._tree) + # Main driver in the application processing the documents + # in the collected sitemap def process(self, style): t1 = time() print "Prepareing the input" @@ -67,7 +75,7 @@ class Sitemap(): print "Template [%5.2f s]" % (round(t5-t4,2)) t6 = time() res = set() - cwd = os.getcwd() + # Collect all files used by the documents for link in self._tree: res = res.union(link.resources()) for f in res: @@ -75,6 +83,8 @@ class Sitemap(): mkdir_p(os.path.dirname(outfile)) shutil.copyfile(f,outfile) print "Resources[%5.2f s]" % (round(t6-t5,2)) + # TODO: Improve the sitemap, it is a page that is generated from + # the ground up and added a bit adhoc. sitmaplink = Link('/sitemap') for l in self._sitelang: sitmaplink.add_page((l,'/sitemap.'+l+'.xml'))