Skip to content

Commit

Permalink
Item8116: detwikification
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/BreadCrumbsPlugin@3486 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Apr 17, 2009
1 parent 5537c13 commit 988acea
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 42 deletions.
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1209401597" format="1.1" reprev="1.2" version="$Rev$"}%
%META:TOPICINFO{author="ProjectContributor" date="1209401597" format="1.1" version="$Rev$"}%
<!--

PLEASE DO NOT EDIT THIS TOPIC
Expand Down Expand Up @@ -83,7 +83,7 @@ Each of the above format strings (format, header, footer,
separator) may contain special variables:
* =$name=: the name of the breadcrumb, this is the topic name or the web name having its
parent web part being stripped off (that is =Bar= instead of =Sandbox/Foo/Bar=)
* =$webtopic=: the full =web.topic= of the breadcrumb (twiki syntax)
* =$webtopic=: the full =web.topic= of the breadcrumb (wiki syntax)
* =$target=: the full =web/topic= of the breadcrumb (url syntax)
* =$name=: name of the breadcrumbs item this is the !TopicTitle, spaced out or normal topic name
topic
Expand Down Expand Up @@ -163,8 +163,9 @@ separator) may contain special variables:
| Plugin Author: | Michael Daum |
| Copyright &copy;: | 2006-2009, Michael Daum http://michaeldaumconsulting.com |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Version: | v2.21 (%$VERSION%) |
| Plugin Version: | v2.30 (%$VERSION%) |
| Change History: | &nbsp; |
| 17 Apr 2009: | converted to Foswiki |
| 07 Jan 2009: | fixed breadcrumbs breadcrumbs title for pattern skin |
| 11 Nov 2008: | hide <nop>WebHome in location breadcrumbs |
| 15 Sep 2008: | switching off current topic in =topicoff= mode |
Expand All @@ -183,6 +184,6 @@ separator) may contain special variables:
| CPAN Dependencies: | none |
| Other Dependencies: | none |
| Perl Version: | 5.8 |
| Plugin Home: | http://nextwiki.org/Extensions/%TOPIC% |
| Feedback: | http://nextwiki.org/Extensions/%TOPIC%Dev |
| Plugin Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC%Dev |

Expand Up @@ -12,29 +12,29 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

package TWiki::Plugins::BreadCrumbsPlugin;
package Foswiki::Plugins::BreadCrumbsPlugin;

use strict;
use vars qw(
$VERSION $RELEASE $NO_PREFS_IN_TOPIC $SHORTDESCRIPTION $doneInit
);

$VERSION = '$Rev$';
$RELEASE = 'v2.20';
$RELEASE = 'v2.30';
$NO_PREFS_IN_TOPIC = 1;
$SHORTDESCRIPTION = 'A flexible way to display breadcrumbs navigation';

