[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 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.

> Based on my preliminary implementation, I think we do need a way to do a
> search by package names.
> ...
> We need per-package links. The packages site also requires a way to link
> to the manual page of a specific language and fall back on the English
> version. So something like this:
> 
> http://manpages.debian.net/pkg/<suite>/<package>/<lang>/
> http://manpages.debian.net/pkg/<suite>/<package>/
> 
> If there is only one manual page in the package, that should present it.
> If there are several manual pages in the package, it should list them.

Did you get a chance to implement this yet?

In addition, would it be possible to get all of the redirects to include
an optional language parameter on the end? This way the contents pages
can also link to manual page translations.

-- 
bye,
pabs

http://wiki.debian.org/PaulWise
From dd8f7d4c8613e2324ea1ac037f9d00b9935f1db2 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 422ca7a..9f19280 100644
--- a/lib/Packages/DoShow.pm
+++ b/lib/Packages/DoShow.pm
@@ -238,6 +238,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,
@@ -520,6 +526,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..205edc0 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.net/man/' _ uri_escape(suite) _ '/' _ uri_escape(matches.0) _ '/' _ uri_escape(matches.1);
+# manpages.d.n doesn't yet support languages in the redirects
+#  ELSIF (matches = file.match('^/usr/share/man/([^\.]+)/man(\d+)/([^\.]+)'));
+#        manurl = 'http://manpages.debian.net/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 8b4a6e2..8f0eb10 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.net/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.2.1

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


Reply to: