Categories
Software and Programming

Type to Search

For some reason, text search dialog boxes (“Find in this page”) in browsers have gotten slower and slower. It takes them ages to show up, and you get this not only in Mozilla (which uses skinnable XUL(eXtensible User interface Language)), but also in Internet Explorer (where the Find box isn’t the usual Windows one, but some weird localized, HTML-ish creature).

Anyway, I’ve noticed that in Mozilla, when I click Ctrl-F and then start typing, it starts searching for the text I’m typing in the links on the page, before the “Find” box had a chance to show up.

This feature, called incremental search, is something cool Mozilla programmers have borrowed from Emacs (it also shows up in Microsoft’s Visual Studio). So I wondered, would it be possible to make it do an incremental search of all the text in the page, not just the links?

Well, sure. Here’s the preference to set (in Mozilla 1.3):

moznav.jpg

Categories
Resources short

The Great War

“1914-1918: The British Army in the Great War”:http://www.1914-1918.net/ and “The Austro-Hungarian army”:http://www.austro-hungarian-army.co.uk/

Categories
Software and Programming

The Busy XML hack

I wanted to list the news feeds I subscribe to in Syndirella to my reading page (still under construction). The program can export this list to me as an OPML file.

OPML is a simple (if inconsistent) XML format, so I tried to use a Perl module called XML::Simple to parse it. For some reason it didn’t work, so I messed around with it and then decided to simply write a script that parses the OPML file with regular expressions:


#an opml subscriptions parser.
while(<>) {
m/title\="([^"]+)"/i and my $title = $1;
m/htmlurl\="([^"]+)"/i and my $html = $1;
m/xmlurl\="([^"]+)"/i and my $rss = $1;
if ($html ne "" && $rss ne "" && $title ne "") {
	print qq{ <p><a href="$html">$title</a> 
                      [ <a href="$rss">RSS</a> ] </p>\n };
	}
}

Then I figured out what the problem with the original script was (I was handing it the script itself as input, instead of the OPML file. Doh!). So I wrote the proper XML-parser using program:


use strict;
use warnings;
use XML::Simple;

my $subfile = shift;
my $subs = XMLin($subfile);
for my $item (@{$subs->{'body'}->{'outline'}})
{
	my $html = $item->{'htmlUrl'}; 
	my $rss = $item->{'xmlUrl'}; 
	my $title = $item->{'title'}; 
	print qq{ <p><a href="$html">$title</a> 
                     [ <a href="$rss">RSS</a> ] </p>\n };
}


Not only is the regular expression based program simpler, it also works with OPML files that use different case for the attributes (htmlurl instead of htmlUrl – I told you it was inconsistent).

When I say “simpler”, above, I mean to write. The second program certainly looks clearer, especially if you’re used to the syntax of more rigorous languages. The quick regular expression hack looks a bit messier than usual because of the escapes in the regular expression (the backslashes before the quotes) and because it uses Perl’s backwards condition syntax (putting the if after the statement saves putting the statement in a { … } block).

Added spaces before the square brackets to stop them from breaking my RSS feed.

Categories
BlogTalk

òáøéú ÷ùä

îâðéá, îöàúé àéê àôùø ìäôåú àú äëéååï ùì ëì úéáú è÷ñè

îòðééï àéê *æä* ééöà.

I think I need a filter (an MT text formatter>?) to fix up Hebrew paragraphs. Raw HTML (or textile) are quite inadequate.

And I probably need a seperate blog, just for Hebrew.

Which raises the question of how to implement Suzie’s site, which needs 3 languages…

Categories
Blather

Valid use of my time

Slow day at work. Should I finish translating that story for the Tenth Dimension, send out some more job applications, read up on the formats the rice genome data was published in, fiddle with the design for the Tenth Dimension web site (coming soon!) or work on my games for Bigor?

The answer, of course, is that I did none of the above. Instead I fiddled with my web pages, to make them valid XHTML.

Valid XHTML 1.0!

If this makes no sense to you, you’re really better off.

Oh, I also did some more website maintenance, changing the whole site over to the new look the weblog had.