# HG changeset patch # User Paul Boddie # Date 1550183732 -3600 # Node ID 2268392c60516753dbaaac66b485bfef2db41c04 # Parent 91891fd7135212ccb664f676503c90ea558a04a2 Added support for explicit "DocumentIndex" filenames. diff -r 91891fd71352 -r 2268392c6051 moinconvert --- a/moinconvert Thu Feb 14 23:34:16 2019 +0100 +++ b/moinconvert Thu Feb 14 23:35:32 2019 +0100 @@ -3,7 +3,7 @@ """ Moin wiki format converter. -Copyright (C) 2018 Paul Boddie +Copyright (C) 2018, 2019 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -84,7 +84,8 @@ # Option values. - l = filenames = [] + document_indexes = [] + filenames = [] formats = [] input_dir_types = [] input_dirs = [] @@ -93,9 +94,13 @@ mappings = [] output_dirs = [] output_encodings = [] - theme_names = [] pagenames = [] root_pagenames = [] + theme_names = [] + + # Obtain filenames by default. + + l = filenames # Flags. @@ -121,6 +126,12 @@ elif arg == "--all": all = True + # Switch to document index. + + elif arg == "--document-index": + l = document_indexes + continue + # Detect fragment output (if serialising). elif arg == "--fragment": @@ -213,6 +224,7 @@ # Define metadata. metadata = Metadata({ + "document_index" : getvalue(document_indexes), "input_context" : input_dir and \ getvalue(input_dir_types, "directory") or \ "standalone", @@ -335,6 +347,9 @@ Output options: +--document-index Provide a "DocumentIndex" filename to be used in links in + HTML format output, useful for local file browsing instead + of Web-published content --format Indicate the format to be used for serialised documents (default: html) --fragment Indicates that an output fragment, not an entire document, diff -r 91891fd71352 -r 2268392c6051 moinformat/links/html.py --- a/moinformat/links/html.py Thu Feb 14 23:34:16 2019 +0100 +++ b/moinformat/links/html.py Thu Feb 14 23:35:32 2019 +0100 @@ -117,7 +117,13 @@ # resolved pagename. top_level = self.get_top_level() - t[0] = "%s%s" % (top_level and "%s/" % top_level or "", resolved) + + # Support an explicit "DocumentIndex" filename for file browsing. + + document_index = self.metadata.get("document_index") + + t[0] = "%s%s%s" % (top_level and "%s/" % top_level or "", resolved, + document_index and "/%s" % document_index or "") return self.quote("#".join(t))