-
Notifications
You must be signed in to change notification settings - Fork 70
support for specific headers / footers per dokuwiki page (ns & bookcr… #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…eator) adds support for setting specific headers and footers for each logical DokuWiki page by using named @page styles and corresponding blocks. Each page is wrapped in a with a matching @page pageX CSS rule that defines the appropriate header and footer names. All named headers and footers are defined before to start html. also adjusted how pagebreak are handled, because mPDF automatically inserts a page break before any new div with a different page style.
Implement support for header_ and footer_ templates specific to:
Back page: header_last.html, footer_last.html
Table of contents (TOC): header_toc.html, footer_toc.html
Multi pages, ns and bookcreator(useful for white pages between cover, TOC, and first page): header_book.html, footer_book.html
splitbrain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented on a bunch of stuff, however...
I would not merge this as is. It makes an already messy and complex file more messy and complex. That is not fully your fault, this class needs some serious refactoring on it's own, but your code would make that even harder.
I am also not sure about the intend behind this PR. Do you really want create templates for individual pages? Or wouldn't you rather assign a certain template to a whole group of pages (eg. identified by namespace, or maybe some kind of meta data)?
I feel like this is an implementation that allowed you to address an issue you had but the same issue could have been maybe addressed in a more general and better way.
Unfortunately the actual issue you're trying to solve is not well explained in the PR.
| /** @var bool|string path to temporary cachefile */ | ||
| /** | ||
| * @var bool|string path to temporary cachefile | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why reformatting these to multiline?
| public function __construct() | ||
| { | ||
| require_once __DIR__ . '/vendor/autoload.php'; | ||
| include_once __DIR__ . '/vendor/autoload.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why changing from require_once to include_once?
BTW. requiring vendor/autoload.php should no longer be necessary for recent DokuWiki releases.
| } | ||
| return true; | ||
| }); | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, these lines only seem to do reformatting? I am not opposed to it, but having it as a separate PR would make reviewing a bit easier.
| /** @deprecated April 2016 replaced by localStorage version of Bookcreator */ | ||
| /** | ||
| * @deprecated April 2016 replaced by localStorage version of Bookcreator | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation broken.
| /** @var action_plugin_bookcreator_handleselection $SelectionHandling */ | ||
| /** | ||
| * @var action_plugin_bookcreator_handleselection $SelectionHandling | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation broken
| $output['back'] = '<pagebreak />'; | ||
| $output['back'] .= file_get_contents($backfile); | ||
| $output['back'] = str_replace(array_keys($replace), array_values($replace), $output['back']); | ||
| $output['back'] = file_get_contents($backfile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pagebreak got removed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I guess this is what you meant by a div with a new page style adds a pagebreak automatically?
| $html = str_replace(array_keys($replace), array_values($replace), $raw); | ||
|
|
||
| return $html; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! I like that this moved into it's own method. It's missing a doc block though.
| //reuse the CSS dispatcher functions without triggering the main function | ||
| define('SIMPLE_TEST', 1); | ||
| require_once(DOKU_INC . 'lib/exe/css.php'); | ||
| include_once DOKU_INC . 'lib/exe/css.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include vs. require
| $this->cssPluginPDFstyles(), | ||
| [ | ||
| DOKU_PLUGIN . 'dw2pdf/conf/style.css' => DOKU_BASE . 'lib/plugins/dw2pdf/conf/', | ||
| DOKU_PLUGIN . '$dw2pdf/conf/style.css' => DOKU_BASE . 'lib/plugins/dw2pdf/conf/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stray $ seems wrong
| /** @var helper_plugin_translation $trans */ | ||
| /** | ||
| * @var helper_plugin_translation $trans | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
…eator)
adds support for setting specific headers and footers for each logical DokuWiki page by using named @page styles and corresponding blocks. Each page is wrapped in a
with a matching @page pageX CSS rule that defines the appropriate header and footer names.
All named headers and footers are defined before to start html.
also adjusted how pagebreak are handled, because mPDF automatically inserts a page break before any new div with a different page style.