sitemap: support for draft, levels and templates
[treecutter.git] / treecutter / directory.py
index 1b7a3e9f3ee6562ff9bfedd51ea0bdac409b1d7c..d4a0973cbd6cb3eee76906a7f6babf56585a5955 100644 (file)
@@ -3,6 +3,7 @@ import os
 import fnmatch
 from lxml import etree
 import treecutter.constants as const
+from treecutter.docbook import Docbook
 import re
 
 class Directory():
@@ -17,10 +18,18 @@ class Directory():
             for filename in filenames:
                 if fnmatch.fnmatch(filename, '*.xml'):
                     file_ = os.path.join(dirname,filename)
-                    doc = etree.parse(file_)
-                    title = doc.xpath(u'/db:article/db:info/db:title',namespaces=const.XPATH)
-                    menu  = doc.xpath(u'/db:article/db:info/db:titleabbrev',namespaces=const.XPATH)
-                    if title and menu:
+                    doc = Docbook(file_)
+                    (title, menu) = doc.title()
+                    draft = doc.status() == "draft"
+                    level = doc.userlevel()
+
+#                    doc = etree.parse(file_)
+#                    title = doc.xpath(u'/db:article/db:info/db:title',namespaces=const.XPATH)
+#                    menu  = doc.xpath(u'/db:article/db:info/db:titleabbrev',namespaces=const.XPATH)
+#                    draft = doc.xpath(u'/db:article[@status="draft"]',namespaces=const.XPATH)
+                    if draft and draftflag:
+                        draft = False
+                    if title and menu and not draft and level <= levelflag:
                         base = self._basepath.match(file_).group()
                         link = base.replace('index','')[1:]
                         self._tree.append(link)