Opened 16 years ago
Last modified 3 years ago
#4616 assigned enhancement
Simplify the creation of multi-page documents
Reported by: | mvlcek | Owned by: | Nickolas Grigoriadis |
---|---|---|---|
Priority: | high | Component: | TracWikiToPdfPlugin |
Severity: | normal | Keywords: | patch |
Cc: | Trac Release: | 0.11 |
Description
The patch allows the definition of a document on a wiki page like follows:
---- Anything between the two horizontal lines will be put on the title page. The configured title page is not used. ---- In the section all linked pages are added to the document. The links must be in the following format: * [wiki:Chapter1] * [wiki:Chapter2] * [wiki:Chapter3] * ... Everything besides the links is ignored.
Attachments (2)
Change History (8)
Changed 16 years ago by
Attachment: | wikitopdf.py added |
---|
comment:1 Changed 16 years ago by
Priority: | normal → high |
---|
comment:2 Changed 16 years ago by
Will there be a similar patch (or the functionality added to the code) for 0.11?
comment:3 Changed 16 years ago by
Owner: | changed from Diorgenes Felipe Grzesiuk to Nickolas Grigoriadis |
---|---|
Status: | new → assigned |
I think that this functionality is very important for this plugin, I just don't know if this is the "right" way to do something like this.
I agree it should use a TOC-like structure, but maybe a macro/ or markup would be of more use?
Something like:
{{{ #!PDFBook --- <Frontpage override, if you don't specify this it uses the default one> --- Variables to replace data in frontpage. Title = <blah> Sub-Title = <blah> Version = <blah> Date = <blah> If Date is not specified, it will automatically populate it with the generation date. TOCCaption = <Table of Contents Caption> Pages = PageOne,PageTwo,Pages/* Anything else is ignored. }}}
The preprocessor by default returns blank back to Trac.
You could pace a link to "Download Current PDF book" like:
Download all documentation as [wiki:ThisPage?format=pdfbook PDF Book]
The issue is HOW, I'm not entirely sure how to do all this.
comment:4 Changed 16 years ago by
comment:5 Changed 16 years ago by
http://svn.ipd.uka.de/trac/javaparty/wiki/TracNav allows to specify such a page usable for the wiki.
if the macro text could be specified on the tracnav table of contents page it would be usable for both, (1) the wiki itself, and (2) printing pdf.
another possibility for specifying the contents would be the TagsPlugin, by using lists like [[ListTagged(macro -plugin)]]
.
comment:6 Changed 15 years ago by
Keywords: | patch added |
---|---|
Trac Release: | 0.10 → 0.11 |
I did a quick fix to add this support to the 0.11 branch. Now I am (as always) not a python/trac/* expert so take this for hat it is. There are also some issues with the title/subject (which are not set, but they are not set from the admin either so maybe I have configured something wrong). The relevant sections are the onse below, the patch has some other things I have played with as well (which might not be what everyone wants).
@@ -224,9 +230,48 @@ page = wiki_to_pdf(text, self.env, req, base_dir, codepage) hfile, hfilename = mkstemp('wikitopdf') - os.write(hfile, page) + os.write(hfile, page) os.close(hfile) + mo = None + if text.startswith('----'): + mo = re.match(r'\-+\r\n([^\-].*?)\r\n\-\-\-\-+\r\n([^\-].*?)\r\n\-\-\-\-+\r\n(.*)', text, re.DOTALL | re.MULTILINE) + + if mo: + bookname = 'WikiToPdf' + title = 'WikiToPdf' + subject = 'WikiToPdf' + title = mo.group(2) + bn = re.match(r'.*?bookname\=(.*?)\r\n', mo.group(1), re.DOTALL | re.MULTILINE) + if bn: + bookname = bn.group(1) + bn = re.match(r'.*?title\=(.*?)\r\n', mo.group(1), re.DOTALL | re.MULTILINE) + if bn: + title = bn.group(1) + bn = re.match(r'.*?subject\=(.*?)\r\n', mo.group(1), re.DOTALL | re.MULTILINE) + if bn: + subject = bn.group(1) + pages = [p for p in re.findall(r'\[wiki:([^\] ]+)', mo.group(3))] + title_page = mo.group(1) + + formats = {} + for provider in self.formats: + for format, name in provider.wikitopdf_formats(req): + formats[format] = { + 'name': name, + 'provider': provider, + } + self.env.log.error('TEST => Name: %s' % (name)) + + date = '2008-01-01' + version = '1.0' + format = 'pdf' + + if not format or format not in formats: + raise TracError('Bad format given for WikiToPdf output.') + + return formats[format]['provider'].process_wikitopdf(req, format, title, subject, pages, date, version, bookname) + htmldoc_args = { 'webpage': '', 'format': 'pdf14', 'charset': codepage } htmldoc_args.update(dict(self.env.config.options('wikitopdf-page')))
Added support for reading the header for the table of content: