Wiki pages don't auto link themselves
This commit is contained in:
parent
705631f860
commit
1a4b77b435
3 changed files with 17 additions and 3 deletions
|
|
@ -6,10 +6,14 @@
|
|||
- fix: purge old asset revisions could purge the most recent revision if the
|
||||
database had some referential integrity probems
|
||||
- Wiki autolinks prefer longest title match
|
||||
http://www.webgui.org/bugs/tracker/wiki-automatic-link-creator-not-greedy-enough
|
||||
- Wiki pages no longer autolink themselves
|
||||
http://www.webgui.org/bugs/tracker/wrong-an-unnecessary-links-in-wiki
|
||||
- fix: Recover Password by Profile Field can now work with subclasses of
|
||||
WebGUI::Auth::WebGUI and with custom WebGUI::Form::Controls as profile
|
||||
fields.
|
||||
|
||||
|
||||
7.4.0
|
||||
- api: Form Controls and Workflow Activities may now include web based helper
|
||||
subroutines directly in their files. See
|
||||
|
|
|
|||
|
|
@ -343,7 +343,10 @@ sub view {
|
|||
historyUrl => $self->getUrl("func=getHistory"),
|
||||
editContent => $self->getEditForm,
|
||||
allowsAttachments => $self->getWiki->get("allowAttachments"),
|
||||
content => $self->getWiki->autolinkHtml($self->scrubContent),
|
||||
content => $self->getWiki->autolinkHtml(
|
||||
$self->scrubContent,
|
||||
{skipTitles => [$self->get('title')]},
|
||||
),
|
||||
};
|
||||
return $self->processTemplate($var, $self->getWiki->get("pageTemplateId"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,14 +90,22 @@ sub appendSearchBoxVars {
|
|||
sub autolinkHtml {
|
||||
my $self = shift;
|
||||
my $html = shift;
|
||||
# TODO: ignore caching for now, but maybe do it later.
|
||||
# opts is always the last parameter, and a hash ref
|
||||
my %opts = ref $_[-1] eq 'HASH' ? %{pop @_} : ();
|
||||
my $skipTitles = $opts{skipTitles} || [];
|
||||
# TODO: ignore caching for now, but maybe do it later.
|
||||
my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage'", [$self->getId]);
|
||||
return $html unless %mapping;
|
||||
foreach my $key (keys %mapping) {
|
||||
if (grep {lc $_ eq $key} @$skipTitles) {
|
||||
delete $mapping{$key};
|
||||
next;
|
||||
}
|
||||
$key =~ s{\(}{\\\(}gxms; # escape parens
|
||||
$key =~ s{\)}{\\\)}gxms; # escape parens
|
||||
$mapping{$key} = $self->session->url->gateway($mapping{$key});
|
||||
}
|
||||
# sort by length so it prefers matching longer titles
|
||||
my $matchString = join('|', map{quotemeta} sort {length($b) <=> length($a)} keys %mapping);
|
||||
my $regexp = qr/($matchString)/i;
|
||||
my @acc = ();
|
||||
|
|
@ -121,7 +129,6 @@ sub autolinkHtml {
|
|||
$p->handler(default => sub { push @acc, $_[0] }, 'text');
|
||||
$p->parse($html);
|
||||
$p->eof;
|
||||
undef $p; # Just in case there might be reference loops.
|
||||
return join '', @acc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue