#?SuikaWikiConfig/2.0

## NOTE: This WikiPlugin module is written in euc-japan.

Plugin:
  @Name: TextRotate
  @FullName:
    Juliuce encryption
  @Description:
    @@@:
      TextRotate WikiPlugin module implements ROT 13 and TEN 25 (Juliuce
      encryption for basic latin alphabet and kana.)
    @@lang: en
  @License: %%Perl%%
  @Author[list]:
     Wakaba <w@suika.fam.cx>
  @Date.RCS:
    $Date: 2004/02/14 10:51:14 $
  @RequiredModule[list]:
    Jcode
  @RequiredPlugin[list]:
    WikiFormCore

FormattingRule:
  @Category[list]:
    form-template
  @Name: rot
  @Description:
    @@@: ROT 13 (for basic latin alphabet) + TEN 25 (for kana)
    @@lang: en
  @Parameter:
    @@Name: rot13
    @@Type: boolean
    @@Default: "1"
    @@Description:
      @@@@: Whether ROT 13 should be applied.
      @@@lang: en
  @Parameter:
    @@Name: source
    @@Type: form-id
    @@Default: (auto)
    @@Description:
      @@@@:
        Form field name from which source text to be encrypted
        retrived.
      @@@lang: en
  @Parameter:
    @@Name: ten25
    @@Type: boolean
    @@Default: "1"
    @@Description:
      @@@@: Whether TEN 25 should be applied.
      @@@lang: en
  @Parameter:
    @@Name: text
    @@Type: text
    @@Default: (auto)
    @@Description:
      @@@@:
        Source text to be encrypted.  "source" parameter is referred
        if missing.
      @@@lang:en
  @After:
    my $src = $p->{text}
           || $o->{wiki}->{input}->parameter ('wikiform__'.$p->{source});
    $src = __FUNCPACK__->rot13 ($src) unless $p->{rot13} && !$p->{rot13};
    $src = __FUNCPACK__->ten25 ($src) unless $p->{ten25} && !$p->{ten25};
    $p->{-result} .= $src;

Function:
  @Name: ten25
  @Description:
    @@@: Encrypting text with TEN 25
    @@lang: en
  @Main:
    my (undef, $s) = @_;
## TODO: This code MUST be fixed after SuikaWiki is utf8'ized.
	    my $tr_f = q{あいうえおかきくけこさしすせそたちつてとなにぬねの}
	              .q{はひふへほまみむめもやゝゆ〜よらりるれろわゐんゑを}
	              .q{アイウエオカキクケコサシスセソタチツテトナニヌネノ}
	              .q{ハヒフヘホマミムメモヤヽユーヨラリルレロワヰンヱヲ};
	    my $tr_t = q{はひふへほまみむめもやゝゆ〜よらりるれろわゐんゑを}
	              .q{あいうえおかきくけこさしすせそたちつてとなにぬねの}
	              .q{ハヒフヘホマミムメモヤヽユーヨラリルレロワヰンヱヲ}
	              .q{アイウエオカキクケコサシスセソタチツテトナニヌネノ};
    require Jcode;
	    Jcode->new (\$s, 'euc')->tr ($tr_f => $tr_t);
    $s;

Function:
  @Name: rot13
  @Description:
    @@@:
      Encrypting text with ROT 13.
    @@lang: en
  @Main:
    my (undef, $s) = @_;
    $s =~ tr/A-Za-z/N-ZA-Mn-za-m/;
    $s;

