public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Kevin O'Gorman" <kogorman@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: [gentoo-user] Index to /usr/share/doc/...html... a reinvented wheel?
Date: Tue, 3 Jul 2007 15:19:14 -0700	[thread overview]
Message-ID: <9acccfe50707031519w73abc638qb001cc5e9bb64d88@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 700 bytes --]

I emerge with the doc USE flag and generally have a bunch of stuff in
/usr/share/doc.  Most of the time it's the HTML stuff I want to read, but
it's a annoyingly laborious to wade through unindexed directgories and get a
browser pointing to the right thing.  So I wrote a little Perl script to
create a top-level "index.html", organized by package and with a bit of
rudimentary pruning.  I bookmarked it in Firefox, and can get to things a
lot faster now.  I like the result, and will continue to tweak it here and
there.

Did I just reinvent a wheel? If not, is there any point it trying to make
this part of gentoo?  If so, how would one do that?

Current script attached.

-- 
Kevin O'Gorman, PhD

[-- Attachment #1.2: Type: text/html, Size: 786 bytes --]

[-- Attachment #2: makeindex.perl --]
[-- Type: application/octet-stream, Size: 2470 bytes --]

#!/usr/bin/perl -w
# Create an index of all index files.  Do not index sub-indexes.

$DEBUG = 0;
$needeol = "";

chdir "/usr/share/doc" or die "Cannot cd to /usr/share/doc: $!";

open FIND, "find . -name index.html |sort|" or die "Cannot fork: $!";

print "<head><title>Index of /usr/share/doc index files</title>\n";
print "<style type=\"text/css\">\n";
print "    li, p { margin-top: 0in; margin-bottom: 0in; }\n";
print "</style>\n";
print "</head>\n";
print "<body>\n";
$date = scalar localtime;
print "<h1>External docs:</h1>\n";
print "<ul>\n";
    print "<li><p>Gentoo web resource: <a \n";
    print "      href=\"http://www.gentoo.org/doc/en/index.xml\">Gentoo\n";
    print "      Documentation Project</a></p></li>\n";
print "</ul>\n";
print "\n";
print "<h1>Index of /usr/share/doc index files, generated $date</h1>\n";

while (<FIND>) {
    chomp;
    $file = $_;
    s:^\./::;
    $name = $_;
    ($basename = $name) =~ s:^\./::;
    print "$needeol   File: \"$file\"  Basename: $basename\n" if $DEBUG;
    $needeol = "";
    ($path = $basename) =~ s|/index\.html$||;
    $files{$basename} = 1;
    open NAME, "<$name" or warn "Cannot open $name";
    while (<NAME>) {
	chomp;
	if ($_ eq "./index.html") {next;}
	if (m/href=\"[^"]+\/(index.html)?\"/i) {
	    print "$needeol    From line \"$_\"\n" if $DEBUG;
	    $needeol = "";
	    while (m/href=\"([^"]+\/(index.html)?)\"/i) {
		$ref = $1;
		s/href=\"[^"]+\/(index.html)?\"//i;
		if ($ref =~ m|^https?://|) {
		    if ($DEBUG > 9) {
			print "         Ditching absolute reference $ref\n"
		    }
		    next;
		}
		if ($ref =~ m:^\.\./:) { # dot dot slash
		    print "         Ditching up-reference $ref\n" if $DEBUG > 9;
		    next;
		}
		if ($ref =~ m:/\.\./:) { # slash dot dot slash
		    print "         Ditching up-reference $ref\n" if $DEBUG > 9;
		    next;
		}
		($hyper = $ref) =~ s:^\./::;  # strip "here" from ref
		print "      blocking: $path/$hyper\n" if $DEBUG;
		$links{"$path/$hyper"} = 1;
    }
	} elsif ($DEBUG) {
	    print ".";
	    $needeol = "\n";
	}
    }
}
close FIND;

print "<ul>\n";
    if ($DEBUG) {
	for $i (sort keys %links) {
	    print("Exclude Link $i\n");
	}
    }
    $p1 = "";
    for $i (sort keys %files) {
	($p2 = $i) =~ s:/.*::;
	if ($p2 ne $p1) {
	    if ($p1) { print "\n"; }
	    print "   <li><p>$p2: ";
	    $p1 = $p2;
	}
	if (! defined $links{$i}) {
	    print " &nbsp; <a href=\"$i\">$i</a>";
	}
    }
    print "\n";
print "</ul>\n";
print "</body>\n";

             reply	other threads:[~2007-07-03 22:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-03 22:19 Kevin O'Gorman [this message]
2007-07-04  3:19 ` [gentoo-user] Index to /usr/share/doc/...html... a reinvented wheel? Naga
2007-07-04 14:59   ` Kevin O'Gorman
2007-07-04 15:15     ` Galevsky
2007-07-04  6:22 ` Kent Fredric
2007-07-04 14:28 ` David Relson
2007-07-04 16:27   ` Kevin O'Gorman
2007-07-04 20:26     ` David Relson
2007-07-04 16:39   ` Willie Wong
2007-07-04 17:26     ` Jerry McBride
2007-07-21 15:50       ` Kevin O'Gorman
2007-07-05  1:40 ` Walter Dnes
2007-07-06 23:31 ` Paul Gibbons
2007-07-07 13:59   ` Dan Farrell
2007-07-07 15:30   ` Kevin O'Gorman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9acccfe50707031519w73abc638qb001cc5e9bb64d88@mail.gmail.com \
    --to=kogorman@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox