diff --git a/ManUtils/ManUtils.pm b/ManUtils/ManUtils.pm index 88280a4..5750b9d 100644 --- a/ManUtils/ManUtils.pm +++ b/ManUtils/ManUtils.pm @@ -15,6 +15,11 @@ sub fmt($input) { # $MANWIDTH works by using the following groff options: -rLL=100n -rLT=100n push @cmd, qw/-mandoc -Tutf8 -DUTF-8 -P-c -rLL=80n -rLT=80n -/; + # tix comes with* a custom(?) man.macros package. But it looks okay even without loading that. + # (* It actually doesn't, the tcllib package appears to have that file, but doesn't '.so' it) + # Other .so's are just turned into a link. + $input =~ s/^\.so (.+)$/$1 eq 'man.macros' ? '' : ".in -10\n.sp\n[[[MANNEDINCLUDE$1]]]"/emg; + $input = # Disable hyphenation, since that screws up man page references. :-( ".hy 0\n.de hy\n..\n" diff --git a/www/index.pl b/www/index.pl index cbb9244..f37f1a0 100755 --- a/www/index.pl +++ b/www/index.pl @@ -706,27 +706,6 @@ sub man_nav_($man, $url, $toc, $htmllang) { } -# Replace .so's in man source with the contents (if available in the same -# package) or with a reference to the other man page. -sub soelim($verid, $src) { - # tix comes with* a custom(?) macro package. But it looks okay even without loading that. - # (* It actually doesn't, the tcllib package appears to have that file, but doesn't '.so' it) - $src =~ s/^\.so man.macros$//mg; - - # Other .so's should be handled by html() - $src =~ s{^\.so (.+)$}{ - my $path = $1; - my $name = (reverse split /\//, $path)[0]; - my($man) = $verid ? man_pref_name $name, SQL 'v.id =', $verid : (); - $man->{name} - # Recursive soelim, but the second call gets $verid=0 so we don't keep checking the database - ? soelim(0, fu->SQL('SELECT content FROM contents WHERE id =', $man->{content})->val) - : ".in -10\n.sp\n\[\[\[MANNEDINCLUDE$path\]\]\]" - }emg; - $src; -} - - sub man_page($man, $url) { fu->set_lastmod($man->{released}); @@ -739,7 +718,17 @@ sub man_page($man, $url) { fu->done; } - my $fmt = ManUtils::html ManUtils::fmt soelim $man->{verid}, $content; + # Find out of this is a redirect-type man page, i.e. one containing only a single .so and no other content. + my $follow; + if (length($content) < 2048 && (() = $content =~ /^\.so/mg) == 1) { + my $data = $content =~ s/^\.\\".*//rmg; + if ($data =~ m{^\s*\.so (?:[^\s]*/)?([^\s/]+)\s*$}s) { + ($follow) = man_pref_name $1, SQL 'v.id =', $man->{verid}; + $content = fu->SQL('SELECT content FROM contents WHERE id =', $follow->{content})->val if $follow; + } + } + + my $fmt = ManUtils::html ManUtils::fmt $content; if($url->{fmt} eq 'txt') { # TODO: The 'txt' format is kind of broken right now as it includes our HTML formatting codes. # This feature is a WIP and not advertised at the moment, anyway. @@ -752,7 +741,6 @@ sub man_page($man, $url) { # Prefix links to other man pages with the current system, to ensure we # grab the most relevant man page. - # XXX: This is a hack, prefixing is better done directly in ManUtils. my $sys = sysbyid->{$man->{system}}{short}; $fmt =~ s{ "/loc/$hash", 'locations' }; } }; + em_ sub { + txt_ 'Displaying the included man page: '; + a_ href => $url->set( + man => $follow->{name}, section => $follow->{section}, + system => sysbyid->{$man->{system}}{short}, shorthash => shorthash_to_hex $follow->{shorthash} + ), "$follow->{name}($follow->{section})"; + } if $follow; pre_ @htmllang, sub { lit_ $fmt }; }; } diff --git a/www/man.css b/www/man.css index 9310e69..15d6d96 100644 --- a/www/man.css +++ b/www/man.css @@ -51,9 +51,9 @@ main.thin { max-width: 700px; margin: 0 auto } .pkgpage section:last-child { padding: 0 10px } #manbuttons h1 { display: inline; margin: 0 20px 0 0; vertical-align: middle } -#manbuttons ul { list-style-type: none; display: inline-block } +#manbuttons ul { list-style-type: none; display: inline-block; margin: 0 0 0 15px } #manbuttons li { display: inline-block } -#manbuttons li a { display: inline-block; outline: none; margin: 0 10px 0 0; padding: 5px 7px 8px 7px; text-decoration: none; border-top-left-radius: 7px 5px; border-top-left-radius: 7px 5px } +#manbuttons li a { display: inline-block; outline: none; margin: 0 10px 0 0; padding: 5px 7px 8px 7px; text-decoration: none } #manbuttons li a:hover { background: #f0f8ff } .manpage nav { background: #f0f8ff; color: #036; float: right; padding: 8px; width: 250px; margin-bottom: 10px; border-radius: 8px; }