.)
This function is provided as a separate subroutine so as to permit other
extensions (namely, hibernal) to obtain the title and subtitle for pages.
=cut
sub GetSmartTitles {
my ($title) = $Page{text} =~ m/ (?:^|\n) \#TITLE [ \t]+ (.*?) \s*\n+ /x;
my ($subtitle) = $Page{text} =~ m/ (?:^|\n) \#SUBTITLE [ \t]+ (.*?) \s*\n+ /x;
my ($suburl) = $Page{text} =~ m/ (?:^|\n) \#SUBURL [ \t]+ (.*?) \s*\n+ /x;
return ($title, $subtitle, $suburl);
}
=head2 GetHeaderSmartTitles
Changes the passed page's HTML header to reflect any "#TITLE" or "#SUBTITLE"
within that passed page's Wiki content.
=cut
sub GetHeaderSmartTitles {
my ($page_name, $title, undef, undef, undef, undef, $subtitle) = @_;
my ($smart_title, $smart_subtitle, $smart_suburl);
my $html_header = GetHeaderSmartTitlesOld(@_);
if ($page_name) {
OpenPage($page_name);
$title = NormalToFree($title);
($smart_title, $smart_subtitle, $smart_suburl) = GetSmartTitles();
}
$smart_title ||= $title;
$smart_subtitle ||= $subtitle;
$smart_title = QuoteHtml($smart_title);
$smart_subtitle = QuoteHtml($smart_subtitle);
$smart_suburl = QuoteHtml($smart_suburl);
$html_header =~ s~\Q>$title\E~>$smart_title~g;
if ($smart_subtitle) {
my $subtitlehtml = '' . $smart_subtitle;
if ($smart_suburl) {
# ApplyRules is too much, we just want links. LinkRules should be enough.
# $subtitlehtml .= ' ' . ToString(sub { ApplyRules($smart_suburl, 1, 1) }) if $smart_suburl;
$_ = $smart_suburl;
$subtitlehtml .= ' ' . ToString(sub {LinkRules(1)});
}
$html_header =~ s~\Q\E~$subtitlehtml
~;
}
my $smart_header;
if ($SiteName eq $smart_title) { # show "MySite: subtitle" instead of "MySite: MySite (subtitle)"
$smart_header = $smart_subtitle
? sprintf($SmartTitlesBrowserTitleWithoutSubtitle, $SiteName, $smart_subtitle)
: $SiteName;
} else {
$smart_header = $smart_subtitle
? sprintf($SmartTitlesBrowserTitle, $SiteName, $smart_title, $smart_subtitle)
: sprintf($SmartTitlesBrowserTitleWithoutSubtitle, $SiteName, $smart_title);
}
$html_header =~ s~\.*?\<\/title\>~$smart_header~;
return $html_header;
}
=head1 COPYRIGHT AND LICENSE
The information below applies to everything in this distribution,
except where noted.
Copyright 2014-2015 Alex-Daniel Jakimenko
Copyleft 2008 by B.w.Curry .
Copyright 2006 by Charles Mauch .
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
=cut