This is a script that looks through your file system for "index.html" files and outputs them in a format that the firefox web browser can import as a bookmark file, giving you access to some of the web based documentation installed with the packages that make up your linux distro (so it should be relevant to what's installed on your machine).
You just copy it, paste it into your favorite text editor, save the file as "something.sh" and make it executable.
From a terminal:
Code:
chmod 740 something.sh
./something.sh
It should create a file in your home directory, internal_bookmarks.html, that you can import into firefox as a bookmark folder named "Internal Documentation".
A couple of notes:
TESTING: It's only been tested on Slackware 64 multi-lib current, though it should have no problem running on any system that has a bash shell. If you test it and it works, do me a favor and post your distro and that it works. If it doesn't work, post your distro and the error message and we'll see if we can get it to work.
Web Pages:It only pulls index.html pages. If you want all html pages go to the function Grinder and change "index.html" to "*.html" in the script but friend... that's liable to be a lot of pages.
Bookmark Names: It pulls the name of the individual bookmarks from the html of the page, specifically. "<title> What the guy titled it</title>" produces a bookmark named "what the guy titled it".
Icons: I'm a Slackware zombie, we don't do icons.
Improvements: If anybody can think of any, I'd greatly appreciate it.
Code:
#!/bin/bash
# As always, this script is free to a good home, comes with no
# warranties, whatsoever. If it turns you into a newt...well, perhaps
# you'll get better.
# a script for indexing localhost index.html files and converting the index
# into a firefox importable bookmarks html file called internal_bookmarks.html in the user home
# directory. Firefox imports it as it's own folder named "internal documentation"
#
# date in the bookmarking world is the number of seconds since the epoch (midnight, 1970)
TICK=$(date +%s)
STICK="$HOME/internal_bookmarks.html"
# formatting the boilerplate
function Top_Plate(){
echo '<!DOCTYPE NETSCAPE-Bookmark-file-1>'> $STICK
echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">'>> $STICK
echo '<TITLE>Bookmarks</TITLE>'>> $STICK
echo '<H1>Bookmarks Menu</H1>'>> $STICK
echo '<DL><p>'>> $STICK
echo '<DT><H3 ADD_DATE='$TICK' LAST_MODIFIED='$TICK' >Internal Documentation</H3>' >> $STICK
echo '<DL><p>'>> $STICK
}
# closing off the DL tags
function Bottom_Plate() {
CTR=$(grep -c '<DL>' $STICK)
while [ $CTR -gt 0 ];do
echo '</DL><p>' >> $STICK
CTR=$[$CTR-1]
done
}
# Creating the bookmarks, creates a tmp file called "bookmarks.tmp" and then delete it.
# If you want ALL html files bookmarked, change index.html in the first line
# to *.html
function Grinder(){
find / -iname index.html 2>/dev/null 1> bookmarks.tmp
while read bookmark; do
TITLE=$(grep -i -o -P '(?<=<title>).*(?=</title>)' $bookmark )
echo "<DT><A HREF=file://"$bookmark" ADD_DATE= "$TICK" ICON= > "$TITLE" </A>">> $STICK
done <bookmarks.tmp
rm bookmarks.tmp
}
Top_Plate
Grinder
Bottom_Plate
exit 0
Final note: The bookmarks are dependent on the rights of the user. I've suppressed the error output but believe me, when you run this thing straight from the command line you'll get a lot of "permission denied" errors (unless you're root and if you are..tsk, tsk) so run it for each user on your system as that user or it will create bookmarks the user doesn't have rights to access.
Enjoy.