173 |
|
|
174 |
FormattingRule: |
FormattingRule: |
175 |
@Category[list]: |
@Category[list]: |
|
form-input |
|
|
view |
|
|
view-resource |
|
|
@Name: search-result |
|
|
@Formatting: |
|
|
__ATTRTEXT:%key__; |
|
|
$p->{key} ||= $o->{wiki}->{var}->{page}->stringify (wiki => $o->{wiki}); |
|
|
__ATTRTEXT:%case_sensible__; |
|
|
my $word = $p->{case_sensible} ? $p->{key} : lc $p->{key}; |
|
|
my @r; |
|
|
my $sr = $o->{wiki}->{db}->get (m__search_result => [$word]); |
|
|
unless ($sr) { |
|
|
for my $page ($o->{wiki}->{db}->keys ('content')) { |
|
|
my $content; |
|
|
try { |
|
|
$content = $o->{wiki}->{db}->get (content => $page); |
|
|
} catch SuikaWiki::DB::Util::Error with { |
|
|
my $err = shift; |
|
|
$err->throw if $err->{-type} eq 'ERROR_REPORTED'; |
|
|
$content = undef; |
|
|
}; |
|
|
$content = $p->{case_sensitive} ? $content : lc $content; |
|
|
$content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s; |
|
|
$page = $o->{wiki}->name ($page); |
|
|
my $n_page = $page->stringify (wiki => $o->{wiki}); |
|
|
$n_page = lc $n_page unless $p->{case_sensible}; |
|
|
if (index ($n_page, $word) > -1) { |
|
|
my $c = $content =~ s/\Q$word\E//g; |
|
|
push @r, [$page, $c+20]; |
|
|
} elsif (index ($word, $n_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 = join "\x1E", |
|
|
map {$_->[0]->stringify (wiki => $o->{wiki}, delimiter => "\x1D") |
|
|
."\x1F".$_->[1]} @r; |
|
|
$o->{wiki}->{db}->set (m__search_result => [$word] => $sr); |
|
|
## TODO: Cache & case-sensitivility |
|
|
} else { |
|
|
@r = map {[$o->{wiki}->name ($_->[0], delimiter_reg => qr/\x1D/), $_->[1]]} |
|
|
map {[split /\x1F/, $_, 2]} split /\x1E/, $sr; |
|
|
} |
|
|
return unless @r; |
|
|
my $list = $p->{-parent}->append_new_node |
|
|
(type => '#element', |
|
|
namespace_uri => $NS_XHTML1, |
|
|
local_name => 'ol'); |
|
|
__ATTRTEXT:%template__; |
|
|
$p->{template} ||= $WIKIRESOURCE->get |
|
|
(name => 'Link:toWikiPage:SourceLabelLong:SearchResult', |
|
|
wiki => $o->{wiki}, o => $o); |
|
|
for (@r) { |
|
|
$WIKILINKING->to_wikipage_in_html ({ |
|
|
label => $p->{template}, |
|
|
} => { |
|
|
base => $o->{wiki}->{var}->{page}, |
|
|
page_name_relative => $_->[0], |
|
|
wiki_mode => $p->{mode}, |
|
|
}, { |
|
|
o => $o, |
|
|
parent => $list->append_new_node |
|
|
(type => '#element', |
|
|
namespace_uri => $NS_XHTML1, |
|
|
local_name => 'li'), |
|
|
-m__weight => $_->[1], |
|
|
}); |
|
|
} |
|
|
|
|
|
FormattingRule: |
|
|
@Category[list]: |
|
176 |
page-link |
page-link |
177 |
@Name: m--link-weight |
@Name: m--link-weight |
178 |
@Formatting: |
@Formatting: |
194 |
template => {%resource-as-plain-text (name => {Children:Item});}p, |
template => {%resource-as-plain-text (name => {Children:Item});}p, |
195 |
);}p, |
);}p, |
196 |
); |
); |
|
%section ( |
|
|
id => see-also, |
|
|
title => {%res(name=>SeeAlso);}p, heading, |
|
|
content => {%search-result;}p, |
|
|
); |
|
|
|
|
|
Resource: |
|
|
@Children:Title: |
|
|
%link-to-it(label=>{%ns-short-page-name;}p, |
|
|
description=>{%page-name(absolute);}p, |
|
|
); |
|
|
%span(class=>headline, content=>{%page-headline;}p); |
|
|
@Link:toWikiPage:SourceLabelLong:PageList: |
|
|
%link-to-it( |
|
|
label=>{%page-title(relative);}p, |
|
|
description=>{%page-name(absolute);}p, |
|
|
); |
|
|
%span(class=>headline,content=>{%page-headline;}p); |
|
|
@Link:toWikiPage:SourceLabelLong:RecentChangeItem: |
|
|
%last-modified; |
|
|
%link-to-it( |
|
|
label=>{%page-title(relative);}p, |
|
|
description=>{%page-name(absolute);}p, |
|
|
); |
|
|
%span(class=>headline,content=>{%page-headline;}p); |
|
|
@Link:toWikiPage:SourceLabelLong:SearchResult: |
|
|
{%m--link-weight;} |
|
|
%link-to-it( |
|
|
label=>{%page-title(relative);}p, |
|
|
description=>{%page-name(absolute);}p, |
|
|
); |
|
|
%span(class=>headline,content=>{%page-headline;}p); |
|
197 |
|
|
198 |
## TODO: Make recent-changes page name customizable |
## TODO: Make recent-changes page name customizable |
199 |
ViewFragment: |
ViewFragment: |
222 |
); |
); |
223 |
|
|
224 |
Resource: |
Resource: |
225 |
|
@Children:Title: |
226 |
|
%link-to-it(label=>{%ns-short-page-name;}p, |
227 |
|
description=>{%page-name(absolute);}p, |
228 |
|
); |
229 |
|
%span(class=>headline, content=>{%page-headline;}p); |
230 |
|
@Link:toWikiPage:SourceLabelLong:PageList: |
231 |
|
%link-to-it( |
232 |
|
label=>{%page-title(relative);}p, |
233 |
|
description=>{%page-name(absolute);}p, |
234 |
|
); |
235 |
|
%span(class=>headline,content=>{%page-headline;}p); |
236 |
|
@Link:toWikiPage:SourceLabelLong:RecentChangeItem: |
237 |
|
%last-modified; |
238 |
|
%link-to-it( |
239 |
|
label=>{%page-title(relative);}p, |
240 |
|
description=>{%page-name(absolute);}p, |
241 |
|
); |
242 |
|
%span(class=>headline,content=>{%page-headline;}p); |
243 |
|
@Link:toWikiPage:SourceLabelLong:SearchResult: |
244 |
|
{%m--link-weight;} |
245 |
|
%link-to-it( |
246 |
|
label=>{%page-title(relative);}p, |
247 |
|
description=>{%page-name(absolute);}p, |
248 |
|
); |
249 |
|
%span(class=>headline,content=>{%page-headline;}p); |
250 |
@GoToRecentChanges: |
@GoToRecentChanges: |
251 |
@@@: Recent |
@@@: Recent |
252 |
@@lang: en |
@@lang: en |
256 |
@GoToRecentChangesLong: |
@GoToRecentChangesLong: |
257 |
@@@: Review recently modified WikiPages list |
@@@: Review recently modified WikiPages list |
258 |
@@lang: en |
@@lang: en |
|
|
|
|
|
|
|
|
|