Bug#264589: Link from packages.debian.org to manpages.debian.net - updated information (bug 264589)

Paul Wise <[email protected]>
Newsgroups gmane.linux.debian.devel.www
Organization Debian
Message-ID <1483340014.24855.64.camel__15601.0598796003$1483340253$gmane$org@debian.org>
On Tue, 2014-03-04 at 12:08 +0800, Paul Wise wrote:

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

Attached an update to git master and https URLs.

-- 
bye,
pabs

https://wiki.debian.org/PaulWise
0001-Link-to-manual-pages-Closes-264589.patch (text/x-patch, 3.9 KB)
From 50f9f03737859545d7fdfba5cfe16edc8c2a10f8 Mon Sep 17 00:00:00 2001
From: Paul Wise <[email protected]>
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 e0f05ff..12a40da 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..b7c9f5a 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 = 'https://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 = 'https://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 31cfce8..37616dc 100644
--- a/templates/html/show.tmpl
+++ b/templates/html/show.tmpl
@@ -235,6 +235,30 @@
 </div> <!-- pdesctab -->
 [% END %]
 
+[%- manfirst = 1 -%]
+[% FOREACH content IN contents;
+  manurl = '';
+  mansection = '';
+  manname = '';
+  IF (matches = content.match('^/usr/share/man/man(\d+)/([^\.]+)'));
+        manurl = 'https://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 = 'https://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>
-- 
2.11.0
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEYQsotVz8/kXqG1Y7MRa6Xp/6aaMFAlhp+O4ACgkQMRa6Xp/6
aaOZMBAAuFNnbArt7pBGnWinPT0WDJiHuicKNHYGPdQhcqoNsbxIOKKiDSFeydkB
4JsWHa4T+MFCTQUhKt9tx0CQMh5kGfvvKcIS0Vv9qlBtm/LxN27gqHYJ2WLjQYhW
zjhXD/VDWIO0Q5bjo4ii8/rDid9sq533rq2L2UUcdESfUmMEdc8xMBqvvJt49VXX
jIUm70ZaMTI/dpyBKG/Bxtx9pi6M/gsufxl77Gv5xVjIDQWcTfLi+llnqxupSsJP
HL29r4hIP1l84OEIVD4rLsRhlROQus3VECkTl2EOBgdoDohOhYGgIaqT0hKRLC7a
V976ov+C0ethh0mJm4xhRF/ElmL2Mp1rGNygVkouLjgi3hZsNfs7l9+fRfqvOoA+
zmKZhIFpVw+JlsGE9VnPfeFF0OsM+aYlHwOFF3X1PyyUxQPRSmKAOxNqBUXxatOY
REY5nkpEdEPFleEa1ZXqwTV45LWT1W0TrpXfI4Hj/eX323DlBJfJDqEBInkKGRB/
Xh3h4h2WwlkpF1jAiaQuPIOXXiojxYUtNzalkJPZoKnl7T1wsKtyJPFtejPURWCL
vlfYmoGujH3VQHHUHJyOwW+x7HG/x4IFzAVaFxaFjNuiQJ3yhBI4kXTE9QCuYohq
u15FQ3vIIusLgkvaJrjVo3nBG+3LWbfZiaPoAhmeCH/ltCfWSsE=
=7ymg
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.