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
From 50f9f03737859545d7fdfba5cfe16edc8c2a10f8 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 | 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
Attachment:
signature.asc
Description: This is a digitally signed message part