plugin:box
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:box [2018-05-30 21:10] – Klap-in | plugin:box [2023-10-31 00:58] (current) – Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
---- plugin ---- | ---- plugin ---- | ||
Line 6: | Line 6: | ||
email : chris@jalakai.co.uk | email : chris@jalakai.co.uk | ||
type : syntax | type : syntax | ||
- | lastupdate : 2016-02-17 | + | lastupdate : 2022-08-16 |
- | compatible : Elenor of Tsort, | + | compatible : Elenor of Tsort, |
depends | depends | ||
conflicts | conflicts | ||
Line 14: | Line 14: | ||
downloadurl: | downloadurl: | ||
- | bugtracker : | + | bugtracker : https:// |
sourcerepo : https:// | sourcerepo : https:// | ||
donationurl: | donationurl: | ||
Line 29: | Line 29: | ||
==== Notes ==== | ==== Notes ==== | ||
- | | + | * 2010-01-30 Copied and pasted below code in style.css and syntax.php (./ |
- | * 2009-09-24 that link is broken :( | + | |
- | * 2009-10-28 that link seems to work now :-) | + | |
- | * 2009-12-13 again broken :( | + | |
- | | + | |
===== Acknowledgment ===== | ===== Acknowledgment ===== | ||
Line 94: | Line 90: | ||
==== Sources: ==== | ==== Sources: ==== | ||
- | * Current: | + | * Current: |
+ | * Please see download and git links above | ||
* Previous DokuWiki versions: | * Previous DokuWiki versions: | ||
+ | * [[http:// | ||
* for DokuWiki 2006-03-xx [[http:// | * for DokuWiki 2006-03-xx [[http:// | ||
* for DokuWiki 2005-09-22 [[http:// | * for DokuWiki 2005-09-22 [[http:// | ||
- | |||
- | ===== Details ===== | ||
- | |||
- | The plugin consists of two files, the plugin script [[# | ||
- | |||
- | ==== syntax.php ==== | ||
- | |||
- | This is the code for the release version of DokuWiki. | ||
- | |||
- | <code php> | ||
- | <?php | ||
- | /** | ||
- | * Box Plugin: Draw highlighting boxes around wiki markup | ||
- | * | ||
- | * Syntax: | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | * Acknowledgments: | ||
- | | ||
- | | ||
- | | ||
- | * @license | ||
- | * @author | ||
- | */ | ||
- | |||
- | if(!defined(' | ||
- | if(!defined(' | ||
- | require_once(DOKU_PLUGIN.' | ||
- | |||
- | /** | ||
- | * All DokuWiki plugins to extend the parser/ | ||
- | * need to inherit from this class | ||
- | */ | ||
- | class syntax_plugin_box extends DokuWiki_Syntax_Plugin { | ||
- | |||
- | var $title_mode = false; | ||
- | |||
- | // the following are used in rendering and are set by _xhtml_boxopen() | ||
- | var $_xb_colours | ||
- | var $_content_colours = ''; | ||
- | var $_title_colours | ||
- | |||
- | /** | ||
- | * return some info | ||
- | */ | ||
- | function getInfo(){ | ||
- | return array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | | ||
- | | ||
- | The title can include some wiki markup, the box | ||
- | | ||
- | ' | ||
- | ); | ||
- | } | ||
- | |||
- | function getType(){ return ' | ||
- | function getAllowedTypes() { return array(' | ||
- | function getPType(){ return ' | ||
- | |||
- | // must return a number lower than returned by native ' | ||
- | function getSort(){ return 195; } | ||
- | |||
- | // override default accepts() method to allow nesting | ||
- | // - ie, to get the plugin accepts its own entry syntax | ||
- | function accepts($mode) { | ||
- | if ($mode == substr(get_class($this), | ||
- | |||
- | return parent:: | ||
- | } | ||
- | |||
- | /** | ||
- | * Connect pattern to lexer | ||
- | */ | ||
- | function connectTo($mode) { | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | $this-> | ||
- | } | ||
- | |||
- | function postConnect() { | ||
- | $this-> | ||
- | $this-> | ||
- | } | ||
- | |||
- | /** | ||
- | * Handle the match | ||
- | */ | ||
- | function handle($match, | ||
- | |||
- | switch ($state) { | ||
- | case DOKU_LEXER_ENTER: | ||
- | $data = $this-> | ||
- | if (substr($match, | ||
- | $this-> | ||
- | return array(' | ||
- | } else { | ||
- | return array(' | ||
- | } | ||
- | |||
- | case DOKU_LEXER_MATCHED: | ||
- | if ($this-> | ||
- | $this-> | ||
- | return array(' | ||
- | } else { | ||
- | return array(' | ||
- | } | ||
- | |||
- | case DOKU_LEXER_UNMATCHED: | ||
- | $handler-> | ||
- | return false; | ||
- | |||
- | case DOKU_LEXER_EXIT: | ||
- | $data = trim(substr($match, | ||
- | $title = ($data && $data{0} == " | ||
- | |||
- | return array(' | ||
- | |||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | /** | ||
- | * Create output | ||
- | */ | ||
- | function render($mode, | ||
- | |||
- | if (empty($indata)) return false; | ||
- | list($instr, | ||
- | |||
- | if($mode == ' | ||
- | switch ($instr) { | ||
- | case ' | ||
- | $this-> | ||
- | $renderer-> | ||
- | break; | ||
- | |||
- | case ' | ||
- | if ($this-> | ||
- | $this-> | ||
- | $renderer-> | ||
- | } else { | ||
- | $renderer-> | ||
- | } | ||
- | break; | ||
- | |||
- | case ' | ||
- | $renderer-> | ||
- | break; | ||
- | |||
- | case ' | ||
- | $renderer-> | ||
- | |||
- | if ($data) { | ||
- | $renderer-> | ||
- | } | ||
- | $renderer-> | ||
- | break; | ||
- | } | ||
- | |||
- | return true; | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | function _boxstyle($str) { | ||
- | if (!strlen($str)) return array(); | ||
- | |||
- | $styles = array(); | ||
- | |||
- | $tokens = preg_split('/ | ||
- | foreach ($tokens as $token) { | ||
- | if (preg_match('/ | ||
- | $styles[' | ||
- | continue; | ||
- | } | ||
- | |||
- | if (preg_match('/ | ||
- | (\# | ||
- | (rgb\(([0-9]{1, | ||
- | )$/x', $token)) { | ||
- | $styles[' | ||
- | continue; | ||
- | } | ||
- | |||
- | // restrict token (class names) characters to prevent any malicious data | ||
- | if (preg_match('/ | ||
- | $styles[' | ||
- | } | ||
- | if (!empty($styles[' | ||
- | $styles[' | ||
- | } | ||
- | |||
- | return $styles; | ||
- | } | ||
- | |||
- | function _box_colours($colours) { | ||
- | $triplets = array(); | ||
- | |||
- | // only need the first four colours | ||
- | if (count($colours) > 4) $colours = array_slice($colours, | ||
- | foreach ($colours as $colour) { | ||
- | $triplet[] = $this-> | ||
- | } | ||
- | |||
- | // there must be one colour to get here - the primary background | ||
- | // calculate title background colour if not present | ||
- | if (empty($triplet[1])) { | ||
- | $triplet[1] = $triplet[0]; | ||
- | } | ||
- | |||
- | // calculate outer background colour if not present | ||
- | if (empty($triplet[2])) { | ||
- | $triplet[2] = $triplet[0]; | ||
- | } | ||
- | |||
- | // calculate border colour if not present | ||
- | if (empty($triplet[3])) { | ||
- | $triplet[3] = $triplet[0]; | ||
- | } | ||
- | |||
- | // convert triplets back to style sheet colours | ||
- | $style_colours[' | ||
- | $style_colours[' | ||
- | $style_colours[' | ||
- | $style_colours[' | ||
- | |||
- | return $style_colours; | ||
- | } | ||
- | |||
- | function _colourToTriplet($colour) { | ||
- | if ($colour{0} == '#' | ||
- | if (strlen($colour) == 4) { | ||
- | // format #FFF | ||
- | return array(hexdec($colour{1}.$colour{1}), | ||
- | } else { | ||
- | // format #FFFFFF | ||
- | return array(hexdec(substr($colour, | ||
- | } | ||
- | } else { | ||
- | // format rgb(x,y,z) | ||
- | return explode(',', | ||
- | } | ||
- | } | ||
- | |||
- | function _xhtml_boxopen($styles) { | ||
- | $class = ' | ||
- | $style = isset($styles[' | ||
- | |||
- | if (isset($styles[' | ||
- | $colours = ' | ||
- | $colours .= ' | ||
- | |||
- | $this-> | ||
- | $this-> | ||
- | |||
- | } else { | ||
- | $colours = ''; | ||
- | |||
- | $this-> | ||
- | $this-> | ||
- | } | ||
- | |||
- | if ($style || $colours) $style = ' style="' | ||
- | if ($colours) $colours = ' style="' | ||
- | |||
- | $this-> | ||
- | |||
- | $html = "< | ||
- | $html .=" | ||
- | $html .=" | ||
- | |||
- | return $html; | ||
- | } | ||
- | |||
- | function _xhtml_boxclose() { | ||
- | |||
- | $colours = $this-> | ||
- | |||
- | $html = " | ||
- | $html .= " | ||
- | $html .= "</ | ||
- | |||
- | return $html; | ||
- | } | ||
- | |||
- | } | ||
- | |||
- | //Setup VIM: ex: et ts=4 enc=utf-8 :</ | ||
- | |||
- | ==== style.css ==== | ||
- | |||
- | These may be modified to suit your own requirements. | ||
- | |||
- | The file '' | ||
- | |||
- | <code css> | ||
- | /* plugin:box */ | ||
- | div.box { | ||
- | width: 50%; | ||
- | margin: 1em auto; | ||
- | border: 1px solid; | ||
- | padding: 4px; | ||
- | overflow: hidden; | ||
- | } | ||
- | |||
- | /* rounded corners styles from Stu Nicholls snazzy borders, http:// | ||
- | .xtop, .xbottom {background: | ||
- | .xb1, .xb2, .xb3, .xb4 {display: | ||
- | .xb2, .xb3 {height: | ||
- | .xb2, .xb3, .xb4 {border-width: | ||
- | .xb1 {height: 0; margin:0 5px; border-width: | ||
- | .xb2 {margin:0 3px; border-width: | ||
- | .xb3 {margin:0 2px;} | ||
- | .xb4 {height: | ||
- | |||
- | div.box .xtop, div.box .xbottom {display: none;} | ||
- | div.box.round > .xtop, div.box.round > .xbottom {display: block;} | ||
- | |||
- | div.box.round { border: none; padding: 0;} | ||
- | div.box.round > .xbox {display: | ||
- | |||
- | div.box p.box_title, | ||
- | font-size: 90%; | ||
- | margin: 0; | ||
- | padding: 2px 6px; | ||
- | line-height: | ||
- | } | ||
- | |||
- | div.box p.box_title { margin-bottom: | ||
- | div.box p.box_caption { margin-top: 4px;} | ||
- | |||
- | div.box .box_content { | ||
- | margin: 0; | ||
- | padding: 0 6px; | ||
- | border-width: | ||
- | border-style: | ||
- | line-height: | ||
- | } | ||
- | |||
- | /* floating alignment */ | ||
- | |||
- | div.box.left { | ||
- | float: left; | ||
- | margin-right: | ||
- | } | ||
- | |||
- | div.box.right { | ||
- | float: right; | ||
- | margin-left: | ||
- | } | ||
- | |||
- | /* colours */ | ||
- | /* default */ | ||
- | div.box, div.box .box_content, | ||
- | border-color: | ||
- | } | ||
- | |||
- | div.box, div.box .xbox, div.box .xb1, div.box .xb2, div.box .xb3, div.box .xb4 { | ||
- | background: __light__; | ||
- | } | ||
- | |||
- | div.box p.box_title, | ||
- | div.box .box_content { background: __lighter__; | ||
- | |||
- | /* blue */ | ||
- | div.box.blue, | ||
- | div.box.blue > * > .xb1, div.box.blue > * > .xb2, div.box.blue > * > .xb3, div.box.blue > * > .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | div.box.blue, | ||
- | div.box.blue > * > .xb1, div.box.blue > * > .xb2, div.box.blue > * > .xb3, div.box.blue > * > .xb4 { | ||
- | background: #e4ecf8; | ||
- | } | ||
- | |||
- | div.box.blue > * > p.box_title, | ||
- | div.box.blue > * > .box_content {background: | ||
- | |||
- | /* red */ | ||
- | div.box.red, | ||
- | div.box.red > * > .xb1, div.box.red > * > .xb2, div.box.red > * > .xb3, div.box.red > * > .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | div.box.red, | ||
- | div.box.red > * > .xb1, div.box.red > * > .xb2, div.box.red > * > .xb3, div.box.red > * > .xb4 { | ||
- | background: #f8ece4; | ||
- | } | ||
- | |||
- | div.box.red > * > p.box_title, | ||
- | div.box.red > * > .box_content {background: | ||
- | |||
- | /* green */ | ||
- | div.box.green, | ||
- | div.box.green > * > .xb1, div.box.green > * > .xb2, div.box.green > * > .xb3, div.box.green > * > .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | div.box.green, | ||
- | div.box.green > * > .xb1, div.box.green > * > .xb2, div.box.green > * > .xb3, div.box.green > * > .xb4 { | ||
- | background: #e4f8f2; | ||
- | } | ||
- | |||
- | div.box.green > * > p.box_title, | ||
- | div.box.green > * > .box_content {background: | ||
- | |||
- | /* orange */ | ||
- | div.box.orange, | ||
- | div.box.orange > * > .xb1, div.box.orange > * > .xb2, div.box.orange > * > .xb3, div.box.orange > * > .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | div.box.orange, | ||
- | div.box.orange > * > .xb1, div.box.orange > * > .xb2, div.box.orange > * > .xb3, div.box.orange > * > .xb4 { | ||
- | background: #f4e8ca; | ||
- | } | ||
- | |||
- | div.box.orange > * > p.box_title, | ||
- | div.box.orange > * > .box_content {background: | ||
- | |||
- | /* must come last to override coloured background when using rounded corners */ | ||
- | |||
- | div.box.round { | ||
- | background: transparent !important; | ||
- | } | ||
- | |||
- | /* IE fixes for unsupported child selector \*/ | ||
- | |||
- | * html div.box div.box, * html div.box div.box .box_content, | ||
- | * html div.box div.box .xb1, * html div.box div.box .xb2, | ||
- | * html div.box div.box .xb3, * html div.box div.box .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box div.box, * html div.box div.box .xbox, | ||
- | * html div.box div.box .xb1, * html div.box div.box .xb2, | ||
- | * html div.box div.box .xb3, * html div.box div.box .xb4 { | ||
- | background: __light__; | ||
- | } | ||
- | |||
- | * html div.box div.box p.box_title, | ||
- | * html div.box div.box .box_content { background: __lighter__; | ||
- | |||
- | * html div.box.round .xtop, * html div.box.round .xbottom {display: block;} | ||
- | * html div.box.round .xbox {display: | ||
- | |||
- | /* blue */ | ||
- | * html div.box.blue .box_content, | ||
- | * html div.box.blue .xb1, * html div.box.blue .xb2, * html div.box.blue .xb3, * html div.box.blue .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box.blue .xbox, | ||
- | * html div.box.blue .xb1, * html div.box.blue .xb2, * html div.box.blue .xb3, * html div.box.blue .xb4 { | ||
- | background: #e4ecf8; | ||
- | |||
- | |||
- | |||
- | } | ||
- | |||
- | * html div.box.blue p.box_title, | ||
- | * html div.box.blue .box_content {background: | ||
- | |||
- | /* nested blue */ | ||
- | * html div.box div.box.blue .box_content, | ||
- | * html div.box div.box.blue .xb1, * html div.box div.box.blue .xb2, | ||
- | * html div.box div.box.blue .xb3, * html div.box div.box.blue .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box div.box.blue .xbox, | ||
- | * html div.box div.box.blue .xb1, * html div.box div.box.blue .xb2, | ||
- | * html div.box div.box.blue .xb3, * html div.box div.box.blue .xb4 { | ||
- | background: #e4ecf8; | ||
- | } | ||
- | |||
- | * html div.box div.box.blue p.box_title, | ||
- | * html div.box div.box.blue p.box_caption {background: | ||
- | * html div.box div.box.blue .box_content {background: | ||
- | |||
- | /* red */ | ||
- | * html div.box.red .box_content, | ||
- | * html div.box.red .xb1, * html div.box.red .xb2, * html div.box.red .xb3, * html div.box.red .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box.red .xbox, | ||
- | * html div.box.red .xb1, * html div.box.red .xb2, * html div.box.red .xb3, * html div.box.red .xb4 { | ||
- | background: #f8ece4; | ||
- | } | ||
- | |||
- | * html div.box.red p.box_title, | ||
- | * html div.box.red .box_content {background: | ||
- | |||
- | /* nested red */ | ||
- | * html div.box div.box.red .box_content, | ||
- | * html div.box div.box.red .xb1, * html div.box div.box.red .xb2, | ||
- | * html div.box div.box.red .xb3, * html div.box div.box.red .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box div.box.red .xbox, | ||
- | * html div.box div.box.red .xb1, * html div.box div.box.red .xb2, | ||
- | * html div.box div.box.red .xb3, * html div.box div.box.red .xb4 { | ||
- | background: #f8ece4; | ||
- | } | ||
- | |||
- | * html div.box div.box.red p.box_title, | ||
- | * html div.box div.box.red .box_content {background: | ||
- | |||
- | /* green */ | ||
- | * html div.box.green .box_content, | ||
- | * html div.box.green .xb1, * html div.box.green .xb2, * html div.box.green .xb3, * html div.box.green .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box.green .xbox, | ||
- | * html div.box.green .xb1, * html div.box.green .xb2, * html div.box.green .xb3, * html div.box.green .xb4 { | ||
- | background: #e4f8f2; | ||
- | } | ||
- | |||
- | * html div.box.green p.box_title, | ||
- | * html div.box.green .box_content {background: | ||
- | |||
- | /* nested green */ | ||
- | * html div.box div.box.green .box_content, | ||
- | * html div.box div.box.green .xb1, * html div.box div.box.green .xb2, | ||
- | * html div.box div.box.green .xb3, * html div.box div.box.green .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box div.box.green .xbox, | ||
- | * html div.box div.box.green .xb1, * html div.box div.box.green .xb2, | ||
- | * html div.box div.box.green .xb3, * html div.box div.box.green .xb4 { | ||
- | background: #e4f8f2; | ||
- | } | ||
- | |||
- | * html div.box div.box.green p.box_title, | ||
- | * html div.box div.box.green .box_content {background: | ||
- | |||
- | /* orange */ | ||
- | * html div.box.orange .box_content, | ||
- | * html div.box.orange .xb1, * html div.box.orange .xb2, * html div.box.orange .xb3, * html div.box.orange .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box.orange .xbox, | ||
- | * html div.box.orange .xb1, * html div.box.orange .xb2, * html div.box.orange .xb3, * html div.box.orange .xb4 { | ||
- | background: #f4e8ca; | ||
- | } | ||
- | |||
- | * html div.box.orange p.box_title, | ||
- | * html div.box.orange .box_content {background: | ||
- | |||
- | /* nestedorange */ | ||
- | * html div.box div.box.orange .box_content, | ||
- | * html div.box div.box.orange .xb1, * html div.box div.box.orange .xb2, | ||
- | * html div.box div.box.orange .xb3, * html div.box div.box.orange .xb4 { | ||
- | border-color: | ||
- | } | ||
- | |||
- | * html div.box div.box.orange .xbox, | ||
- | * html div.box div.box.orange .xb1, * html div.box div.box.orange .xb2, | ||
- | * html div.box div.box.orange .xb3, * html div.box div.box.orange .xb4 { | ||
- | background: #f4e8ca; | ||
- | } | ||
- | |||
- | * html div.box div.box.orange p.box_title, | ||
- | * html div.box div.box.orange .box_content {background: | ||
- | |||
- | /* end plugin:box */ | ||
- | </ | ||
===== Revision History ===== | ===== Revision History ===== | ||
Line 1045: | Line 462: | ||
Cheers for the update Chris but I'm not sure what you mean by a cleared element? So without the div/span plugin there is no way to resolve the issue? | Cheers for the update Chris but I'm not sure what you mean by a cleared element? So without the div/span plugin there is no way to resolve the issue? | ||
- | > You could also use the **clearfloat plugin** (search for it on [[: | + | > You could also use the **clearfloat plugin** (search for it on [[: |
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | --- [[user> | ||
What about a | before and after the text? | What about a | before and after the text? | ||
Line 1201: | Line 623: | ||
--- [[user> | --- [[user> | ||
+ | ---- | ||
+ | Can we add a close button to it, so We can use it as notice? | ||
---- | ---- | ||
- | Can we add close button | + | :!: **Box** plugin not able to work correctly with **Include** plugin. Commonly **Box** hold any content in '' |
---- | ---- | ||
+ | Basic Dokuwiki engine works with images only through pixel widths. This plugin can be used as the percent zoomer. Add < | ||
+ | width: 100%; | ||
+ | width: -moz-available; | ||
+ | width: -webkit-fill-available; | ||
+ | width: stretch; | ||
+ | }</ | ||
+ | |||
+ | ---- |
plugin/box.1527707451.txt.gz · Last modified: 2018-05-30 21:10 by Klap-in