Page MenuHomePhabricator

Collection extension should accept lists of chapters generated by templates (e.g. expanding templates of a collection page before loading the collection)
Closed, DeclinedPublic


As mentioned on [[Help:Books/Feedback/Archives/2010/May#The_extension_is_not_parsing_templates]], the extension is not expanding templates before loading a collection.

Currently, in the function loadCollection[1] we have a loop for parsing each line of the collection, but it uses the value of $article->getContent() in the following loop

foreach ( preg_split( '/[\r\n]+/', $article->getContent() ) as $line ) {

Instead of that, it should be used the preprocessed text, such as that which appears on [[Special:ExpandTemplates]]. The code of this ExpandTemplates extension uses

$output = $wgParser->preprocess( $input, $title, $options );

to get the expanded content in the special page. I believe the same function can be used for Collection extension.


Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:23 PM
bzimport added a project: Collection.
bzimport set Reference to bz26533.
bzimport added a subscriber: Unknown Object (MLST).

Maybe it could have also an API parameter to which the users could provide the name of a page whose (expanded) content would be used to load a collection.

ralf_wikimedia wrote:

There are some reasons why we won't implement that:

  1. We'd like to keep it simple. Currently collection pages can be parsed using some simple regular expressions. If we would allow templates, one would need to write a complete template expander in order to parse them (or rely on mediawiki's expander).
  1. There's no way I can think of to load and save those books from the collection interface while at the same time keeping calls to templates intact in the general case (when saving a collectionpage).
  1. We'd like to able to use template syntax as a way to store additional meta-information about the book, like in:


title=Hadronic Matter
subtitle=An overview
cover-image=Quark structure proton.svg


at the top of a collectionpage.