Skip to content

Commit

Permalink
Item1156: Create Release01x00 branch
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x00@2728 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
KennethLavrsen authored and KennethLavrsen committed Feb 26, 2009
1 parent d399d97 commit 38dacb8
Show file tree
Hide file tree
Showing 32 changed files with 756 additions and 0 deletions.
411 changes: 411 additions & 0 deletions RenderListPlugin/data/System/RenderListPlugin.txt

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions RenderListPlugin/data/System/VarRENDERLIST.txt
@@ -0,0 +1,15 @@
%META:TOPICINFO{author="ProjectContributor" date="1191140974" format="1.1" version="$Rev$"}%
%META:TOPICPARENT{name="Macros"}%
#VarRENDERLIST
---+++ RENDERLIST -- render bullet lists in a variety of formats
* The =%<nop>RENDERLIST%= macro is handled by the RenderListPlugin
* Syntax: =%<nop>RENDERLIST%=
* Syntax: =%<nop>RENDERLIST{ "org" focus="Sales.WestCoastTeam" }%=
* Example:%BR%
=%<nop>RENDERLIST{ "org" }%= %BR%
=&nbsp; * [<nop>[Eng.WebHome][Engineering]]= %BR%
=&nbsp; * [<nop>[Eng.TechPubs][Tech Pubs]]= %BR%
=&nbsp; * [<nop>[Sales.WestCoastTeam][Sales]]= %BR%
=&nbsp; * [<nop>[Sales.EastCoastTeam][East Coast]]= %BR%
=&nbsp; * [<nop>[Sales.WestCoastTeam][West Coast]]=
* Related: RenderListPlugin
283 changes: 283 additions & 0 deletions RenderListPlugin/lib/Foswiki/Plugins/RenderListPlugin.pm
@@ -0,0 +1,283 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2001-2007 Peter Thoeny, peter@thoeny.org
# Copyright (C) 2008 Foswiki Contributors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. For
# more details read LICENSE in the root of this distribution.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# As per the GPL, removal of this notice is prohibited.
# =========================


# =========================
package Foswiki::Plugins::RenderListPlugin; # change the package name and $pluginName!!!

# =========================
use vars qw(
$web $topic $user $installWeb $VERSION $RELEASE $pluginName
$debug $pubUrl $attachUrl
);

$VERSION = '$Rev: 16234 $';
$RELEASE = '2.1';
$pluginName = 'RenderListPlugin'; # Name of this Plugin

# =========================
sub initPlugin
{
( $topic, $web, $user, $installWeb ) = @_;

# check for Plugins.pm versions
if( $Foswiki::Plugins::VERSION < 1 ) {
Foswiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" );
return 0;
}

# Get plugin debug flag
$debug = Foswiki::Func::getPreferencesFlag( "\U$pluginName\E_DEBUG" );

# one time initialization
$pubUrl = Foswiki::Func::getUrlHost() . Foswiki::Func::getPubUrlPath();
$attachUrl = "$pubUrl/$installWeb/$pluginName";

# Plugin correctly initialized
Foswiki::Func::writeDebug( "- Foswiki::Plugins::${pluginName}::initPlugin( $web.$topic ) is OK" ) if $debug;
return 1;
}

