[Home]WikiPatches/AutoSignature

UseModWiki | WikiPatches | RecentChanges | Preferences

This patch adds a new Wiki markup token. The "~" character repeated three times will insert the writer's username into the text when the page is saved. This works in different ways depending on context:

At the start of a normal line or a line indented with ":" characters, this produces:

Username:

At the end of a line, the username is enclosed with brackets to make a wiki link, like this:

-- Username

 Elsewhere, the user name is just added with italic tags either side.

If the writer has no username, they are signed as "Guest".

This patch is in use on Unreal Wiki -- Tarquin

Patch

Locate line 3918 on an unmodified wiki.pl 1.0 ($string .= "\n" if (!($string =~ /\n$/));) and add the following lines under line 3918:

  # tarq: user signoff
  {
      my $signature = &GetParam("username", "");
      my $linkedsig = "[[$signature]]";
      if ( $signature eq "" ) {
          $signature = "Guest" ;
          $linkedsig = "''Guest''";
      }
      for ( $string ) {
          s[ ^(:*)\s*~~~ ][\n$1'''$signature:''' ]xmg;
          s[ ~~~\s*$     ][ -- $linkedsig ]xmg;
          s[ ~~~         ][ '''$signature''' ]xg;
          s[ /me (?!\w)  ]['''$signature''']xg; # You may want to comment out this one.
      }
  }

Drawbacks

Once applied, the string ~~~ will ALWAYS be parsed. It can't be escaped with the nowiki tag. It's possible to have \~~~ ignored, but then rendered text shows the excape character, so the markup processing part of the script would need to look for that and skip the backslash.

See also


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited November 22, 2009 9:05 am by JuanmaMP (diff)
Search: