Skip to content

Commit

Permalink
Item1916: Port LinkOptionsPlugin to Foswiki
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/LinkOptionsPlugin@4643 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ItaloValcy authored and ItaloValcy committed Aug 11, 2009
1 parent f3581ed commit d306591
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 66 deletions.
Expand Up @@ -19,7 +19,7 @@ Some new options and CSS sets can be used simultaneously, separated by a pipe (|
| ==Title== | %GREEN%Text%ENDCOLOR% | A text to be a hint for the link |
| ==Class== | %GREEN%Name%ENDCOLOR% | The name of a class (to define CSS style) |
| ==ID== | %GREEN%Name%ENDCOLOR% | This %GREEN%Name%ENDCOLOR% must be unique on the web page |
| ==Skin== | %GREEN%<nop>SkinName%ENDCOLOR% | %GREEN%SkinName%ENDCOLOR% must be a valid TWiki skin |
| ==Skin== | %GREEN%<nop>SkinName%ENDCOLOR% | %GREEN%SkinName%ENDCOLOR% must be a valid Foswiki skin |
| ==CSS== | %GREEN%CSS Code%ENDCOLOR% | %GREEN%CSS Code%ENDCOLOR% is any CSS formatatin code. You can repeat this option <p/> ==color== is a CSS properti, and you can put values like =%GREEN%#00A0F0%ENDCOLOR%= or =%GREEN%red%ENDCOLOR%=. See more colors in %SYSTEMWEB%.StandardColors. You can use any CSS properti (valid for links) hire. See more in the [[http://www.w3.org/TR/REC-CSS2/cover.html#minitoc][CSS2 Specification in the W3C Web Site]]. |
The option names are case insensitive for LinkOptionsPlugin or CSS, but the W3C defines the CSS properties in lower case and it is important to validade. Write the LinkOptionsPlugin optins as you prefer.

Expand All @@ -41,12 +41,12 @@ Opening in a new window (with options):
* *Code:* =[<nop>[%SYSTEMWEB%.Macros][See the Macros][NewWin:600x500|Name:winMacros|Skin:plain]]=
* *Expand to:* <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/%SYSTEMWEB%/Macros?skin=plain" target="winMacros"\
onclick="open('%SCRIPTURL%/view%SCRIPTSUFFIX%/%SYSTEMWEB%/Macros?skin=plain',\
'winMacros', 'titlebar=0,width=600,height=500,resizable,scrollbars'); return false;">See the TWiki Variables</a>
'winMacros', 'titlebar=0,width=600,height=500,resizable,scrollbars'); return false;">See the Macros</a>
* *If installed:* [[%SYSTEMWEB%.Macros][See the Macros][NewWin:600x500|Name:winMacros|Skin:plain]]

Crazy CSS use:
* *Code:* =[<nop>[<nop>WebHome][Crazy Link!][color:green|background-color:#FFF0A0|border:3px dotted #FFC030|text-decoration:none|letter-spacing:10px|padding:4px|font-size:15px|font-weight:900]]=
* *Expand to:* <a style="color:green; background-color:#FFF0A0; border:3px dotted #FFC030; text-decoration:none; letter-spacing:10px; padding:4px; font-size:15px; font-weight:900; " class="twikiLink" href="/twiki/bin/view/TWiki/WebHome">Crazy Link!</a>
* *Expand to:* <a style="color:green; background-color:#FFF0A0; border:3px dotted #FFC030; text-decoration:none; letter-spacing:10px; padding:4px; font-size:15px; font-weight:900; " class="foswikiLink" href="/foswiki/bin/view/System/WebHome">Crazy Link!</a>
* *If installed:* [[WebHome][Crazy Link!][color:green|background-color:#FFF0A0|border:3px dotted #FFC030|text-decoration:none|letter-spacing:10px|padding:4px|font-size:15px|font-weight:900]]


Expand All @@ -60,35 +60,32 @@ Plugin settings are stored as preferences variables. To reference a plugin setti
* Set DEBUG to 1 to get debug messages in data/debug.txt. Default: 0
* Set DEBUG = 0

---++ Plugin Installation Instructions
---++ Installation Instructions

__Note:__ You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
%$INSTALL_INSTRUCTIONS%

---++ Plugin Files

| *File:* | *Description:* |
%$MANIFEST%

* Download the ZIP file from the Plugin web (see below)
* Unzip ==%TOPIC%.zip== in your twiki installation directory. Content:
| *File:* | *Description:* |
| ==data/System/%TOPIC%.txt== | Plugin topic |
| ==data/System/%TOPIC%.txt,v== | Plugin topic repository |
| ==lib/Foswiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
* Dakar: Visit =configure= in your TWiki installation, and enable the plugin in the {Plugins} section.
* Test if the installation was successful.
you should see rendered dates on the [[#Examples][example session]].

---++ Plugin Info

| Plugin Author: | TWiki:Main.AurelioAHeckert |
| Plugin Version: | 27 Jul 2006 (v1.001) |
| Plugin Author: | Foswiki:Main.ItaloValcy |
| Previous Author: | Foswiki:Main.AurelioAHeckert |
| Copyright: | &copy; 2009, Italo Valcy, &copy; 2005-2006, Aurelio A. Heckert |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 21 Jul 2009 | Foswiki:Main.ItaloValcy: Porting to Foswiki (closes Foswikitask:Item1916) |
| 27 Jul 2006 | (v1.001) - TWiki:Main.AntonioTerceiro: Dakar compatibility |
| 29 Mar 2005 | Initial version |
| TWiki Dependency: | $TWiki::Plugins::VERSION 1.024 |
| Foswiki Dependency: | $Foswiki::Plugins::VERSION 1.024 |
| CPAN Dependencies: | none |
| Other Dependencies: | none |
| Perl Version: | 5.005 |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Home: | http://foswiki.org/Extensions/%TOPIC% |
| Feedback: | http://foswiki.org/Extensions/%TOPIC%Dev |
| Support: | http://foswiki.org/Support/%TOPIC% |

__Related Topics:__ %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences, [[%SYSTEMWEB%.Plugins][Plugins]]

-- TWiki:Main.AurelioAHeckert - 29 Mar 2005
Expand Up @@ -12,58 +12,25 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html
#
# =========================
#
# This is an empty TWiki plugin. Use it as a template
# for your own plugins; see %SYSTEMWEB%.Plugins for details.
#
# Each plugin is a package that may contain these functions: VERSION:
#
# initPlugin ( $topic, $web, $user, $installWeb ) 1.000
# initializeUserHandler ( $loginName, $url, $pathInfo ) 1.010
# registrationHandler ( $web, $wikiName, $loginName ) 1.010
# commonTagsHandler ( $text, $topic, $web ) 1.000
# startRenderingHandler ( $text, $web ) 1.000
# outsidePREHandler ( $text ) 1.000
# insidePREHandler ( $text ) 1.000
# endRenderingHandler ( $text ) 1.000
# beforeEditHandler ( $text, $topic, $web ) 1.010
# afterEditHandler ( $text, $topic, $web ) 1.010
# beforeSaveHandler ( $text, $topic, $web ) 1.010
# writeHeaderHandler ( $query ) 1.010 Use only in one Plugin
# redirectCgiQueryHandler ( $query, $url ) 1.010 Use only in one Plugin
# getSessionValueHandler ( $key ) 1.010 Use only in one Plugin
# setSessionValueHandler ( $key, $value ) 1.010 Use only in one Plugin
#
# initPlugin is required, all other are optional.
# For increased performance, all handlers except initPlugin are
# disabled. To enable a handler remove the leading DISABLE_ from
# the function name. Remove disabled handlers you do not need.
#
# NOTE: To interact with TWiki use the official TWiki functions
# in the TWiki::Func module. Do not reference any functions or
# variables elsewhere in TWiki!!


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

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

# This should always be $Rev$ so that TWiki can determine the checked-in
# This should always be $Rev$ so that Foswiki can determine the checked-in
# status of the plugin. It is used by the build automation tools, so
# you should leave it alone.
$VERSION = '$Rev$';

# This is a free-form string you can use to "name" your own plugin version.
# It is *not* used by the build automation tools, but is reported as part
# of the version number in PLUGINDESCRIPTIONS.
$RELEASE = 'Dakar';
$RELEASE = '1.0.0';

$pluginName = 'LinkOptionsPlugin'; # Name of this Plugin

Expand All @@ -75,16 +42,16 @@ sub initPlugin
( $topic, $web, $user, $installWeb ) = @_;

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

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

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

Expand All @@ -93,7 +60,7 @@ sub commonTagsHandler
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead

TWiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug;
Foswiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug;

# This is the place to define customized tags and variables
# Called by sub handleCommonTags, after %INCLUDE:"..."%
Expand Down Expand Up @@ -131,7 +98,7 @@ sub handleLinkOptions
my $extraAtt = '';
my @sepOpt;

my $html = TWiki::Func::renderText("[[$link][$text]]");
my $html = Foswiki::Func::renderText("[[$link][$text]]");

$options =~ s/win([^:|]+):([^|]+)(\||$)/$1=:$2$3/g;
my @options = split(/\|/, $options);
Expand Down
2 changes: 2 additions & 0 deletions lib/Foswiki/Plugins/LinkOptionsPlugin/MANIFEST
@@ -0,0 +1,2 @@
data/System/LinkOptionsPlugin.txt 0664 Plugin description topic
lib/Foswiki/Plugins/LinkOptionsPlugin.pm 0444 Plugin code module
Expand Up @@ -8,10 +8,10 @@ BEGIN
}
}

use TWiki::Contrib::Build;
use Foswiki::Contrib::Build;

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

# Build the target on the command line, or the default target
$build->build($build->{target});
Expand Down
2 changes: 0 additions & 2 deletions lib/TWiki/Plugins/LinkOptionsPlugin/MANIFEST

This file was deleted.

0 comments on commit d306591

Please sign in to comment.