On Sat, 2013-11-30 at 10:00 +0800, Paul Wise wrote:

> Attached an update for using manpages.d.o instead.

Attached an update to support the new per-language redirects on
manpages.d.o and the filesystem paths for translated manpages.

-- 
bye,
pabs

http://wiki.debian.org/PaulWise
From 0703ed27a4a02dcd978cce0e3e6e43a70fbffe63 Mon Sep 17 00:00:00 2001
From: Paul Wise <p...@debian.org>
Date: Thu, 27 Dec 2012 15:48:15 +0800
Subject: [PATCH] Link to manual pages (Closes: #264589)

---
 lib/Packages/DoShow.pm       | 26 ++++++++++++++++++++++++++
 templates/html/filelist.tmpl | 12 +++++++++++-
 templates/html/show.tmpl     | 24 ++++++++++++++++++++++++
 3 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm
index 915e05d..0b65c48 100644
--- a/lib/Packages/DoShow.pm
+++ b/lib/Packages/DoShow.pm
@@ -241,6 +241,12 @@ sub do_show {
 			$contents{downloads} = \@downloads;
 
 			#
+			# File contents on amd64
+			#
+			$contents{contents} = [];
+			pkg_files('amd64', $suite, $pkg, $contents{contents});
+
+			#
 			# more information
 			#
 			moreinfo( name => $pkg, data => $page, vars => \%contents,
@@ -526,6 +532,26 @@ sub pkg_list {
     }
 }
 
+sub pkg_files {
+    my ( $arch, $suite, $pkg, $list ) = @_;
+        if (tie my %contents_data, 'DB_File', "$DBDIR/contents/filelists_${suite}_${arch}.db",
+            O_RDONLY, 0666, $DB_BTREE) {
+
+            unless (exists $contents_data{$pkg}) {
+		return ;
+            } else {
+                my @files = unpack "L/(CC/a)", $contents_data{$pkg};
+                my $file = '';
+
+                for (my $i=0; $i<scalar @files;) {
+                    $file = substr($file, 0, $files[$i++]).$files[$i++];
+                    push @$list, "/$file";
+                }
+            }
+        } else {
+		return ;
+        }
+}
 
 1;
 
diff --git a/templates/html/filelist.tmpl b/templates/html/filelist.tmpl
index 515502e..d534a1b 100644
--- a/templates/html/filelist.tmpl
+++ b/templates/html/filelist.tmpl
@@ -9,9 +9,19 @@
  		]
 -%]
 
-[% FOREACH file IN files %]
+[% FOREACH file IN files;
+  manurl = '';
+  IF (matches = file.match('^/usr/share/man/man(\d+)/([^\.]+)'));
+        manurl = 'http://manpages.debian.org/man/' _ uri_escape(suite) _ '/' _ uri_escape(matches.0) _ '/' _ uri_escape(matches.1);
+  ELSIF (matches = file.match('^/usr/share/man/([^\.]+)/man(\d+)/([^\.]+)'));
+        manurl = 'http://manpages.debian.org/man/' _ uri_escape(suite) _ '/' _ uri_escape(matches.0) _ '/' _ uri_escape(matches.1) _ '/' _ uri_escape(matches.2);
+  END -%]
 [%- '<div id="pfilelist"><pre>' IF loop.first -%]
+[%- IF manurl -%]
+<a href="[% manurl %]">[% file %]</a>
+[% ELSE -%]
 [% file %]
+[% END -%]
 [% '</pre></div>' IF loop.last -%]
 [% END %]
 
diff --git a/templates/html/show.tmpl b/templates/html/show.tmpl
index 59a3deb..c604704 100644
--- a/templates/html/show.tmpl
+++ b/templates/html/show.tmpl
@@ -233,6 +233,30 @@
 </div> <!-- pdesctab -->
 [% END %]
 
+[%- manfirst = 1 -%]
+[% FOREACH content IN contents;
+  manurl = '';
+  mansection = '';
+  manname = '';
+  IF (matches = content.match('^/usr/share/man/man(\d+)/([^\.]+)'));
+        manurl = 'http://manpages.debian.org/man/' _ uri_escape(suite) _ '/' _ uri_escape(matches.0) _ '/' _ uri_escape(matches.1);
+        mansection = matches.0;
+        manname = matches.1;
+  ELSIF (matches = file.match('^/usr/share/man/([^\.]+)/man(\d+)/([^\.]+)'));
+        manurl = 'http://manpages.debian.org/man/' _ uri_escape(suite) _ '/' _ uri_escape(matches.0) _ '/' _ uri_escape(matches.1) _ '/' _ uri_escape(matches.2);
+        mansection = matches.1;
+        manname = matches.2;
+  END -%]
+	[%- IF manurl -%]
+	[%- IF manfirst -%]
+	[%- manfirst = 0 -%]
+	<h2>[% g('Documentation:') %]</h2>
+	[%- END -%]
+	[% g('<a href="%s" title="%s manual page">%s</a>', manurl, manname, manname _ '(' _ mansection _ ')' ) %]
+	[%- END -%]
+[%- END -%]
+
+
 [% FOREACH b IN binaries %]
   [% IF loop.first %]<div id="pbinaries">[% g('The following binary packages are built from this source package:') %]<dl>[% END %]
     <dt>[% IF b.available %]<a href="[% make_url(b.name,'','source','') %]">[% b.name %]</a>[% ELSE; b.name; END %]</dt>
-- 
1.9.0

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to