[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



On Wed, 2013-04-17 at 14:21 +0800, Paul Wise wrote:
> On Thu, 2012-12-27 at 15:47 +0800, Paul Wise wrote:
> 
> > I implemented linking to individual manual pages on my local machine
> > today, from both the filelist and package pages.
> 
> Attached so that it doesn't get lost.

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

-- 
bye,
pabs

http://wiki.debian.org/PaulWise
From f1203d318ccb3336f513aeb11652bc8aaa25e141 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs@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 | 13 ++++++++++++-
 templates/html/show.tmpl     | 20 ++++++++++++++++++++
 3 files changed, 58 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..9453640 100644
--- a/templates/html/filelist.tmpl
+++ b/templates/html/filelist.tmpl
@@ -9,9 +9,20 @@
  		]
 -%]
 
-[% 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);
+# manpages.d.o doesn't yet support languages in the redirects
+#  ELSIF (matches = file.match('^/usr/share/man/([^\.]+)/man(\d+)/([^\.]+)'));
+#        manurl = 'http://manpages.debian.org/man/' _ uri_escape(suite) _ '/' _ uri_escape(matches.1) _ '/' _ uri_escape(matches.2) _ '/' _ uri_escape(matches.0);
+  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..becf505 100644
--- a/templates/html/show.tmpl
+++ b/templates/html/show.tmpl
@@ -233,6 +233,26 @@
 </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;
+  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.8.5.rc3

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


Reply to: