]> git.uio.no Git - usit-rt.git/blobdiff - lib/RT/Pod/HTML.pm
Upgrade to 4.2.8
[usit-rt.git] / lib / RT / Pod / HTML.pm
index 68960632391a12b6d43001f24ce738d35b9facd0..c44a50f036112d6fb0dd09019dd8a1306ba53026 100644 (file)
@@ -2,7 +2,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
 #                                          <sales@bestpractical.com>
 #
 # (Except where explicitly superseded by other copyright notices)
@@ -54,6 +54,10 @@ use base 'Pod::Simple::XHTML';
 
 use HTML::Entities qw//;
 
+__PACKAGE__->_accessorize(
+    "batch"
+);
+
 sub new {
     my $self = shift->SUPER::new(@_);
     $self->index(1);
@@ -118,27 +122,41 @@ sub resolve_local_link {
     my $self = shift;
     my ($name, $section) = @_;
 
+    $name .= ""; # stringify name, it may be an object
+
     $section = defined $section
         ? '#' . $self->idify($section, 1)
         : '';
 
     my $local;
-    if ($name =~ /^RT::/) {
+    if ($name =~ /^RT(::(?!Extension::|Authen::)|$)/ or $self->batch->found($name)) {
         $local = join "/",
                   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";
+    elsif ($name =~ /^(\w+)_Config(\.pm)?$/) {
+        $name  = "$1_Config";
+        $local = "$1_Config";
+    }
+    elsif ($name eq 'README') {
+        # We process README separately in devel/tools/rt-static-docs
+        $local = $name;
+    }
+    elsif ($name =~ /^UPGRADING.*/) {
+        # If an UPGRADING file is referred to anywhere else (such as
+        # templates.pod) we won't have seen UPGRADING yet and will treat
+        # it as a non-local file.
+        $local = $name;
     }
     # 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$})
     {
+        $name  = join "::", split '/', $1;
         $local = join "/",
                   map { $self->encode_entities($_) }
                 split /\//, $1;
@@ -146,11 +164,20 @@ sub resolve_local_link {
 
     if ($local) {
         # Resolve links correctly by going up
-        my $depth = $self->batch_mode_current_level - 1;
-        return ($depth ? "../" x $depth : "") . "$local.html$section";
+        my $found = $self->batch->found($name);
+        my $depth = $self->batch_mode_current_level
+                  + ($found ? -1 : 1);
+        return ($depth ? "../" x $depth : "") . ($found ? "" : "rt/latest/") . "$local.html$section";
     } else {
         return;
     }
 }
 
+sub batch_mode_page_object_init {
+    my ($self, $batch, $module, $infile, $outfile, $depth) = @_;
+    $self->SUPER::batch_mode_page_object_init(@_[1..$#_]);
+    $self->batch( $batch );
+    return $self;
+}
+
 1;