Ticket #4616 (assigned enhancement)

Opened 4 years ago

Last modified 4 years ago

Simplify the creation of multi-page documents

Reported by: mvlcek Assigned to: grigi (accepted)
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

wikitopdf.py (5.7 kB) - added by mvlcek on 02/13/09 08:52:03.
multiple_pages_patch.txt (5.2 kB) - added by mickem on 09/20/09 20:08:54.
patch to add "this" to 0.11

Change History

02/13/09 08:52:03 changed by mvlcek

  • attachment wikitopdf.py added.

02/13/09 08:54:07 changed by mvlcek

  • priority changed from normal to high.

Added support for reading the header for the table of content:

----

Anything between the two horizontal lines will be put on the title page.

The configured title page is not used.

----

The first header in this section is used as caption for the table of content

== Table of Content ==

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.}}}

02/24/09 12:50:17 changed by izzy

Will there be a similar patch (or the functionality added to the code) for 0.11?

05/05/09 12:38:28 changed by grigi

  • status changed from new to assigned.
  • owner changed from diorgenes to grigi.

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.

05/06/09 09:46:01 changed by grigi

mvlcek: Commit [5673] adds your patch for version 0.10 I cannot support 0.10 properly, since I didn't have a 0.10 installation for ages. Please check that is works fine. Thanks in advance, Grigi

05/10/09 20:21:49 changed by anonymous

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)]].

09/20/09 20:08:09 changed by mickem

  • release changed from 0.10 to 0.11.
  • keywords set to patch.

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')))

09/20/09 20:08:54 changed by mickem

  • attachment multiple_pages_patch.txt added.

patch to add "this" to 0.11


Add/Change #4616 (Simplify the creation of multi-page documents)




Change Properties
Action