Monday, November 08, 2010 at 12:01 AM.
system.verbs.apps.Netscape.examples.buildCoolSitesTable
local (startHref = "<a href=\"", endHref = "</a><br>");
<<how to use this script
<<use NetScape 1.0N
<<visit the Cool Sites of the Day, Previous Cool Sites page, at:
<<http://www.infi.net/oldcool.html
<<choose the Source... command from the View menu
<<save the file that's opened in your text editor
<<run this script, choose the same file
<<a bunch of cool sites will show up in this table
local (source);
bundle { <<read the source text from the file
local (f);
if not file.getFileDialog ("Choose a file containing HTML source:", @f, 0) {
return};
file.open (f);
source = file.read (f, infinity);
file.close (f)};
local (s, url, ixendtitle);
on popnextline () {
local (s = string.nthField (source, cr, 1));
source = string.delete (source, 1, sizeof (s) + 1);
return (s)};
while sizeof (source) > 0 {
s = popnextline ();
if s beginsWith startHref {
<<process lines in the following form:
<<<a href="http://www.mediabridge.com/nyc/xmas/">Christmas in New York</a><br>
s = string.delete (s, 1, 9);
url = string.mid (s, 1, string.patternMatch ("\"", s) - 1);
s = string.delete (s, 1, sizeof (url) + 2);
ixendtitle = string.patternMatch (endHref, s);
if ixendtitle > 0 { <<it's there, not split between two lines
title = string.mid (s, 1, sizeof (s) - sizeof (endHref))}
else {
title = s + " " + popnextline () - endHref};
msg (title);
netscape.examples.coolsites.[title] = url}}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.