1.1 --- a/moinformat/input/directory.py Wed Aug 07 15:44:50 2019 +0200
1.2 +++ b/moinformat/input/directory.py Wed Aug 07 15:48:00 2019 +0200
1.3 @@ -53,6 +53,19 @@
1.4
1.5 self.attachments_dir = metadata.get("attachments")
1.6
1.7 + # Support a common attachments directory.
1.8 +
1.9 + self.common_attachments = metadata.get("common_attachments")
1.10 +
1.11 + def _get_attachments_dir(self, pagename):
1.12 +
1.13 + "Return the attachments directory for 'pagename'."
1.14 +
1.15 + if self.common_attachments:
1.16 + return join(self.dir.filename, self.attachments_dir)
1.17 + else:
1.18 + return join(self.dir.filename, self.attachments_dir, pagename)
1.19 +
1.20 def all(self):
1.21
1.22 "Return all pages in the context."
1.23 @@ -74,11 +87,7 @@
1.24 is relative to the appropriate attachment directory.
1.25 """
1.26
1.27 - attachments_dir = Directory(join(self.dir.filename,
1.28 - self.attachments_dir,
1.29 - pagename))
1.30 -
1.31 - return attachments_dir.select_files("*")
1.32 + return Directory(self._get_attachments_dir(pagename)).select_files("*")
1.33
1.34 # Page characteristics.
1.35
1.36 @@ -118,8 +127,8 @@
1.37 if not pagename:
1.38 return None
1.39
1.40 - return self.dir.get_filename(join(self.attachments_dir,
1.41 - pagename, filename))
1.42 + return self.dir.get_filename(join(self._get_attachments_dir(pagename),
1.43 + filename))
1.44
1.45 # NOTE: Translation methods should encode filenames appropriately.
1.46