1.1 --- a/moinconvert Thu Feb 14 23:34:16 2019 +0100
1.2 +++ b/moinconvert Thu Feb 14 23:35:32 2019 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Moin wiki format converter.
1.6
1.7 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -84,7 +84,8 @@
1.13
1.14 # Option values.
1.15
1.16 - l = filenames = []
1.17 + document_indexes = []
1.18 + filenames = []
1.19 formats = []
1.20 input_dir_types = []
1.21 input_dirs = []
1.22 @@ -93,9 +94,13 @@
1.23 mappings = []
1.24 output_dirs = []
1.25 output_encodings = []
1.26 - theme_names = []
1.27 pagenames = []
1.28 root_pagenames = []
1.29 + theme_names = []
1.30 +
1.31 + # Obtain filenames by default.
1.32 +
1.33 + l = filenames
1.34
1.35 # Flags.
1.36
1.37 @@ -121,6 +126,12 @@
1.38 elif arg == "--all":
1.39 all = True
1.40
1.41 + # Switch to document index.
1.42 +
1.43 + elif arg == "--document-index":
1.44 + l = document_indexes
1.45 + continue
1.46 +
1.47 # Detect fragment output (if serialising).
1.48
1.49 elif arg == "--fragment":
1.50 @@ -213,6 +224,7 @@
1.51 # Define metadata.
1.52
1.53 metadata = Metadata({
1.54 + "document_index" : getvalue(document_indexes),
1.55 "input_context" : input_dir and \
1.56 getvalue(input_dir_types, "directory") or \
1.57 "standalone",
1.58 @@ -335,6 +347,9 @@
1.59
1.60 Output options:
1.61
1.62 +--document-index Provide a "DocumentIndex" filename to be used in links in
1.63 + HTML format output, useful for local file browsing instead
1.64 + of Web-published content
1.65 --format Indicate the format to be used for serialised documents
1.66 (default: html)
1.67 --fragment Indicates that an output fragment, not an entire document,
2.1 --- a/moinformat/links/html.py Thu Feb 14 23:34:16 2019 +0100
2.2 +++ b/moinformat/links/html.py Thu Feb 14 23:35:32 2019 +0100
2.3 @@ -117,7 +117,13 @@
2.4 # resolved pagename.
2.5
2.6 top_level = self.get_top_level()
2.7 - t[0] = "%s%s" % (top_level and "%s/" % top_level or "", resolved)
2.8 +
2.9 + # Support an explicit "DocumentIndex" filename for file browsing.
2.10 +
2.11 + document_index = self.metadata.get("document_index")
2.12 +
2.13 + t[0] = "%s%s%s" % (top_level and "%s/" % top_level or "", resolved,
2.14 + document_index and "/%s" % document_index or "")
2.15
2.16 return self.quote("#".join(t))
2.17