=====HTML Handler===== >> ==See also:== Documentation: HTMLHandlerInfo. 1.1.7 patch: [[http://wush.net/trac/wikka/ticket/218]]>>This is the development page for the HTML handler.::c:: This handler generates "standalone" HTML, without the header/footer/menu items. ===Dependency=== None. ===The code=== Copy ##css/wikka.css## to ##css/html.css##, then add the following line to the top of html.css: %%(php) .header, .footer, .commentsheader, .copyright, .smallprint { display:none; } %% Create ##handlers/page/html.php## (//version <=1.1.6.3//) or ##handlers/html/html.php## (//version >=1.1.7//): %%(php) HasAccess("read") && $this->page) { // display page ?> <?php echo $this->GetPageTag(); ?>
config['external_link_tail'] = ''; print($this->Format($this->page["body"], "html")); } ?>
%% Add the following after about line 1109 (//version < 1.1.6.2//) or line 1030 (//version 1.1.6.2/1.1.6.3//) in ##wikka.php## (just before the final else statement): %%(php) elseif ($this->method == "html") { print($this->Method($this->method)); } %% Add the code above after about line 2183 (//version 1.2//) in ##libs/Wakka.class.php## (just before the final else statement). Add the following after about line 2879 (//version = 1.1.7//) in ##libs/Wakka.class.php## : %%(php) // Handler to generate html elseif ($this->handler == 'html') { print($this->Handler($this->handler)); } %% The Wikka parsing engine doesn't differentiate between relative URIs and absolute URIs (the default is to prepend any "unidentified" URIs with http://). To enable relative URIs, copy formatters/wakka.php to formatters/html.php, then make the following changes starting at around line 240 (//version < 1.1.6.2//), line 284 (//version 1.1.6.2/1.1.6.3//), or line 527 (//version >= 1.1.7//): %%(php) // forced links // \S : any character that is not a whitespace character // \s : any whitespace character --->change start<--- // Hack to pick up leading . and / characters in URI else if (preg_match("/^\[\[([\S|\.|\/]*)(\s+(.+))?\]\]$/s", $thing, $matches)) # recognize forced links across lines { --->change end<--- list (, $url, , $text) = $matches; if ($url) { //if ($url!=($url=(preg_replace("/@@|££||\[\[/","",$url))))$result=""; if (!$text) $text = $url; //$text=preg_replace("/@@|££|\[\[/","",$text); --->change start<--- $link = $wakka->Link($url, "", $text); // Hack to handle relative URIs (i.e., links to files // in the same directory) if(strstr($link, "http://.") || strstr($link, "http:///")) $link = preg_replace("/^(.*)http:\/\/(.*)$/", "\${1}\${2}", $link); return $result.$link; --->change end<--- } %% To disable the display of ""CamelWords"" and ""InterWiki"" as clickable links, also delete the following lines from formatters/html.php: %%(php) "\b[A-Z???][A-Za-z???????]+[:](?![=_])\S*\b|". # InterWiki link "\b([A-Z???]+[a-z????]+[A-Z0-9???][A-Za-z0-9???????]*)\b|". # CamelWords %% ===Dumping an entire wiki=== This is some proof-of-concept code I hacked together rather quickly for a Wikka user in need of a way to dump **all** of his Wikka pages to a directory. I've only tested this on version ##1.1.6.0##, so your results may vary. By default, html files are dumped in ##/tmp/wikka_test/##. %%(php) LoadAllPages(); foreach($pages as $page) { if ($this->HasAccess("read") && $page) { // dump pages ob_start(); ?> <?php echo $page['tag'] ?> config['external_link_tail'] = ''; print($this->Format($page['body'], "html")); } $buffer = ob_get_flush(); $filename = $page['tag'].".html"; file_put_contents("/tmp/wikka_test/".$filename, $buffer); } $this->Redirect(); ?> %% ===To Do=== - Provide option to exclude inline CSS (with option to display listing of CSS to save in separate file) - Provide "raw" html (no html, head, body tags) - Clean up kludge in wikka.php (there should be no need to modify this file to accomodate a new handler type) - Convince DarTar to include this formatter in the next release so we can show ##""Exports HTML == yes""## in the ""WikkaWiki"" entry on [[http://www.wikimatrix.org WikiMatrix]]! ---- ==Categories== CategoryDevelopmentHandlers CategoryUserContributions