[library-web] Add a document path template configuration option



commit f25a1fa6f954030d35c5f0ff946d63ba6b8a22cf
Author: Frédéric Péters <fpeters 0d be>
Date:   Sat Mar 19 19:04:41 2011 +0100

    Add a document path template configuration option

 src/config.py           |    2 +-
 src/defaults.lgorc      |    3 +++
 src/lgo.py              |    9 ++++++---
 src/modtypes/base.py    |    9 ++++++---
 src/modtypes/mallard.py |    3 +--
 5 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/src/config.py b/src/config.py
index 89715dd..1987a13 100644
--- a/src/config.py
+++ b/src/config.py
@@ -36,7 +36,7 @@ _known_keys = ['ftp_gnome_org_local_copy', 'use_latest_version',
             'blacklist', 'extra_tarballs', 'symbols_dbm_filepath',
             'httxt2dbm_path', 'fast_mode', 'create_tarballs',
             'symbols_sqlite_filepath', 'nightly_tarballs_location',
-            'channels']
+            'channels', 'doc_path_template']
 
 class Config:
     def __init__(self, filename=_default_lgorc):
diff --git a/src/defaults.lgorc b/src/defaults.lgorc
index 742d6b5..1b1c2b4 100644
--- a/src/defaults.lgorc
+++ b/src/defaults.lgorc
@@ -64,3 +64,6 @@ nightly_tarballs_location = None
 
 # channels to process, None to process all of them
 channels = None
+
+# document path template (known variables are %(channel)s and %(module)s
+doc_path_template = '/%(channel)s/%(module)s/'
diff --git a/src/lgo.py b/src/lgo.py
index 5ab28c5..9a31b24 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -737,14 +737,17 @@ class Lgo(App):
                 logging.warn('%s failed with error %d' % (' '.join(cmd), rc))
 
     def get_module_web_path(self, module, versioned=True):
+        base_path = self.config.doc_path_template % {
+                'channel': module.channel,
+                'module': module.modulename }
+
         licence_modules = ['fdl', 'gpl', 'lgpl']
         if module.modulename in licence_modules or versioned is False:
             # special casing the licences, they do not go in a
             # versioned path
-            return '/' + os.path.join(module.channel, module.modulename) + '/'
+            return base_path
         else:
-            return '/' + os.path.join(module.channel, module.modulename,
-                    module.one_dot_version) + '/'
+            return base_path + module.one_dot_version + '/'
 
     def get_module_web_output_dir(self, module, versioned=True):
         return os.path.join(self.config.output_dir,
diff --git a/src/modtypes/base.py b/src/modtypes/base.py
index 9723ad7..f283a24 100644
--- a/src/modtypes/base.py
+++ b/src/modtypes/base.py
@@ -197,10 +197,13 @@ class DocModule(object):
             installed = True
 
         if installed:
+            base_path = app.config.doc_path_template % {
+                'channel': self.channel,
+                'module': self.modulename }
             if not development_release:
-                if doc.path == '/%s/%s/%s/' % (self.channel, self.modulename, self.one_dot_version):
+                if doc.path == base_path + '%s/' % self.one_dot_version:
                     # set default path to use the keyword
-                    doc.path = '/%s/%s/stable/' % (self.channel, self.modulename)
+                    doc.path = base_path + 'stable/'
 
                 # if there is no unstable link, create it even for a stable release
                 # (or if stable is newer)
@@ -216,7 +219,7 @@ class DocModule(object):
             elif not os.path.exists(os.path.join(web_output_dir, 'stable')):
                 # update default path to have codename if there is no stable
                 # release
-                doc.path = '/%s/%s/unstable/' % (self.channel, self.modulename)
+                doc.path = base_path + 'unstable/'
 
             for k in doc.version_keywords.keys():
                 if doc.version_keywords.get(k) == keyword:
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index 2037a7f..f32c282 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -215,8 +215,7 @@ class MallardModule(DocModule):
             doc.category = self.category
             doc.toc_id = app.toc_mapping.get(doc.category)
 
-        web_output_dir = os.path.join(app.config.output_dir, self.channel,
-                doc_module, self.one_dot_version)
+        web_output_dir = app.get_module_web_output_dir(self, versioned=True)
 
         logging.info('generating doc in %s' % web_output_dir[len(app.config.output_dir):])
         if not os.path.exists(web_output_dir):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]