Fix generation of static templates URLs for sitemap.xml
authorJonathan S. Katz <jonathan.katz@excoventures.com>
Wed, 2 May 2018 16:05:49 +0000 (12:05 -0400)
committerJonathan S. Katz <jonathan.katz@excoventures.com>
Wed, 2 May 2018 17:26:45 +0000 (13:26 -0400)
Cause of issue is speculated to be due to different relative path
handling since upgrade of Django versions.  For the static pages,
the path is handled relative to the file that is generating the
URLs for the sitemap.

pgweb/core/struct.py

index 61eb3125a3a8150fc4460ed9fb4244f34313fcda..b04d8b82a6eddd9fe7004e04839c74b669973454 100644 (file)
@@ -6,8 +6,10 @@ def get_struct():
        yield ('support/versioning', None)
 
        # Enumerate all the templates that will generate pages
-       for root, dirs, files in os.walk('../templates/pages'):
-               r=root[19:] # Cut out ../templates/pages
+       pages_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../templates/pages/'))
+       for root, dirs, files in os.walk(pages_dir):
+               # Cut out the reference to the absolute root path
+               r = '' if root == pages_dir else os.path.relpath(root, pages_dir)
                for f in files:
                        if f.endswith('.html'):
                                yield (os.path.join(r, f)[:-5] + "/",