MoinLight

Changeset

284:b8cfafd45f26
2019-12-11 Paul Boddie raw files shortlog changelog graph Merged concurrent branches.
     1.1 --- a/moinconvert	Thu Oct 24 18:50:53 2019 +0200
     1.2 +++ b/moinconvert	Wed Dec 11 00:47:52 2019 +0100
     1.3 @@ -108,8 +108,10 @@
     1.4  
     1.5      all = False
     1.6      bundle = False
     1.7 +    common = False
     1.8      fragment = False
     1.9      macros = False
    1.10 +    no_inline = False
    1.11      tree = False
    1.12  
    1.13      for arg in args:
    1.14 @@ -126,6 +128,11 @@
    1.15          elif arg == "--bundle":
    1.16              bundle = True
    1.17  
    1.18 +        # Detect use of a common attachments directory.
    1.19 +
    1.20 +        elif arg == "--common":
    1.21 +            common = True
    1.22 +
    1.23          # Detect fragment output (if serialising).
    1.24  
    1.25          elif arg == "--fragment":
    1.26 @@ -136,6 +143,11 @@
    1.27          elif arg == "--macros":
    1.28              macros = True
    1.29  
    1.30 +        # Detect suppression of inline objects.
    1.31 +
    1.32 +        elif arg == "--no-inline":
    1.33 +            no_inline = True
    1.34 +
    1.35          # Detect tree output.
    1.36  
    1.37          elif arg == "--tree":
    1.38 @@ -244,6 +256,7 @@
    1.39      metadata = Metadata({
    1.40          "attachments"       : getvalue(attachments_dir, "attachments"),
    1.41          "bundle"            : bundle,
    1.42 +        "common_attachments": common,
    1.43          "document_index"    : getvalue(document_indexes),
    1.44          "input_context"     : input_dir and \
    1.45                                getvalue(input_dir_types, "directory") or \
    1.46 @@ -253,6 +266,7 @@
    1.47          "input_separator"   : getvalue(input_page_seps),
    1.48          "link_format"       : format,
    1.49          "mapping"           : getmapping(mappings),
    1.50 +        "no_inline"         : no_inline,
    1.51          "output_context"    : output_dir and "directory" or "standalone",
    1.52          "output_encoding"   : getvalue(output_encodings),
    1.53          "output_format"     : format,
    1.54 @@ -362,6 +376,9 @@
    1.55  
    1.56  Input options:
    1.57  
    1.58 +--common            Obtain attachments from a common directory for all pages,
    1.59 +                    rather than each page having its own subdirectory of a
    1.60 +                    top-level attachments directory.
    1.61  --input-dir         Indicate an input directory containing document files
    1.62  --input-dir-type    Indicate the type of input directory involved
    1.63                      (default: directory)
    1.64 @@ -384,6 +401,8 @@
    1.65                      (default: html)
    1.66  --fragment          Indicates that an output fragment, not an entire document,
    1.67                      is to be generated, skipping any theming activities
    1.68 +--no-inline         Suppress inline objects in serialised documents, linking to
    1.69 +                    separate objects instead.
    1.70  --output-dir        Indicate an output directory to contain serialised document
    1.71                      files
    1.72  --output-encoding   Indicate the character encoding used in serialised document
     2.1 --- a/moinformat/input/directory.py	Thu Oct 24 18:50:53 2019 +0200
     2.2 +++ b/moinformat/input/directory.py	Wed Dec 11 00:47:52 2019 +0100
     2.3 @@ -53,6 +53,19 @@
     2.4  
     2.5          self.attachments_dir = metadata.get("attachments")
     2.6  
     2.7 +        # Support a common attachments directory.
     2.8 +
     2.9 +        self.common_attachments = metadata.get("common_attachments")
    2.10 +
    2.11 +    def _get_attachments_dir(self, pagename):
    2.12 +
    2.13 +        "Return the attachments directory for 'pagename'."
    2.14 +
    2.15 +        if self.common_attachments:
    2.16 +            return join(self.dir.filename, self.attachments_dir)
    2.17 +        else:
    2.18 +            return join(self.dir.filename, self.attachments_dir, pagename)
    2.19 +
    2.20      def all(self):
    2.21  
    2.22          "Return all pages in the context."
    2.23 @@ -74,11 +87,7 @@
    2.24          is relative to the appropriate attachment directory.
    2.25          """
    2.26  
    2.27 -        attachments_dir = Directory(join(self.dir.filename,
    2.28 -                                         self.attachments_dir,
    2.29 -                                         pagename))
    2.30 -
    2.31 -        return attachments_dir.select_files("*")
    2.32 +        return Directory(self._get_attachments_dir(pagename)).select_files("*")
    2.33  
    2.34      # Page characteristics.
    2.35  
    2.36 @@ -118,8 +127,8 @@
    2.37          if not pagename:
    2.38              return None
    2.39  
    2.40 -        return self.dir.get_filename(join(self.attachments_dir,
    2.41 -                                          pagename, filename))
    2.42 +        return self.dir.get_filename(join(self._get_attachments_dir(pagename),
    2.43 +                                          filename))
    2.44  
    2.45      # NOTE: Translation methods should encode filenames appropriately.
    2.46  
     3.1 --- a/moinformat/serialisers/html/graphviz.py	Thu Oct 24 18:50:53 2019 +0200
     3.2 +++ b/moinformat/serialisers/html/graphviz.py	Wed Dec 11 00:47:52 2019 +0100
     3.3 @@ -22,6 +22,7 @@
     3.4  from moinformat.serialisers.common import Serialiser, escape_attr, escape_text
     3.5  from moinformat.utils.graphviz import Graphviz, IMAGE_FORMATS, \
     3.6                                        get_output_identifier
     3.7 +from moinformat.utils.links import LinkTarget
     3.8  
     3.9  # Utility functions.
    3.10  
    3.11 @@ -107,7 +108,7 @@
    3.12  
    3.13          # Determine the inline status, with only SVG being appropriate.
    3.14  
    3.15 -        inline = format == "svg"
    3.16 +        inline = format == "svg" and not self.metadata.get("no_inline")
    3.17  
    3.18          # Non-inline graph output is stored for a known page only.
    3.19  
    3.20 @@ -131,7 +132,7 @@
    3.21              # Make sure that page attachments can be stored.
    3.22  
    3.23              self.output.ensure_attachments(pagename)
    3.24 -            link = self.linker.translate("attachment:%s" % attachment)
    3.25 +            link = self.linker.translate(LinkTarget("attachment", attachment))
    3.26  
    3.27          # No filename is defined for inline output.
    3.28