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(<ol class="recent-changes">\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(<li><span class="date">$date[0]</span> <a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki">) . $o->escape ($_) . qq(</a>); $r .= ' <span class="summary">'.$o->escape (&main::get_subjectline ($_)).'</span>' if $p->{summary}; $r .= qq(</li>\n); } $r .= '</ol>'; } } or $r = ''; } { Name: wikiview/recent-change-dated FullName: Recent-changed-pages list, grouped by modified date Format: eval q{ $r = qq(<div class="recent-changes">\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 .= "</ol>\n" if $date; my $id = 'h'.$o->new_index ('heading'); my $level = $p->{level}+0||1; $r .= qq(<h$level id="$id">$ndate</h$level>\n<ol>\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(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki" title="@{[$o->escape (&main::get_subjectline ($_,delimiter=>''))]} [$date[0]]">) . $o->escape ($_) . qq(</a></li>\n); } $r .= '</ol></div>'; } or $r = $o->escape($@); } { Name: wikiform_input/recent-change-dated FullName: Recent-changed-pages list, grouped by modified date Format: eval q{ $r = qq(<div class="recent-changes">\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 .= "</ol>\n" if $date; my $id = 'h'.$o->new_index ('heading'); my $level = ($p->{level}+0||1)+1; $r .= qq(<h$level id="$id">$ndate</h$level>\n<ol>\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(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki" title="@{[$o->escape($_)]} [$date[0]]">) . $o->escape ($_) . qq(</a></li>\n); } $r .= '</ol></div>'; } or $r = $o->escape($@); } { Name: wikiform_input/page-list FullName: WikiPage list Format: eval q{ $r = qq(<ul class="pages">\n); my $re = $p->{match} || '.'; for (grep /$re/, keys %main::database) { $r .= qq(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki">) . $o->escape ($_) . qq(</a>); $r .= ' <span class="summary">'.$o->escape (&main::get_subjectline ($_)).'</span>' if $p->{summary}; $r .= qq(</li>\n); } $r .= '</ul>'; } 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 = '<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>'; } { 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)#<em>$1</em>#gi; $s } : sub {$_[0]}; $r = join "\n", map {qq(<li>[$_->[1]] <a href ="@{[$o->uri('wiki').'?'.$o->encode($_->[0])]}" class="wiki">@{[&$em($o->escape($_->[0]))]}</a> <span class="headline">@{[&$em($o->escape(&main::get_subjectline($_->[0])))]}</span></li>)} @r; $r = qq|<ul class="search-result">$r</ul>| 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(<li><span class="weight">[@{[0+$wlist->{$Page}->{$page}]}]</span> <a href="$main::url_cgi?@{[&main::encode($page)]}" class="wiki@{[$option{not_exist}->{$page}?' not-exist':'']}">@{[$o->escape ($page).($option{not_exist}->{$page}?qq(<span class="mark">@{[$o->resource('JumpAndEditWikiPageMark',escape=>1)]}</span>):'')]}</a> <a href="$main::url_cgi?mycmd=map;mypage=@{[&main::encode($page)]}" class="wiki-cmd map-from-here" title="@{[&main::escape($option{map_from_here_description})]}">@{[$o->escape($option{map_from_here})]}</a> <span class="summary">@{[$o->escape(&main::get_subjectline($page))]}</span>); unless ($option{outputed}->{$page}) { $r .= &list_to_html ($page, $wlist, %option); } $r .= "</li>\n"; } $r ? qq(<ul class="map">$r</ul>) : ''; } 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(<pre class="diff">); for (split /\n/, $o->escape ($main::database->traverse_diff ($o->{page}))) { if (/^\+(.*)/) { $r .= qq(<ins class="added">$1</ins>\n); } elsif (/^\-(.*)/) { $r .= qq(<del class="deleted">$1</del>\n); } elsif (/^\=(.*)/) { $r .= qq(<span class="same">$1</span>\n); } else { $r .= qq|??? $_\n|; } } $r .= qq(</pre>); } { 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(<link); for my $attr (qw/rel rev href class type hreflang charset/) { $r .= qq( $attr="@{[$o->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(<a); for my $attr (qw/rel rev href class type hreflang charset/) { $r .= qq( $attr="@{[$o->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) . '</a>'; } { 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(<<a href="$uri">$uri</a>>); } POD:LICENSE: Copyright 2003 Wakaba <w@suika.fam.cx> %%GNUGPL2%%