Skip to content

Commit

Permalink
Item8709: capital is an SSP macro, and should not be processed by a …
Browse files Browse the repository at this point in the history
…format rendering - the docco for the %DATE macros only talks about lowercase, so this has been a hidden mis-feature for quite some time - needs unit tests for both DATE and SSP

git-svn-id: http://svn.foswiki.org/trunk@6750 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Mar 15, 2010
1 parent 4091882 commit 36bc557
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 11 deletions.
83 changes: 83 additions & 0 deletions UnitTestContrib/test/unit/Fn_SEARCH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2989,4 +2989,87 @@ sub test_summary_searchcontext_long_word_search {
CRUD
}

#from the FormattedSearch topic
sub verify_FormattedSearch__Search_with_conditional_output {
my $this = shift;

my $result =
$this->{test_topicObject}->expandMacros(<<'HERE');
%SEARCH{
"."
scope="topic"
type="regex"
nosearch="on"
nototal="on"
order="modified"
reverse="on"
format="| $date | [[$topic]] | $wikiusername | $date | $rev |"
limit="3"
}%
HERE

$this->assert_html_equals( <<CRUD, $result );
| 15 Mar 2010 - 00:11 | [[OkBTopic]] | TemporarySEARCHUsersWeb.WikiGuest | 15 Mar 2010 - 00:11 | 1 |
| 15 Mar 2010 - 00:11 | [[OkTopic]] | TemporarySEARCHUsersWeb.WikiGuest | 15 Mar 2010 - 00:11 | 1 |
| 15 Mar 2010 - 00:11 | [[WebPreferences]] | TemporarySEARCHUsersWeb.WikiGuest | 15 Mar 2010 - 00:11 | 1 |
CRUD

$result =
$this->{test_topicObject}->expandMacros(<<'HERE');
%CALC{$SET(weekold, $TIMEADD($TIME(), -7, day))}%
%CALC{$IF($TIME(15 Mar 2010 - 00:11) < $GET(weekold), no, yes)}%
HERE

$this->assert_html_equals( <<CRUD, $result );
yes
CRUD

$result =
$this->{test_topicObject}->expandMacros(<<'HERE');
%CALC{$SET(weekold, $TIMEADD($TIME(), -7, day))}%
%SEARCH{
"."
scope="topic"
type="regex"
nosearch="on"
nototal="on"
order="modified"
reverse="on"
format="$percentCALC{$IF($TIME($date) < $GET(weekold), no, yes)}$percent"
limit="3"
}%
HERE

$this->assert_html_equals( <<CRUD, $result );
yes
yes
yes
CRUD

$result =
$this->{test_topicObject}->expandMacros(<<'HERE');
%CALC{$SET(weekold, $TIMEADD($TIME(), -7, day))}%
%SEARCH{
"."
scope="topic"
type="regex"
nosearch="on"
nototal="on"
order="modified"
reverse="on"
format="$percentCALC{$IF($TIME($date) < $GET(weekold), <nop>, | [[$topic]] | $wikiusername | $date | $rev |)}$percent"
limit="3"
}%
HERE

$this->assert_html_equals( <<CRUD, $result );
| [[OkBTopic]] | TemporarySEARCHUsersWeb.WikiGuest | 15 Mar 2010 - 00:44 | 1 |
| [[OkTopic]] | TemporarySEARCHUsersWeb.WikiGuest | 15 Mar 2010 - 00:44 | 1 |
| [[WebPreferences]] | TemporarySEARCHUsersWeb.WikiGuest | 15 Mar 2010 - 00:44 | 1 |
CRUD
}


1;
22 changes: 11 additions & 11 deletions core/lib/Foswiki/Render.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1637,26 +1637,26 @@ sub renderRevisionInfo {
}

my $value = $format || 'r$rev - $date - $time - $wikiusername';
$value =~ s/\$web/$topicObject->web() || ''/gei;
$value =~ s/\$web/$topicObject->web() || ''/ge;
$value =~ s/\$topic\(([^\)]*)\)/
Foswiki::Render::breakName( $topicObject->topic(), $1 )/gei;
$value =~ s/\$topic/$topicObject->topic() || ''/gei;
$value =~ s/\$rev/$info->{version}/gi;
Foswiki::Render::breakName( $topicObject->topic(), $1 )/ge;
$value =~ s/\$topic/$topicObject->topic() || ''/ge;
$value =~ s/\$rev/$info->{version}/g;
$value =~ s/\$time/
Foswiki::Time::formatTime($info->{date}, '$hour:$min:$sec')/gei;
Foswiki::Time::formatTime($info->{date}, '$hour:$min:$sec')/ge;
$value =~ s/\$date/
Foswiki::Time::formatTime(
$info->{date}, $Foswiki::cfg{DefaultDateFormat} )/gei;
$info->{date}, $Foswiki::cfg{DefaultDateFormat} )/ge;
$value =~ s/(\$(rcs|http|email|iso|longdate))/
Foswiki::Time::formatTime($info->{date}, $1 )/gei;
Foswiki::Time::formatTime($info->{date}, $1 )/ge;

if ( $value =~ /\$(sec|min|hou|day|wday|dow|week|mo|ye|epoch|tz)/ ) {
$value = Foswiki::Time::formatTime( $info->{date}, $value );
}
$value =~ s/\$comment/$info->{comment}/gi;
$value =~ s/\$username/$un/gi;
$value =~ s/\$wikiname/$wn/gi;
$value =~ s/\$wikiusername/$wun/gi;
$value =~ s/\$comment/$info->{comment}/g;
$value =~ s/\$username/$un/g;
$value =~ s/\$wikiname/$wn/g;
$value =~ s/\$wikiusername/$wun/g;

return $value;
}
Expand Down

0 comments on commit 36bc557

Please sign in to comment.