Overriding <title> html tag

143 views
Skip to first unread message

Dave Hansen

unread,
Feb 3, 2009, 2:55:18 PM2/3/09
to album...@googlegroups.com
My little brother uses album for the '/' page of his web site. He
doesn't like how it shows up in Google since its title is "Album: www".
I wrote him a little plugin which seems to work, although in a very
hackish way.

I just stick and extra <title> tag in the HTML before the regular
album-generated one, which I'm sure isn't exactly standards compliant.
The browser seems to only show the first one that it encounters.

Any thoughts on a more elegant way to do this? What about just adding a
hook to header() that does:

my $title = $tAlbum $this;

$title = do_hooks($opt, $data, 'html_title', $dir, $album);

print ALBUM <<END_OF_HEADER;
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>
$title
</title>
...

---

# My hackish plugin
sub start_plugin {
my ($opt) = @_;

album::hook($opt,'write_index',\&add_title);
#album::hook($opt,'do_album_top',\&add_title);
return {
author => 'David Hansen',
href => 'http://www.sr71.net/',
version => '1.0',
description => "add a new title.",
};
}

sub add_title {
my $opt = shift;
my $data = shift;
my $hook_name = shift;
my $pic = shift;

return undef if ($pic ne '/home/mike/www');
my $js =<<END;
<title>Mike Hansen's photo album</title>
END
print STDERR $data->{head};
$data->{head} .= $js;
return undef;
}

1;

-- Dave

album author - David Ljung Madison

unread,
Feb 3, 2009, 3:43:50 PM2/3/09
to album-users
> What about just adding a hook to header() that does:
> my $title = $tAlbum $this;
> $title = do_hooks($opt, $data, 'html_title', $dir, $album);

This is a good idea, though the Themes unfortunately have the
title hardcoded to be "Album:" and the path.

I can update all of the simmer_theme Themes pretty easily
to use some possibly hook specified title if people thought
that would be a good idea.

Also - the hook should probably be given at least:

1) The translation of "Album:"
2) The path to the current album (possibly caption'ed)

Is there anything else that the plugin might need
to know to create a good album name?

Reply all
Reply to author
Forward
0 new messages