Name:
WikiPage
FullName:
Getting WikiPage information
URI:
IW:SuikaWiki:WikiAdmin
{
Name:
wikiform_input/recent-change-list
FullName:
Recent-changed-pages list
Format:
eval q{
if ($o->{to} eq 'RSS') {
require Yuki::RSS;
my $rss = new Yuki::RSS (version => '1.0');
my $myuri = $o->uri ('wiki');
$rss->stylesheet (
href => $myuri . "?mycmd=css;mypage=WikiStyle:RSS",
type => 'text/css',
);
$rss->channel(
title => $o->resource ('RSS:WikiTitle'),
link => $myuri,
description => $o->resource ('RSS:WikiDescription'),
'dc:language' => $main::lang,
);
for my $title ($main::database->recent_changes ($p->{n} || 10)) {
next unless $title;
$rss->add_item (
title => $o->escape ($title),
link => $myuri . '?' . $o->encode ($title),
description => $o->escape(&main::get_subjectline($title,delimiter=>'')),
'dc:date' => $main::database->mtime ($title),
);
}
$r = $rss->as_string;
} else {
$r = qq(
\n);
for ($main::database->recent_changes ($p->{n} || 10)) {
next unless $_;
my @date = gmtime $main::database->mtime ($_);
$date[0] = sprintf '%04d-%02d-%02d %02d:%02d:%02d+00:00', $date[5]+1900,$date[4]+1,@date[3,2,1,0];
$r .= qq(- $date[0] ) . $o->escape ($_) . qq();
$r .= ' '.$o->escape (&main::get_subjectline ($_)).'' if $p->{summary};
$r .= qq(
\n);
}
$r .= '
';
}
} or $r = '';
}
{
Name:
wikiview/recent-change-dated
FullName:
Recent-changed-pages list, grouped by modified date
Format:
eval q{
$r = qq(\n);
my $date = '';
for ($main::database->recent_changes ($p->{n} || 10)) {
next unless $_;
my @date = gmtime $main::database->mtime ($_);
my $ndate = sprintf '%04d-%02d-%02d', $date[5]+1900,$date[4]+1,$date[3];
if ($ndate ne $date) {
$r .= "\n" if $date;
my $id = 'h'.$o->new_index ('heading');
my $level = $p->{level}+0||1;
$r .= qq(
$ndate\n
\n);
push @{$o->{toc}}, [$level-1 => $id => $ndate] if !defined $p->{add_to_toc} || $p->{add_to_toc};
$date = $ndate;
}
$date[0] = sprintf '%s %02d:%02d:%02d+00:00', $ndate, @date[2,1,0];
$r .= qq(- ) . $o->escape ($_) . qq(
\n);
}
$r .= '
';
} or $r = $o->escape($@);
}
{
Name:
wikiform_input/recent-change-dated
FullName:
Recent-changed-pages list, grouped by modified date
Format:
eval q{
$r = qq(\n);
my $date = '';
for ($main::database->recent_changes ($p->{n} || 10)) {
next unless $_;
my @date = gmtime $main::database->mtime ($_);
my $ndate = sprintf '%04d-%02d-%02d', $date[5]+1900,$date[4]+1,$date[3];
if ($ndate ne $date) {
$r .= "\n" if $date;
my $id = 'h'.$o->new_index ('heading');
my $level = ($p->{level}+0||1)+1;
$r .= qq(
$ndate\n
\n);
push @{$o->{toc}}, [$level-1 => $id => $ndate] if !defined $p->{add_to_toc} || $p->{add_to_toc};
$date = $ndate;
}
$date[0] = sprintf '%s %02d:%02d:%02d+00:00', $ndate, @date[2,1,0];
$r .= qq(- ) . $o->escape ($_) . qq(
\n);
}
$r .= '
';
} or $r = $o->escape($@);
}
{
Name:
wikiform_input/page-list
FullName:
WikiPage list
Format:
eval q{
$r = qq(\n);
my $re = $p->{match} || '.';
for (grep /$re/, keys %main::database) {
$r .= qq(- ) . $o->escape ($_) . qq();
$r .= ' '.$o->escape (&main::get_subjectline ($_)).'' if $p->{summary};
$r .= qq(
\n);
}
$r .= '
';
} or $r = '';
}
{
Name:
wikiformat/SuikaWiki/0.9-to-RSS
FullName:
SuikaWiki/0.9 document format -> RSS
URI:
IW:SuikaWiki:SuikaWiki
Format:
$o->{content} =~ s($main::embed_command{form}){
my $i = $2;
$i =~ s/\\(.)/$1/gs;
if ($i =~ /(%recent-change-list(?:\((?:[^)]|\\.)*\))?;)/s) {
$r = $o->formatter ('form_input')->replace ($1 => $o);
return $r;
}
''}ge;
$r = '';
}
{
Name:
wikiview/search-result
FullName:
Search result of given page name
Format:
($r) = main::get_search_result ($o->{page});
}
{
Name:
wikiform_input/search-result
FullName:
Search result with the given string
Format:
my $word = $p->{case_sensible} ? $p->{key} : lc $p->{key};
my @r;
my $sr = $o->cache ('search');
unless (defined $sr->{$word}) {
for my $page (keys %main::database) {
my ($magic, $content) = $o->magic_and_content ($main::database{$page});
$content = $p->{case_sensible} ? $content : lc $content;
$content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s;
if (index (lc $page, $word) > -1) {
my $c = $content =~ s/\Q$word\E//g;
push @r, [$page, $c+20];
} elsif (index ($word, lc $page) > -1) {
my $c = $content =~ s/\Q$word\E//g;
push @r, [$page, $c+10];
} elsif (my $c = $content =~ s/\Q$word\E//g) {
push @r, [$page, $c];
}
}
@r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;
$sr->{$word} = join "\x1E", map {$_->[0]."\x1F".$_->[1]} @r;
} else {
@r = map {[split /\x1F/, $_, 2]} split /\x1E/, $sr->{$word};
}
my $em = $p->{em} ? sub { my $s = shift; $s =~ s#(\Q$word\E)#$1#gi; $s } : sub {$_[0]};
$r = join "\n", map {qq([$_->[1]] @{[&$em($o->escape($_->[0]))]} @{[&$em($o->escape(&main::get_subjectline($_->[0])))]})} @r;
$r = qq|| if $r;
}
{
Name:
wikiview/link-map
FullName:
Hyperlink map from the WikiPage
Format:
sub make_list ($;%) {
my ($page, %option) = @_;
$option{level} ||= 3;
my %weight;
my $content = $main::database{$page};
$content =~ s{^\#\?([^\x0A\x0D]+)}{
if ($1 =~ /import="([^"]+)"/) {
for (split /\s*,\s*/, $1) {
$weight{$_} += 2;
}
}
$&;
}ges;
## Bug: this code does not support content type.
$content =~ s{\[\[((?!\#)[^]]+)\](?:>>\d+)?\]}{
$weight{$1}++; $&;
}ge;
delete $weight{$page}; ## Delete myself
for my $page (keys %weight) {
my $w = ($content =~ s/\Q$page\E/$&/g);
$weight{$page} += $w + $weight{$page}; ## Weight of [[name]] is x2.
($weight{$page} *= 0.1, $option{not_exist}->{$page} = 1) unless &main::is_exist_page ($page);
}
$option{weight_list}->{$page} = \%weight;
if (--$option{level}) {
for my $page (keys %weight) {
&make_list ($page, %option) unless $option{weight_list}->{$page};
}
}
$option{weight_list};
}
sub list_to_html ($$;%) {
my ($Page, $wlist, %option) = @_;
my $r = '';
$option{outputed}->{$Page} = 1;
for my $page (sort {$wlist->{$Page}->{$b} <=> $wlist->{$Page}->{$a}} keys %{$wlist->{$Page}}) {
$r .= qq([@{[0+$wlist->{$Page}->{$page}]}] @{[$o->escape ($page).($option{not_exist}->{$page}?qq(@{[$o->resource('JumpAndEditWikiPageMark',escape=>1)]}):'')]} @{[$o->escape($option{map_from_here})]} @{[$o->escape(&main::get_subjectline($page))]});
unless ($option{outputed}->{$page}) {
$r .= &list_to_html ($page, $wlist, %option);
}
$r .= "\n";
}
$r ? qq() : '';
}
my %option = (level => 0+$o->resource('Map:Depth'), weight_list => {},
not_exist => {}, map_from_here => $o->resource('Map:FromHere'),
map_from_here_description => $o->resource('Map:FromHereLong'));
&make_list ($o->{page}, %option);
$r = &list_to_html ($o->{page}, $option{weight_list}, %option);
}
{
Name:
wikiview/last-modified
FullName:
Last-modified date & time of the page
Format:
$r = &main::_rfc3339_date ($main::database->mtime ($p->{page} || $o->{page}));
}
{
Name:
wikiview-resource/last-modified
FullName:
Last-modified date & time of the page
Format:
$r = &main::_rfc3339_date ($main::database->mtime ($p->{page} || $o->{page}));
}
{
Name:
wikiform_input/last-modified
FullName:
Last-modified date & time of the page
Format:
$r = &main::_rfc3339_date ($main::database->mtime ($p->{page} || $o->{page}));
}
{
Name:
wikiview/page-name
FullName:
Page name
Format:
$r = $o->escape ($o->{page});
}
{
Name:
wikiview-resource/page-name
FullName:
Page name
Format:
$r = $o->escape ($o->{page});
}
{
Name:
wikiview/wiki-link
FullName:
Link to the WikiPage
Format:
$r = &main::make_wikilink ($o->escape ($p->{page}||$o->{page}), anchor => $p->{anchor}, latest => 1);
}
{
Name:
wikiview-resource/wiki-link
FullName:
Link to the WikiPage
Format:
$r = &main::make_wikilink ($o->escape ($p->{page}||$o->{page}), anchor => $p->{anchor}, latest => 1);
}
{
Name:
wikiview/diff-between-previous
FullName:
Difference between previous version of this WikiPage
Format:
$r = qq();
for (split /\n/, $o->escape ($main::database->traverse_diff ($o->{page}))) {
if (/^\+(.*)/) {
$r .= qq($1\n);
} elsif (/^\-(.*)/) {
$r .= qq($1\n);
} elsif (/^\=(.*)/) {
$r .= qq($1\n);
} else {
$r .= qq|??? $_\n|;
}
}
$r .= qq(
);
}
{
Name:
wikiview/link-wiki
FullName:
Link element to the wiki itself
Format:
unless ($p->{href}) {
$p->{mode} ||= 'read';
$p->{page} = $o->{page} unless defined $p->{page};
$p->{href} = $o->uri('wiki').'?';
if ($p->{up_to_date} || $p->{mode} ne 'read' || $p->{add_param}) {
$p->{href} .= qq(mypage=@{[$o->encode($p->{page})]};mycmd=@{[$o->encode($p->{mode})]});
$p->{href} .= ';'.$p->{add_param} if $p->{add_param};
$p->{href} .= ';x-d='.time if $p->{up_to_date};
$p->{href} .= ';x-lm='.($main::database->mtime ($p->{page})||0) if $p->{with_lm};
} else {
$p->{href} .= $o->encode ($p->{page});
}
}
$r = qq(escape($p->{$attr})]}") if $p->{$attr};
}
for my $attr (qw/title/) {
$r .= qq( $attr="@{[$o->formatter('view')->replace($p->{$attr},$o)]}") if $p->{$attr};
}
$r .= '/' if $o->{media}->{type} =~ /xml/;
$r .= '>';
}
{
Name:
wikiview/anchor-wiki
FullName:
A element to the wiki page
Format:
unless ($p->{href}) {
$p->{mode} ||= 'read';
$p->{page} = $o->{page} unless defined $p->{page};
$p->{href} = $o->uri('wiki').'?';
if ($p->{up_to_date} || $p->{mode} ne 'read' || $p->{add_param}) {
$p->{href} .= qq(mypage=@{[$o->encode($p->{page})]};mycmd=@{[$o->encode($p->{mode})]});
$p->{href} .= ';'.$p->{add_param} if $p->{add_param};
$p->{href} .= ';x-d='.time if $p->{up_to_date};
$p->{href} .= ';x-lm='.($main::database->mtime ($p->{page})||0) if $p->{with_lm};
} else {
$p->{href} .= $o->encode ($p->{page});
}
}
$r = qq(escape($p->{$attr})]}") if $p->{$attr};
}
for my $attr (qw/title accesskey/) {
$r .= qq( $attr="@{[$o->formatter('view')->replace($p->{$attr},$o)]}") if $p->{$attr};
}
$r .= '>' . $o->formatter ('view')->replace ($p->{label}, $o) . '';
}
{
Name:
wikiview/referer-list
FullName:
Referer-list of page
Format:
$r = wiki::referer::list_html ($o->{page});
}
{
Name:
wikiview/uri-wiki
FullName:
Output URI of the WikiPage (as anchor)
Format:
my $uri = $o->uri('wiki').'?'.$o->encode($p->{page}||$o->{page});
$r = qq(<$uri>);
}
POD:LICENSE:
Copyright 2003 Wakaba
%%GNUGPL2%%