-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.php
53 lines (47 loc) · 1.61 KB
/
cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
use dokuwiki\Search\Indexer;
use splitbrain\phpcli\Options;
/**
* DokuWiki Plugin renderrevisions (CLI Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Andreas Gohr <[email protected]>
*/
class cli_plugin_renderrevisions extends \dokuwiki\Extension\CLIPlugin
{
/** @inheritDoc */
protected function setup(Options $options)
{
$options->setHelp(
"Re-render pages if necessary\n" .
"\n" .
"This command will go through all pages in the wiki (adhering to the skipRegex and matchRegex settings) " .
"and re-render them if necessary. This will trigger the renderrevisions plugin mechanism to create " .
"a new revision of the page if the content changed."
);
}
/** @inheritDoc */
protected function main(Options $options)
{
$indexer = new Indexer();
$pages = $indexer->getPages();
$action = plugin_load('action', 'renderrevisions');
[$skipRE, $matchRE] = $action->getRegexps();
foreach ($pages as $page) {
if (
($skipRE && preg_match($skipRE, ":$page")) ||
($matchRE && !preg_match($matchRE, ":$page"))
) {
$this->info("Skipping $page");
continue;
}
$this->notice("Processing $page");
$file = wikiFN($page);
try {
p_cached_output($file, 'xhtml', $page);
} catch (\Exception $e) {
$this->error("Issues while rendering $page: " . $e->getMessage());
}
}
}
}