Name: WikiPage FullName: Getting WikiPage information URI: IW:SuikaWiki:WikiAdmin Require: SuikaWiki::Markup::XML main Initialize: my $NS_XHTML1 = 'http://www.w3.org/1999/xhtml'; { Name: wikiview/search-result wikiform_input/search-result FullName: Search result with the given string Format: $p->{key} ||= $o->{page}; 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]}; my $ul = SuikaWiki::Markup::XML->new (local_name => 'ul', namespace_uri => $NS_XHTML1); for (@r) { my $li = $ul->append_new_node (local_name => 'li', namespace_uri => $NS_XHTML1); $li->append_text ('{' . $_->[1] . '} '); my $a = $li->append_new_node (local_name => 'a', namespace_uri => $NS_XHTML1); $a->set_attribute (href => $o->uri('wiki').'?'.$o->encode($_->[0])); $a->set_attribute (class => 'wiki'); $a->append_text ($_->[0]); $li->append_text (' '); my $hl = $li->append_new_node (local_name => 'span', namespace_uri => $NS_XHTML1); $hl->set_attribute (class => 'headline'); $hl->append_text (__PACKAGE__->_get_subjectline ($_->[0])); $ul->append_text ("\n"); } $r = $ul if $ul->count; } { Name: wikiview/last-modified wikiview-resource/last-modified wikiform-input/last-modified FullName: Last-modified date & time of the page Format: $r = SuikaWiki::Markup::XML->new (type => '#text', value => &main::_rfc3339_date ($o->get_data (lastmodified => [$p->{page} || $o->{page}]))); ## TODO: } { Name: wikipage-link/last-modified FullName: Last-modified date & time of the page Format: $r = SuikaWiki::Markup::XML->new (type => '#text', value => &main::_rfc3339_date ($o->{link}->{dest}->{page_lastmodified} || $o->get_data (lastmodified => [$o->{link}->{dest}->{page_name}]))); ## TODO: temp. } { Name: wikiview-resource/page-name wikiform-input/page-name wikiview/page-name wikipage_list_item/page-name FullName: Page name Format: $r = SuikaWiki::Markup::XML->new (type => '#text', value => $o->{page}); } { Name: wikipage-link/page-name FullName: Name of the WikiPage Format: if ($p->{relative}) { $r = SuikaWiki::Markup::XML->new (type => '#text', value => $o->{link}->{dest}->{page_name_relative}); } else { $r = SuikaWiki::Markup::XML->new (type => '#text', value => $o->{link}->{dest}->{page_name}); } } { Name: wikipage-link/page-title FullName: Title of the WikiPage Description: Returns title of the destination WikiPage. Note that currently WikiPage itself cannot have page title information so that title not same as WikiName is only able to be specified by generator of the link context. (In other words, customized title is defined by the link, not the page linked to.) Format: if (defined $o->{link}->{dest}->{page_title}) { $r = SuikaWiki::Markup::XML->new (type => '#text', value => $o->{link}->{dest}->{page_title}); } elsif ($p->{relative}) { $r = SuikaWiki::Markup::XML->new (type => '#text', value => $o->{link}->{dest}->{page_name_relative}); } else { $r = SuikaWiki::Markup::XML->new (type => '#text', value => $o->{link}->{dest}->{page_name}); } } { Name: wikipage-link/page-headline FullName: Headline of the WikiPage Format: $r = SuikaWiki::Markup::XML->new (type => '#text', value => __PACKAGE__->_get_subjectline ($o->{link}->{dest}->{page_name}, delimiter => '')); } { Name: wikiview/wiki-link wikiview-resource/wiki-link FullName: Link to the WikiPage Format: $r = &main::make_wikilink ($o->escape ($p->{page}||$o->{page}), anchor => $p->{anchor}, up_to_date => 1); } { Name: wikipage_list_item/wiki-link FullName: Link to the WikiPage Format: $r = $o->_html_wikilink ($o->escape ($p->{page}||$o->{page}), anchor => $p->{anchor}, up_to_date => $p->{up_to_date}, label => $p->{label}); } { Name: wikiview/link-wiki FullName: Link element to the wiki itself Format: unless ($p->{href}) { $p->{mode} ||= 'read'; $p->{page} ||= $o->{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}; } $r .= '/' if $o->{media}->{type} =~ /xml/; $r .= '>'; } { Name: wikiview/anchor-wiki FullName: A element to the wiki page Format: $p->{href} ||= compose_wiki_page_uri ($o, $p, {}); $p->{label} = $p->{page} unless length $p->{label}; if ($p->{page} ne $p->{label} && !defined $p->{title}) { $p->{title} = $p->{page}; } $r = qq(escape($p->{$attr})]}") if $p->{$attr}; } $r .= '>' . $o->escape ($p->{label}) . ''; } { Name: wikiview-resource/anchor-wiki FullName: A element to the wiki page Format: $p->{href} = compose_wiki_page_uri ($o, $p, {}); $p->{label} = $p->{page} unless length $p->{label}; if ($p->{page} ne $p->{label} && !defined $p->{title}) { $p->{title} = $p->{page} || $o->{page}; } $r = qq(escape($p->{$attr})]}") if $p->{$attr}; } $r .= '>' . $o->escape ($p->{label}) . ''; } { 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>); } { Name: wikiview/log-hotness FullName: Logging hotness of the page Format: my $db = $o->cache ('hotness', -expires=>7*24*3600, -removes=>7*24*3600); $db->{$o->{page}||$p->{page}} += ($p->{weight} || 1); } { Name: wikiform_input/hotness-list FullName: Hotness-of-pages' list Format: my $db = $o->cache ('hotness', -expires=>7*24*3600, -removes=>7*24*3600); my $i = 0; $r = qq(