###############################################################################
sub initPlugin {

TWiki::Func::registerTagHandler('BREADCRUMBS', \&renderBreadCrumbs);
Foswiki::Func::registerTagHandler('BREADCRUMBS', \&renderBreadCrumbs);

my $doRecordTrail = TWiki::Func::getPreferencesValue('BREADCRUMBSPLUGIN_RECORDTRAIL') || '';
my $doRecordTrail = Foswiki::Func::getPreferencesValue('BREADCRUMBSPLUGIN_RECORDTRAIL') || '';
$doRecordTrail = ($doRecordTrail eq 'on')?1:0;

if ($doRecordTrail) {
init();
TWiki::Plugins::BreadCrumbsPlugin::Core::recordTrail($_[1], $_[0]);
Foswiki::Plugins::BreadCrumbsPlugin::Core::recordTrail($_[1], $_[0]);
} else {
#print STDERR "not recording the click path trail\n";
}
Expand All @@ -46,14 +46,14 @@ sub initPlugin {
sub init {
return if $doneInit;
$doneInit = 1;
require TWiki::Plugins::BreadCrumbsPlugin::Core;
TWiki::Plugins::BreadCrumbsPlugin::Core::init(@_);
require Foswiki::Plugins::BreadCrumbsPlugin::Core;
Foswiki::Plugins::BreadCrumbsPlugin::Core::init(@_);
}

###############################################################################
sub renderBreadCrumbs {
init();
return TWiki::Plugins::BreadCrumbsPlugin::Core::renderBreadCrumbs(@_);
return Foswiki::Plugins::BreadCrumbsPlugin::Core::renderBreadCrumbs(@_);
}

1;
Expand Up @@ -12,32 +12,32 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

package TWiki::Plugins::BreadCrumbsPlugin::Core;
package Foswiki::Plugins::BreadCrumbsPlugin::Core;

use strict;
use vars qw($homeTopic $lowerAlphaRegex $upperAlphaRegex $numericRegex);
use TWiki::Plugins;
use Foswiki::Plugins;

use constant DEBUG => 0; # toggle me

###############################################################################
sub writeDebug {
return unless DEBUG;

#&TWiki::Func::writeDebug('- BreadCrumbPlugin - '.$_[0]);
#&Foswiki::Func::writeDebug('- BreadCrumbPlugin - '.$_[0]);
print STDERR '- BreadCrumbPlugin - '.$_[0]."\n";
}

###############################################################################
sub init {

$homeTopic = TWiki::Func::getPreferencesValue('HOMETOPIC')
|| $TWiki::cfg{HomeTopicName} || 'WebHome';
$homeTopic = Foswiki::Func::getPreferencesValue('HOMETOPIC')
|| $Foswiki::cfg{HomeTopicName} || 'WebHome';

if ($TWiki::Plugins::VERSION < 1.1) {
$lowerAlphaRegex = TWiki::Func::getRegularExpression('lowerAlpha');
$upperAlphaRegex = TWiki::Func::getRegularExpression('upperAlpha');
$numericRegex = TWiki::Func::getRegularExpression('numeric');
if ($Foswiki::Plugins::VERSION < 1.1) {
$lowerAlphaRegex = Foswiki::Func::getRegularExpression('lowerAlpha');
$upperAlphaRegex = Foswiki::Func::getRegularExpression('upperAlpha');
$numericRegex = Foswiki::Func::getRegularExpression('numeric');
}
}

Expand All @@ -47,9 +47,9 @@ sub recordTrail {

writeDebug("called recordTrail($web, $topic)");

($web, $topic) = TWiki::Func::normalizeWebTopicName($web, $topic);
($web, $topic) = Foswiki::Func::normalizeWebTopicName($web, $topic);
my $here = "$web.$topic";
my $trail = TWiki::Func::getSessionValue('BREADCRUMB_TRAIL') || '';
my $trail = Foswiki::Func::getSessionValue('BREADCRUMB_TRAIL') || '';
my @trail = split(',', $trail);

# Detect cycles by scanning back along the trail to see if we've been here
Expand All @@ -63,7 +63,7 @@ sub recordTrail {
}
push(@trail, $here);

TWiki::Func::setSessionValue('BREADCRUMB_TRAIL', join(',', @trail));
Foswiki::Func::setSessionValue('BREADCRUMB_TRAIL', join(',', @trail));
}

###############################################################################
Expand Down Expand Up @@ -148,15 +148,15 @@ sub renderBreadCrumbs {

# expand common variables
escapeParameter($result);
$result = TWiki::Func::expandCommonVariables($result, $topic, $web);
$result = Foswiki::Func::expandCommonVariables($result, $topic, $web);

return $result;
}

###############################################################################
sub getPathBreadCrumbs {

my $trail = TWiki::Func::getSessionValue('BREADCRUMB_TRAIL') || '';
my $trail = Foswiki::Func::getSessionValue('BREADCRUMB_TRAIL') || '';
my @trail =
map {
/^(.*)\.(.*?)$/;
Expand Down Expand Up @@ -230,7 +230,7 @@ sub getLocationBreadCrumbs {

while (1) {
# get parent
my ($meta, $dumy) = &TWiki::Func::readTopic($web, $topic);
my ($meta, $dumy) = &Foswiki::Func::readTopic($web, $topic);
my $parentMeta = $meta->get('TOPICPARENT');
last unless $parentMeta;
my $parentName = $parentMeta->{name};
Expand All @@ -241,7 +241,7 @@ sub getLocationBreadCrumbs {
last if
$topic eq $homeTopic ||
$seen{"$web.$topic"} ||
!TWiki::Func::topicExists($web,$topic);
!Foswiki::Func::topicExists($web,$topic);

# add breadcrumb
#writeDebug("adding breadcrumb: target=$web/$topic, name=$topic");
Expand Down Expand Up @@ -288,7 +288,7 @@ sub escapeParameter {
}

###############################################################################
# local version to run on legacy twiki releases
# local version to run on legacy wiki releases
sub normalizeWebTopicName {
my ($web, $topic) = @_;

Expand All @@ -305,16 +305,16 @@ sub getTopicTitle {
my ($theWeb, $theTopic) = @_;

# use DBCachePlugin if installed
if (TWiki::Func::getContext()->{'DBCachePluginEnabled'}) {
require TWiki::Plugins::DBCachePlugin;
return TWiki::Plugins::DBCachePlugin::getTopicTitle($theWeb, $theTopic);
if (Foswiki::Func::getContext()->{'DBCachePluginEnabled'}) {
require Foswiki::Plugins::DBCachePlugin;
return Foswiki::Plugins::DBCachePlugin::getTopicTitle($theWeb, $theTopic);
}

# use core means otherwise
my $topicTitle = TWiki::Func::getPreferencesValue("TOPICTITLE");
my $topicTitle = Foswiki::Func::getPreferencesValue("TOPICTITLE");
return $topicTitle if $topicTitle;

my ($meta, $text) = TWiki::Func::readTopic($theWeb, $theTopic);
my ($meta, $text) = Foswiki::Func::readTopic($theWeb, $theTopic);
my $field = $meta->get('FIELD', 'TopicTitle');
if ($field) {
$topicTitle = $field->{value};
Expand All @@ -328,8 +328,8 @@ sub getTopicTitle {
sub spaceOutWikiWord {
my ($wikiWord, $separator) = @_;

return TWiki::Func::spaceOutWikiWord($wikiWord, $separator)
if $TWiki::Plugins::VERSION >= 1.13;
return Foswiki::Func::spaceOutWikiWord($wikiWord, $separator)
if $Foswiki::Plugins::VERSION >= 1.13;

$wikiWord =~ s/([$lowerAlphaRegex])([$upperAlphaRegex$numericRegex]+)/$1$separator$2/go;
$wikiWord =~ s/([$numericRegex])([$upperAlphaRegex])/$1$separator$2/go;
Expand Down
4 changes: 4 additions & 0 deletions lib/Foswiki/Plugins/BreadCrumbsPlugin/MANIFEST
@@ -0,0 +1,4 @@
data/System/BreadCrumbsPlugin.txt 0644
lib/Foswiki/Plugins/BreadCrumbsPlugin.pm 0644
lib/Foswiki/Plugins/BreadCrumbsPlugin/Core.pm 0644
templates/view.breadcrumbs.tmpl 0644
4 changes: 0 additions & 4 deletions lib/TWiki/Plugins/BreadCrumbsPlugin/MANIFEST

This file was deleted.

2 changes: 1 addition & 1 deletion templates/view.breadcrumbs.tmpl
@@ -1,3 +1,3 @@
%TMPL:INCLUDE{"view"}%
%TMPL:DEF{"topicpathseparator"}%<span class='twikiSeparator'>&nbsp;&#187;</span> %TMPL:END%
%TMPL:DEF{"topicpathseparator"}%<span class='foswikiSeparator'>&nbsp;&#187;</span> %TMPL:END%
%TMPL:DEF{"breadcrumb"}%%TMPL:P{"breadcrumb:title"}%%BREADCRUMBS{separator="%TMPL:P{"topicpathseparator"}%"}%%TMPL:END%

0 comments on commit 988acea

Please sign in to comment.