[Home]WikiPatches/NowPseudoLink

UseModWiki | WikiPatches | RecentChanges | Preferences

This patch adds to pseudo links, [ [ now ] ] and [ [ NOW ] ] (spaces inserted here to prevent these links from expanding). They are expanded to a short version of today's date at edit time. When you re-edit the page (or when you press Preview), the links are replaced by the text.

There are some pros and cons to using forced link (aka FreeLink?) syntax for this. It is easier for our users who don't need to learn another convention. It is hard to extend later, because every pseudo link eats up a possible wiki target.

The nice thing is that we can make a now and NOW page and explain the use of these words. You would not be able to refer to these pages, but you can search for them.. :-) Actuallly, you can refer to ``Now'' without problems.

TODO:

dirk janssen feb 2003

Patched against usemod 0.92

*** usemod.pl	Sun Feb 16 00:27:40 2003
--- usemod.pl~	Fri Feb 14 21:55:08 2003
***************
*** 2375,2391 ****
    return CalcDay($Now);
  }
  
- sub CalcShortDay {
-     my ($ts) = @_;
- 
-     $ts += $TimeZoneOffset;
-     my ($sec, $min, $hour, $mday, $mon, $year) = localtime($ts);
-     return  $mday . ("Jan", "Feb", "Mar", "Apr", "May", "Jun",
- 	    "Jul", "Aug", "Sep", "Oct", "Nov",
- 	    "Dec")[$mon] .  sprintf("%02d", $year % 100) ;
- }
-     
- 
  sub CalcTime {
    my ($ts) = @_;
    my ($ampm, $mytz);
--- 2375,2380 ----
***************
*** 3230,3245 ****
    return @links;
  }
  
- sub EditTimeSubs {
-     my ($string) = @_;
-     my ($nowtext);
-     
-     $nowtext = &CalcShortDay($Now);
-     $string =~ s/\[\[now\]\]/$nowtext/g;
-     $string =~ s/\[\[NOW\]\]/'''$nowtext'''/g;
-     return $string;
- }
- 
  sub DoPost {
    my ($editDiff, $old, $newAuthor, $pgtime, $oldrev, $preview, $user);
    my $string = &GetParam("text", undef);
--- 3219,3224 ----
***************
*** 3271,3277 ****
    $summary =~ s/[\r\n]//g;
    # Add a newline to the end of the string (if it doesn't have one)
    $string .= "\n"  if (!($string =~ /\n$/));
-   $string = &EditTimeSubs($string);
  
    # Lock before getting old page to prevent races
    &RequestLock() or die(T('Could not get editing lock'));
--- 3250,3255 ----

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited September 2, 2007 4:51 pm by MarkusLude (diff)
Search: