X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FPod%2FHTML.pm;fp=rt%2Flib%2FRT%2FPod%2FHTML.pm;h=68960632391a12b6d43001f24ce738d35b9facd0;hb=7588a4ac90a9b07c08a3107cd1107d773be1c991;hp=8ddce42d1a98581f2fdf06960d408635e374f024;hpb=98d2b25256055abb0dfcb9f586b434474fa97afd;p=freeside.git diff --git a/rt/lib/RT/Pod/HTML.pm b/rt/lib/RT/Pod/HTML.pm index 8ddce42d1..689606323 100644 --- a/rt/lib/RT/Pod/HTML.pm +++ b/rt/lib/RT/Pod/HTML.pm @@ -1,9 +1,59 @@ +# BEGIN BPS TAGGED BLOCK {{{ +# +# COPYRIGHT: +# +# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +# +# +# (Except where explicitly superseded by other copyright notices) +# +# +# LICENSE: +# +# This work is made available to you under the terms of Version 2 of +# the GNU General Public License. A copy of that license should have +# been provided with this software, but in any event can be snarfed +# from www.gnu.org. +# +# This work 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +# +# +# CONTRIBUTION SUBMISSION POLICY: +# +# (The following paragraph is not intended to limit the rights granted +# to you to modify and distribute this software under the terms of +# the GNU General Public License and is only of importance to you if +# you choose to contribute your changes and enhancements to the +# community by submitting them to Best Practical Solutions, LLC.) +# +# By intentionally submitting any modifications, corrections or +# derivatives to this work, or any other work intended for use with +# Request Tracker, to Best Practical Solutions, LLC, you confirm that +# you are the copyright holder for those contributions and you grant +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +# royalty-free, perpetual, license to use, copy, create derivative +# works based on those contributions, and sublicense and distribute +# those contributions and any derivatives thereof. +# +# END BPS TAGGED BLOCK }}} + use strict; use warnings; package RT::Pod::HTML; use base 'Pod::Simple::XHTML'; +use HTML::Entities qw//; + sub new { my $self = shift->SUPER::new(@_); $self->index(1); @@ -11,6 +61,11 @@ sub new { return $self; } +sub decode_entities { + my $self = shift; + return HTML::Entities::decode_entities($_[0]); +} + sub perldoc_url_prefix { "http://metacpan.org/module/" } sub html_header { '' } @@ -20,8 +75,22 @@ sub html_footer { return '← Back to index'; } -sub start_Verbatim { $_[0]{'scratch'} = "
" }
-sub end_Verbatim   { $_[0]{'scratch'} .= "
"; $_[0]->emit; } +sub start_F { + $_[0]{'scratch_F'} = $_[0]{'scratch'}; + $_[0]{'scratch'} = ""; +} +sub end_F { + my $self = shift; + my $text = $self->{scratch}; + my $file = $self->decode_entities($text); + + if (my $local = $self->resolve_local_link($file)) { + $text = qq[$text]; + } + + $self->{'scratch'} = delete $self->{scratch_F}; + $self->{'scratch'} .= "$text"; +} sub _end_head { my $self = shift; @@ -38,6 +107,17 @@ sub resolve_pod_page_link { return $self->SUPER::resolve_pod_page_link(@_) unless $self->batch_mode and $name; + my $local = $self->resolve_local_link($name, $section); + + return $local + ? $local + : $self->SUPER::resolve_pod_page_link(@_); +} + +sub resolve_local_link { + my $self = shift; + my ($name, $section) = @_; + $section = defined $section ? '#' . $self->idify($section, 1) : ''; @@ -48,18 +128,28 @@ sub resolve_pod_page_link { map { $self->encode_entities($_) } split /::/, $name; } - elsif ($name =~ /^rt-/) { + elsif ($name =~ /^rt[-_]/) { $local = $self->encode_entities($name); } + elsif ($name eq "RT_Config" or $name eq "RT_Config.pm") { + $local = "RT_Config"; + } + # These matches handle links that look like filenames, such as those we + # parse out of F<> tags. + elsif ( $name =~ m{^(?:lib/)(RT/[\w/]+?)\.pm$} + or $name =~ m{^(?:docs/)(.+?)\.pod$}) + { + $local = join "/", + map { $self->encode_entities($_) } + split /\//, $1; + } if ($local) { # Resolve links correctly by going up my $depth = $self->batch_mode_current_level - 1; - return join "/", - ($depth ? ".." x $depth : ()), - "$local.html$section"; + return ($depth ? "../" x $depth : "") . "$local.html$section"; } else { - return $self->SUPER::resolve_pod_page_link(@_) + return; } }