.)
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+/c;
my ($subtitle) = $Page{text} =~ m/(?:^|\n)\#SUBTITLE[ \t]+(.*?)\s*\n+/c;
my ($interlink, $suburl) = $Page{text} =~ m/(?:^|\n)\#SUBURL(:)?[ \t]+(.*?)\s*\n+/c;
return ($title, $subtitle, $suburl, $interlink ? 1 : '');
}
=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, $smart_interlink) = GetSmartTitles();
}
$smart_title ||= $title;
$smart_subtitle ||= $subtitle;
$smart_title = QuoteHtml($smart_title);
$smart_subtitle = QuoteHtml($smart_subtitle);
$html_header =~ s~\Q>$title\E~>$smart_title~g;
if ($smart_subtitle) {
my $subtitlehtml = '' . $smart_subtitle;
if ($smart_suburl) {
$subtitlehtml .= $smart_interlink ? GetInterLink($smart_suburl, undef, 1, 1)
: GetUrl($smart_suburl, $SmartTitlesSubUrlText, 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 Alex-Daniel Jakimenko
Copyleft 2008 by B.w.Curry .
Copyright 2006 by Charles Mauch .
This file 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 2
of the License, or (at your option) any later version.
This file 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 file; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=cut