# =========================
sub startRenderingHandler
{
### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead

Foswiki::Func::writeDebug( "- ${pluginName}::startRenderingHandler( $_[1] )" ) if $debug;

# This handler is called by getRenderedVersion just before the line loop

# Render here, not in commonTagsHandler so that lists produced by
# Plugins, TOC and SEARCH can be rendered
if ($_[0] =~/%RENDERLIST/o ) {
unless ($_[0] =~ s/%RENDERLIST{(.*?)}%(([\n\r]+[^ ]{3}[^\n\r]*)*?)(([\n\r]+ {3}[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges ) {
# Cairo compatibility fallback
$_[0] =~ s/%RENDERLIST{(.*?)}%(([\n\r]+[^\t]{1}[^\n\r]*)*?)(([\n\r]+\t[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges;
}
}
}

# =========================
sub handleRenderList
{
my ( $theAttr, $thePre, $theList ) = @_;

$theAttr =~ s/ {3}/\t/gs;
$thePre =~ s/ {3}/\t/gs;
$theList =~ s/ {3}/\t/gs;

my $focus = &Foswiki::Func::extractNameValuePair( $theAttr, "focus" );
my $depth = &Foswiki::Func::extractNameValuePair( $theAttr, "depth" );
my $theme = &Foswiki::Func::extractNameValuePair( $theAttr, "theme" ) ||
&Foswiki::Func::extractNameValuePair( $theAttr );
$theme = "RENDERLISTPLUGIN_" . uc( $theme ) . "_THEME";
$theme = &Foswiki::Func::getPreferencesValue( $theme ) || "unrecognized theme type";
my ( $type, $params ) = split( /, */, $theme, 2 );
$type = lc( $type );

if( $type eq "tree" || $type eq "icon" ) {
return $thePre . renderIconList( $type, $params, $focus, $depth, $theList );
} else {
return "$thePre$theList";
}
}

# =========================
sub renderIconList
{
my ( $theType, $theParams, $theFocus, $theDepth, $theText ) = @_;

$theText =~ s/^[\n\r]*//os;
my @tree = ();
my $level = 0;
my $type = "";
my $text = "";
my $focusIndex = -1;
foreach( split ( /[\n\r]+/, $theText ) ) {
m/^(\t+)(.) *(.*)/;
$level = length( $1 );
$type = $2;
$text = $3;
if( ( $theFocus ) && ( $focusIndex < 0 ) && ( $text =~ /$theFocus/ ) ) {
$focusIndex = scalar( @tree );
}
push( @tree, { level => $level, type => $type, text => $text } );
}

# reduce tree to relatives around focus
if( $focusIndex >= 0 ) {
# splice tree into before, current node and after parts
my @after = splice( @tree, $focusIndex + 1 );
my $nref = pop( @tree );

# highlight node with focus and remove links
$text = $nref->{'text'};
$text =~ s/^([^\-]*)\[\[.*?\]\[(.*?)\]\]/$1$2/o; # remove [[...][...]] link
$text =~ s/^([^\-]*)\[\[(.*?)\]\]/$1$2/o; # remove [[...]] link
$text = "<b> $text </b>"; # bold focus text
$nref->{'text'} = $text;

# remove uncles and siblings below current node
$level = $nref->{'level'};
for( my $i = 0; $i < scalar( @after ); $i++ ) {
if( ( $after[$i]->{'level'} < $level )
|| ( $after[$i]->{'level'} <= $level && $after[$i]->{'type'} ne " " ) ) {
splice( @after, $i );
last;
}
}

# remove uncles and siblings above current node
my @before = ();
for( my $i = scalar( @tree ) - 1; $i >= 0; $i-- ) {
if( $tree[$i]->{'level'} < $level ) {
push( @before, $tree[$i] );
$level = $tree[$i]->{'level'};
}
}
@tree = reverse( @before );
$focusIndex = scalar( @tree );
push( @tree, $nref );
push( @tree, @after );
}

# limit depth of tree
my $depth = $theDepth;
unless( $depth =~ s/.*?([0-9]+).*/$1/o ) {
$depth = 0;
}
if( $theFocus ) {
if( $theDepth eq "" ) {
$depth = $focusIndex + 3;
} else {
$depth += $focusIndex + 1;
}
}
if( $depth > 0 ) {
my @tmp = ();
foreach my $ref ( @tree ) {
push( @tmp, $ref ) if( $ref->{'level'} <= $depth );
}
@tree = @tmp;
}

$theParams =~ s/%PUBURL%/$pubUrl/go;
$theParams =~ s/%ATTACHURL%/$attachUrl/go;
$theParams =~ s/%WEB%/$installWeb/go;
$theParams =~ s/%MAINWEB%/Foswiki::Func::getMainWebname()/geo;
$theParams =~ s/%TWIKIWEB%/$Foswiki::cfg{SystemWebName}/geo;
$theParams =~ s/%SYSTEMWEB%/$Foswiki::cfg{SystemWebName}/geo;
my ( $showLead, $width, $height, $iconSp, $iconT, $iconI, $iconL, $iconImg )
= split( /, */, $theParams );
$width = 16 unless( $width );
$height = 16 unless( $height );
$iconSp = "empty.gif" unless( $iconSp );
$iconSp = fixImageTag( $iconSp, $width, $height );
$iconT = "dot_udr.gif" unless( $iconT );
$iconT = fixImageTag( $iconT, $width, $height );
$iconI = "dot_ud.gif" unless( $iconI );
$iconI = fixImageTag( $iconI, $width, $height );
$iconL = "dot_ur.gif" unless( $iconL );
$iconL = fixImageTag( $iconL, $width, $height );
$iconImg = "home.gif" unless( $iconImg );
$iconImg = fixImageTag( $iconImg, $width, $height );

$text = "";
my $start = 0;
$start = 1 unless( $showLead );
my @listIcon = ();
for( my $i = 0; $i < scalar( @tree ); $i++ ) {
$text .= '<table border="0" cellspacing="0" cellpadding="0"><tr>' . "\n";
$level = $tree[$i]->{'level'};
for( my $l = $start; $l < $level; $l++ ) {
if( $l == $level - 1 ) {
$listIcon[$l] = $iconSp;
for( my $x = $i + 1; $x < scalar( @tree ); $x++ ) {
last if( $tree[$x]->{'level'} < $level );
if( $tree[$x]->{'level'} <= $level && $tree[$x]->{'type'} ne " " ) {
$listIcon[$l] = $iconI;
last;
}
}
if( $tree[$i]->{'type'} eq " " ) {
$text .= "<td valign=\"top\">$listIcon[$l]</td>\n";
} elsif( $listIcon[$l] eq $iconSp ) {
$text .= "<td valign=\"top\">$iconL</td>\n";
} else {
$text .= "<td valign=\"top\">$iconT</td>\n";
}
} else {
$text .= "<td valign=\"top\">" . ($listIcon[$l] || '') . "</td>\n";
}
}
if( $theType eq "icon" ) {
# icon theme type
if( $tree[$i]->{'type'} eq " " ) {
# continuation line
$text .= "<td valign=\"top\">$iconSp</td>\n";
} elsif( $tree[$i]->{'text'} =~ /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) {
# specific icon
$tree[$i]->{'text'} = $4;
$tree[$i]->{'text'} = "$1 $4" if( $1 );
my $icon = $2;
$icon =~ s/^icon\://o;
$icon = fixImageTag( $icon, $width, $height );
$text .= "<td valign=\"top\">$icon</td>\n";
} else {
# default icon
$text .= "<td valign=\"top\">$iconImg</td>\n";
}
$text .= "<td valign=\"top\"><nobr>&nbsp; $tree[$i]->{'text'} </nobr></td>\n";

} else {
# tree theme type
if( $tree[$i]->{'text'} =~ /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) {
# specific icon
$tree[$i]->{'text'} = $4;
$tree[$i]->{'text'} = "$1 $4" if( $1 );
my $icon = $2;
$icon =~ s/^icon\://o;
$icon = fixImageTag( $icon, $width, $height );
$text .= "<td valign=\"top\">$icon</td>\n";
$text .= "<td valign=\"top\"><nobr>&nbsp; $tree[$i]->{'text'} </nobr></td>\n";
} else {
$text .= "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n";
}
}
$text .= '</tr></table>' . "\n";
}
return $text;
}

# =========================
sub fixImageTag
{
my ( $theIcon, $theWidth, $theHeight ) = @_;

if( $theIcon !~ /^<img/i ) {
$theIcon .= '.gif' if( $theIcon !~ /\.(png|gif|jpeg|jpg)$/i );
$theIcon = "$attachUrl/$theIcon" if( $theIcon !~ /^(\/|https?\:)/ );
$theIcon = "<img src=\"$theIcon\" width=\"$theWidth\" height=\"$theHeight\""
. " alt=\"\" border=\"0\" />";
}
return $theIcon;
}

# =========================

1;
Empty file.
29 changes: 29 additions & 0 deletions RenderListPlugin/lib/Foswiki/Plugins/RenderListPlugin/MANIFEST
@@ -0,0 +1,29 @@
data/System/RenderListPlugin.txt 0644
data/System/VarRENDERLIST.txt 0644
lib/Foswiki/Plugins/RenderListPlugin.pm 0444
pub/System/RenderListPlugin/doc.gif 0644
pub/System/RenderListPlugin/dot_ud.gif 0644
pub/System/RenderListPlugin/dot_udr.gif 0644
pub/System/RenderListPlugin/dot_ur.gif 0644
pub/System/RenderListPlugin/email.gif 0644
pub/System/RenderListPlugin/empty.gif 0644
pub/System/RenderListPlugin/file.gif 0644
pub/System/RenderListPlugin/files.gif 0644
pub/System/RenderListPlugin/folder.gif 0644
pub/System/RenderListPlugin/folders.gif 0644
pub/System/RenderListPlugin/globe.gif 0644
pub/System/RenderListPlugin/group.gif 0644
pub/System/RenderListPlugin/home.gif 0644
pub/System/RenderListPlugin/image.gif 0644
pub/System/RenderListPlugin/pdf.gif 0644
pub/System/RenderListPlugin/person.gif 0644
pub/System/RenderListPlugin/persons.gif 0644
pub/System/RenderListPlugin/ppt.gif 0644
pub/System/RenderListPlugin/see.gif 0644
pub/System/RenderListPlugin/sound.gif 0644
pub/System/RenderListPlugin/trend.gif 0644
pub/System/RenderListPlugin/virtualhome.gif 0644
pub/System/RenderListPlugin/virtualperson.gif 0644
pub/System/RenderListPlugin/virtualpersons.gif 0644
pub/System/RenderListPlugin/xls.gif 0644
pub/System/RenderListPlugin/zip.gif 0644
18 changes: 18 additions & 0 deletions RenderListPlugin/lib/Foswiki/Plugins/RenderListPlugin/build.pl
@@ -0,0 +1,18 @@
#!/usr/bin/perl -w
#
# Build for RenderListPlugin
#
BEGIN {
foreach my $pc (split(/:/, $ENV{FOSWIKI_LIBS})) {
unshift @INC, $pc;
}
}

use Foswiki::Contrib::Build;

# Create the build object
$build = new Foswiki::Contrib::Build( 'RenderListPlugin' );

# Build the target on the command line, or the default target
$build->build($build->{target});

Binary file added RenderListPlugin/pub/System/RenderListPlugin/doc.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RenderListPlugin/pub/System/RenderListPlugin/pdf.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RenderListPlugin/pub/System/RenderListPlugin/ppt.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RenderListPlugin/pub/System/RenderListPlugin/xls.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RenderListPlugin/pub/System/RenderListPlugin/zip.gif

0 comments on commit 38dacb8

Please sign in to comment.