]> Shamusworld >> Repos - ardour-manual/blobdiff - build.py
no-op to get a push
[ardour-manual] / build.py
index 8ac84d4efb4e93859685ad7fb7f0962ebad7de26..b53b439f13bcd0039ec09e9cb0f8a9390a4ffcb5 100755 (executable)
--- a/build.py
+++ b/build.py
@@ -112,12 +112,18 @@ def GetFileStructure():
                        level = PartToLevel(hdr['part'])
                        hdr['level'] = level
                        fnames[level] = MakeFilename(hdr['title'])
-                       fullName = ''
 
-                       for i in range(level + 1):
-                               fullName = fullName + fnames[i] + '/'
+                       # Ickyness--user specified URIs
+                       if 'uri' in hdr:
+                               hdr['filename'] = hdr['uri']
+                       else:
+                               fullName = ''
+
+                               for i in range(level + 1):
+                                       fullName = fullName + fnames[i] + '/'
+
+                               hdr['filename'] = fullName.rstrip('/')
 
-                       hdr['filename'] = fullName.rstrip('/')
                        fs.append(hdr)
 
                        if ('include' not in hdr) and (level > 0):
@@ -253,7 +259,8 @@ def BuildList(lst, fs, pagePos, cList):
                nextPos = lst[i + 1] if i + 1 < len(lst)  else len(fs)
 
                active = ' class=active' if curPos == pagePos else ''
-               content = content + '<dt' + active + '><a href="/' + fs[curPos]['filename'] + '/">' + fs[curPos]['title'] + '</a></dt><dd' + active + '>'
+               menuTitle = fs[curPos]['menu_title'] if 'menu_title' in fs[curPos] else fs[curPos]['title']
+               content = content + '<dt' + active + '><a href="/' + fs[curPos]['filename'] + '/">' + menuTitle + '</a></dt><dd' + active + '>'
 
                # If the current page is our page, and it has children, enumerate them
                if curPos == pagePos:
@@ -316,11 +323,6 @@ if os.access(siteDir, os.F_OK):
 
 shutil.copytree('./source', siteDir)
 
-# Yeah, need to make a symlink in include/ too :-P
-# [this will go away when the rewrite happens]
-if (os.access('include/_manual', os.F_OK) == False):
-       os.symlink('../_manual/', 'include/_manual')
-
 
 # Read the template, and fix the stuff that's fixed for all pages
 temp = open('page-template.txt')
@@ -465,8 +467,9 @@ for header in fileStruct:
        page = page.replace('{% prevnext %}', prevnext)
        page = page.replace('{{ content }}', content + more)
 
-       # Create the directory for the index.html file to go into
-       os.mkdir(siteDir + header['filename'], 0o775)
+       # Create the directory for the index.html file to go into (we use makedirs,
+       # because we have to in order to accomodate the 'uri' keyword)
+       os.makedirs(siteDir + header['filename'], 0o775, exist_ok=True)
 
        # Finally, write the file!
        destFile = open(siteDir + header['filename'] + '/index.html', 'w')