Download and install the plugin using the Plugin Manager using the following URL. Refer to Plugins on how to install plugins manually.
20100301.0: Add Josef Fortier's improved link HTML. Also styled the links a bit.
20100118.0: Added a small feature request: you can now express racks that number top-to-bottom by specifying ”descending” in the <rack> tag.
20100115.0: Folded in a change introduced by Sylvain Bigonneau: you can now assign links to rack items. Thanks for the contribution! A lot of people have been asking for this.
20090608.0: Renamed the JavaScript function getElementsByClass to rack_getElementsByClass, since the former exists as a part of the base DokuWiki. (Of course, if IE would just support modern CSS, I wouldn't need any JavaScript at all.) Thanks to Christian Marg for spotting this!
20090520.0: Sidestepped frustrating Firefox rendering bug by making the bottom border a whole row. Ugly, I know, but otherwise Firefox will leave little black lines across the rack when you scroll past it (????). Very weird.
20090519.0: Initial release
If you add something useful to the plugin, email me and post a patch or pastebin or something below and I'll see about folding it into the plugin.
Put your comments/fixes here
Hi, great plugin, thank you. I have a patch that addresses 2 issues (I think).
link:whatever as name if there is no name and no color. such as in<rack name=A20 height=42> 12 1 Cableguide link:http://www.example.com/ </rack>
This can be resolved using a negative lookahead in the regexp part that matches the name field. The regexp is “either it is empty or it not starting with # or link:”. ie ((?:"[^"]*")|(?!(?:(?:\#)|(?:link:)))\S*)? instead of ((?:\"[^\"]*\")|[^#]\S*)?
link:somelink can only be an external link. With the following patch, it is now possible to use such links as link:[[page]], link:[[page|]] or link:[[ns:page|link title]] to point to internal pages.--- syntax.php.orig 2011-01-18 15:05:00.109173222 +0100 +++ syntax.php 2011-01-19 12:32:49.058595826 +0100 @@ -157,19 +157,25 @@ foreach (explode("\n",$content) as $line) { $item = array(); if (preg_match("/^\s*#/",$line) || !trim($line)) { continue; } # skip comments & blanks - # Ustart Usize Model Name? Color? Link? Comment - if (preg_match("/^\s* (\d+) \s+ (\d+) \s+ ((?:\"[^\"]*\")|\S+) \s* ((?:\"[^\"]*\")|[^#]\S*)? \s* (\#\w+)? \s* ((?=link:)\S*)? \s* (.*?)? \s* \$/x",$line,$matches)) { + # Ustart Usize Model Name? Color? Link? Comment + if (preg_match('/^\s* (\d+) \s+ (\d+) \s+ ((?:"[^"]*")|\S+) \s* ((?:"[^"]*")|(?!(?:(?:\#)|(?:link:)))\S*)? \s* (\#\w+)? \s* ( link: (?: (?:\[\[[^]|]+(?:\|[^]]*)?]]) | \S* ) )? \s* (.*?)? \s* $/x',$line,$matches)) { $item['u_bottom'] = $matches[1]; $item['u_size'] = $matches[2]; $item['model'] = preg_replace('/^"/','',preg_replace('/"$/','',$matches[3])); $item['name'] = preg_replace('/^"/','',preg_replace('/"$/','',$matches[4])); $item['color'] = $matches[5] ? $matches[5] : $this->autoselect_color($item); + $item['linktitle'] = ''; $item['link'] = substr($matches[6], 5); + if( '[' == substr($item['link'], 0, 1)) { + if(preg_match( '/^\[\[[^|]+\|([^]]+)]]$/', $item['link'], $titlematch )) + $item['linktitle']=' title="'.hsc($titlematch[1]). '"'; + $item['link']=wl(cleanID(preg_replace( '/^\[\[([^]|]+).*/', '$1', $item['link'] ))); + } $item['comment'] = $matches[7]; $item['u_top'] = $item['u_bottom'] + ($opt['descending']?-1:1)*($item['u_size'] - 1); $items[$item['u_top']] = $item; } else { - $renderer->doc .= "Syntax error on the following line: <pre style='color:red'>$line</pre>\n"; + $renderer->doc .= 'Syntax error on the following line: <pre style="color:red">'.hsc($line)."</pre>\n"; } } @@ -187,7 +193,7 @@ $renderer->doc .= "<tr><th>$u</th>". "<td class='item' rowspan='$item[u_size]' style='background-color: $item[color];' title=\"".htmlspecialchars($item['comment'])."\">". - ($item['link'] ? "<a href=\"$item[link]\">" : ''). + ($item['link'] ? '<a href="'.$item['link'].'"'.$item['linktitle'].'>' : ''). "<div style='float: left; font-weight:bold;'>". "$item[model]" . ($item['comment'] ? ' *' : '').
— schplurtz
schplurtz
France, Finistère 2011/01/19 11:50
I figured I could use a “link” option for this nice plugin, so I made little changes in the syntax.php file. Please contact me for remarks and questions.
Usage:
<u_bottom> <u_size> <model> [name] [#color] [link:http://url] [comment]
(This feature is now available in the official 20100115.0 release linked at the top of this page. –TKB)
The link now covers the whole cell, so you can now click on the model or hostname. Email.
(Integrated into 20100301.0 –TKB)
Each rack is enclosed in <rack>...</rack> tags. The rack tag can have the following parameters (all optional):
Between these tags is a series of lines, each describing a piece of equipment:
<u_bottom> <u_size> <model> [name] [#color] [link:<URL>] [comment]
The fields:
You can also include comment lines starting with a pound sign #.
Here is an example 16U rack and the resulting output:
<rack name=A20 height=16> # This line is a comment, and will be ignored. # Here's a 4U server. We just give the location, size, model, and name: 1 4 "IBM x3950" webserver1 # Here's another server with a comment appended and a link to a web page: 5 4 "HP DL380" webdemo link:http://company.com/bob/ On loan from Bob. # There's some empty space in the rack here, but there's no need to make a note of it. # If the model or name doesn't have any spaces, you can drop the quotes. # Also, the name field is optional. 12 1 Cableguide # The color is automatically picked based on the model, unless you override it. # This unknown device will be gray by default. 13 1 "Crazytown 9000" crazy1 # To override the color, just specify a #RRGGBB HTML color after the model/name. We'll make this one yellow: 14 1 "Crazytown 9000" crazy2 #FFFF00 link:http://example.com/ </rack>
If you want to add new auto-coloring options, edit syntax.php and add conditionals to the autoselect_color function.
Shoot me an email.
The usual: Author assumes no responsibility for this software, use at your own risk. Don't sue me.