On Tue, Jul 03, 2007 at 03:19:14PM -0700, Kevin O'Gorman wrote
> 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.

  Here's mine.  It uses strictly bash; no perl at all.  The setup...
  - following files sit in the ~/.docpointer/  directory
    - docpointer (executable script)
    - docpointer.css
    - header
    - footer

  - from a console execute...
    ~/.docpointer/docpointer n
    where "n" is an integer specifying the number of columns across you
    want in the output.  You *MUST* specify a number.  I use between 1
    and 3, depending on my mood.  It only takes a couple of seconds on
    an old 450 mhz PIII

  - I point browser to file:///home/waltdnes/.docpointer/docpointer.html
    and get a list of html docs.  The pathname will obviously be
    different om your system

  The files are attached...

-- 
Walter Dnes <[EMAIL PROTECTED]> In linux /sbin/init is Job #1
Q. Mr. Ghandi, what do you think of Microsoft security?
A. I think it would be a good idea.
#!/bin/bash

makelinktext() {

# Search for matches
find ${1} -iname ${2} > workfile.000

# Generate text for link and append it and the match to workfile.001
while read
do
# Strip the prefix off the filespec
  xoffset=$(( ${#1} + 1 ))
  commenttext=${REPLY:${xoffset}}

# If the stripped filespec contains the string "/html/", get rid of that
  commenttext=`echo ${commenttext} | sed "s/\/html\//\//g"`

# Get rid of the string "/HTML/" too
  commenttext=`echo ${commenttext} | sed "s/\/HTML\//\//g"`

# Get rid of the string "/doc/" too
  commenttext=`echo ${commenttext} | sed "s/\/doc\//\//g"`

# Get rid of the string "/DOC/" too
  commenttext=`echo ${commenttext} | sed "s/\/DOC\//\//g"`

# Get rid of the string "/doc/" too
  commenttext=`echo ${commenttext} | sed "s/\/docs\//\//g"`

# Get rid of the string "/doc/" too
  commenttext=`echo ${commenttext} | sed "s/\/DOCS\//\//g"`

# Strip the suffix off the filespec
  xlength=$(( ${#commenttext} - ${#2} - 1 ))
  commenttext=${commenttext:0:${xlength}}

# Send the stripped filespec, along with the original, to workfile.001
  echo ${commenttext} ${REPLY} >> workfile.001
done < workfile.000

}

# Get parameter which specifies how many columns across
columncount=${1}

# Change to ~/.docpointer directory
cd ~/.docpointer

# Get rid of workfile.001 if it exists.
if [[ -a workfile.001 ]]; then
  rm workfile.001
fi

# Get raw search results
makelinktext "/usr/share/doc" "index.html"
makelinktext "/usr/share/doc" "index.htm"
# Repeat the above lines for any additional searches you want to throw in.

# Generate a sorted workfile
sort -u workfile.001 > workfile.002

# Create the beginning of the docpointer.html file
cp header docpointer.html

# Put creation date into the link page
date >> docpointer.html

# Open the table
echo '<table class="t1" cellspacing="4">' >> docpointer.html

# Initialize column pointer
columnpointer=0

# Read each line in workfile.002 and generate a link
while read commenttext urltext
do

# Increment column pointer
  columnpointer=$(( ${columnpointer} + 1 ))

# If this is the first cell of a row, open the row first
  if [[ ${columnpointer} -eq 1 ]]; then
    echo '<tr>' >> docpointer.html
    rowstatus="open"
  fi

# Do the cell
  echo "<td><a href=\"${urltext}\">" "${commenttext}" '</a></td>' >> 
docpointer.html

# If this is the  last cell of a row, close the row, and reset the
# column pointer to zero
  if [[ ${columnpointer} -eq ${columncount} ]]; then
    echo '</tr>' >> docpointer.html
    rowstatus="closed"
    columnpointer=0
  fi

done < workfile.002

# If the last row hasn't been closed, close it now
if [[ "${rowstatus}" = "open" ]]; then
  echo '</tr>' >> docpointer.html
fi

# Close the table
echo '</table>' >> docpointer.html

# Append the footer to docpointer.html
cat footer >> docpointer.html
div.nav_menu {
  color:             #000000;
  background-color:  #b4dade;
  font-weight:       bold;
  font-family:       monospace;
  top:               1px;
  left:              1px;
  border-style:      groove;
  padding:           0;
}

td.tab_cell {
  background-color:  #b4dade;
  background-image:  url(tabimage.gif);
  background-repeat: no-repeat;
  font-family:       "Courier New","Courier",monospace;
}

pre.listing {
  font-size:         larger;
}

.bluelight {
  color:             #000000;
  background-color:  #c0d0ff;
}

.highlight {
  color:             #000000;
  background-color:  #b4ffb4;
  font-weight:       bold;
  text-align:        left;
  border-style:      none;
}

table.t1 {
  border-style:      ridge;
  border-color:      #0000c0;
  border-spacing:    9px;
  border-width:      8px;
  color:             #000000;
  background-color:  #f0f0f0;
}

table.t1 td {
  border-style:      solid;
  border-color:      #0000c0;
  border-width:      1px;
  color:             #000000;
  background-color:  #f0f0f0;
}
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" >
<head>
<link rel="stylesheet" href="docpointer.css" type="text/css" />
<title>The docpointer linkpage to html documentation on your system</title>
</head>
<body>
<div class="nav_menu">
This page created 
</div>
</body>
</html>

Reply via email to