Feature Proposal:
Motivation
Description and Documentation
Following changes to lib/TWiki/attach.pm allows time/date processing:
Add after
use strict;
use Assert;
use TWiki::Time;
and add before
# I18N: Site specified %ATTACHEDIMAGEFORMAT% or %ATTACHEDFILELINKFORMAT%,
# ensure that filename is URL encoded - first $name must be URL.
$fileLink =~ s/\$name/$fileURL/;
$fileLink =~ s/\$name/$attName/;
my $fileext = $attName;
$fileext =~ s/(.*\.)*([^.]*)/$2/;
$fileLink =~ s/\$fileext/$fileext/;
if (defined $att->{date})
{
my $date = $att->{date};
use Time::localtime;
my ($seconds,$minutes,$hours,$day,$mo,$ye,$wday,$ydat,$isdst) = gmtime($date);
#require TWiki::time;
$fileLink =~ s/\$date/TWiki::Time::formatTime( $date || 0)/gei;
$fileLink =~ s/\$seconds/TWiki::Time::formatTime( $date || 0, "\$seconds")/gei;
$fileLink =~ s/\$minutes/TWiki::Time::formatTime( $date || 0, "\$minutes")/gei;
$fileLink =~ s/\$hours/TWiki::Time::formatTime( $date || 0, "\$hours")/gei;
$fileLink =~ s/\$wday/TWiki::Time::formatTime( $date || 0, "\$wday")/gei;
$fileLink =~ s/\$day/TWiki::Time::formatTime( $date || 0, "\$day")/gei;
$fileLink =~ s/\$month/TWiki::Time::formatTime( $date || 0, "\$month")/gei;
$fileLink =~ s/\$mo/TWiki::Time::formatTime( $date || 0, "\$mo")/gei;
$fileLink =~ s/\$year/TWiki::Time::formatTime( $date || 0, "\$year")/gei;
$fileLink =~ s/\$ye/TWiki::Time::formatTime( $date || 0, "\$ye")/gei;
}
After this change, following attachment example is possible:
On TWIki Site:
* Local ATTACHEDFILELINKFORMAT = |$year-$mo-$day|Effort |[[%ATTACHURL%/$name][%ICON{$fileext}% $name]]| received from company xy |
Simple enhancement with nice effects, good enough to add to the next twiki version?
--
TWiki:Main/SaschaVetter - 18 Aug 2008
Examples
Impact
Implementation
--
Contributors: TWiki:Main/SaschaVetter - 18 Aug 2008
Discussion
sounds interesting - I guess what we need is documentation to go into the released topics, and unit tests.
--
SvenDowideit - 01 Oct 2009
This does look simple. It's gone nowhere on (tm)wiki. I'll commit to adding the feature and some tests for 1.2 if still interested. Should it also expand the common Formatting tokens? (
Foswiki::Func::decodeFormatTokens
/
Foswiki::expandStandardEscapes
- $n, $nop, $quot, $comma, $percnt, $lt, $gt, $amp, $dollar) for consistency?
--
GeorgeClark - 23 Feb 2012
Added using the standardEscapes and also use Foswiki::Time to expand the standard date/time tokens.
--
GeorgeClark - 26 May 2012