From: <Mar...@nt...> - 2005-04-16 13:47:59
|
Author: MartinCleaver Date: 2005-04-16 06:46:54 -0700 (Sat, 16 Apr 2005) New Revision: 4026 Modified: twiki/branches/DEVELOP/lib/TWiki/Plurals.pm twiki/branches/DEVELOP/lib/TWiki/Render.pm Log: SuggestSingularNotPlural: Thanks to BenHouston ; as per his patch minus pref Modified: twiki/branches/DEVELOP/lib/TWiki/Plurals.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Plurals.pm 2005-04-16 13:22:55 UTC (rev 4025) +++ twiki/branches/DEVELOP/lib/TWiki/Plurals.pm 2005-04-16 13:46:54 UTC (rev 4026) @@ -71,6 +71,8 @@ my $singularForm = $pluralForm; $singularForm =~ s/ies$/y/; # plurals like policy / policies $singularForm =~ s/sses$/ss/; # plurals like address / addresses + $singularForm =~ s/ches$/ch/; # plurals like search / searches + $singularForm =~ s/(oes|os)$/o/; # plurals like veto / vetoes $singularForm =~ s/([Xx])es$/$1/;# plurals like box / boxes $singularForm =~ s/([^s])s$/$1/; # others, excluding ss like address(es) return $singularForm Modified: twiki/branches/DEVELOP/lib/TWiki/Render.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Render.pm 2005-04-16 13:22:55 UTC (rev 4025) +++ twiki/branches/DEVELOP/lib/TWiki/Render.pm 2005-04-16 13:46:54 UTC (rev 4026) @@ -445,9 +445,10 @@ my $store = $this->{session}->{store}; my $topicExists = $store->topicExists( $theWeb, $theTopic ); + my $singular = ''; unless( $topicExists ) { # topic not found - try to singularise - my $singular = TWiki::Plurals::singularForm($theWeb, $theTopic); + $singular = TWiki::Plurals::singularForm($theWeb, $theTopic); if( $singular ) { $topicExists = $store->topicExists( $theWeb, $singular ); $theTopic = $singular if $topicExists; @@ -459,8 +460,14 @@ $theTopic, $theLinkText, $theAnchor); } if( $doLinkToMissingPages ) { - return _renderNonExistingWikiWord($this, $theWeb, $theTopic, + if ($singular && $singular ne $theTopic) { + my @topics = ($singular, $theTopic); + return _renderNonExistingWikiWord($this, $theWeb, \@topics, $theLinkText, $theAnchor); + } else { + return _renderNonExistingWikiWord($this, $theWeb, $theTopic, + $theLinkText, $theAnchor); + } } if( $doKeepWeb ) { return $theWeb.'.'.$theLinkText; @@ -490,13 +497,30 @@ my $ans; $ans = CGI::font( { -color=>$this->{NEWTOPICFONTCOLOR} }, $theLinkText ); - $ans .= CGI::a( { href=>$this->{session}->getScriptUrl + + if (ref $theTopic && ref $theTopic eq 'ARRAY') { + my $num = 1; + foreach my $t(@{ $theTopic }) { + next if ! $t; + $ans .= CGI::a( { href=>$this->{session}->getScriptUrl + ($theWeb, $t, 'edit', + topicparent => $this->{session}->{webName}.'.'. + $this->{session}->{topicName} ), + rel => 'nofollow' + }, + $this->{NEWLINKSYMBOL} x $num . " " ); + $num++; + } + } else { + $ans .= CGI::a( { href=>$this->{session}->getScriptUrl ($theWeb, $theTopic, 'edit', topicparent => $this->{session}->{webName}.'.'. $this->{session}->{topicName} ), rel => 'nofollow' }, $this->{NEWLINKSYMBOL} ); + } + return CGI::span( { class=>'twikiNewLink', style=>'background : '.$this->{NEWTOPICBGCOLOR}.';' }, $ans ); |