home

OddMuse

Notes and bookmarks.

CSS/HTML

Page structure and CSS classes:

Links

Open links in new window

This adds a new rule which will produce links with the evil target="_new" attribute. It understands

[new:URL]

and

[new:URL text]

The links will have the class newwindow (like outside for normal off-site links).

push(@MyRules, \&newWindowLink);
sub newWindowLink
{

    # compare sub LinkRules in oddmuse.pl
    if ($BracketText && m/\G(\[new:$FullUrlPattern\s+([^\]]+?)\])/cog
	or m/\G(\[new:$FullUrlPattern\])/cog)
    {
	my ($url, $text) = ($2, $3);
	$url =~ /^($UrlProtocols)/;
	my $class = "url $1";      # get protocol (http, ftp, ...)
	$text = $url unless $text; # use url as link text if text empty
	$url = UnquoteHtml($url);  # quote special chars
	$class .= ' newwindow';    # add newwindow to class
	# output link
	my $link = $q->a({-href=>$url, -class=>$class, -target=>"_new"}, $text);
	#Clean($link); # ?!
	#return '';
	return $link;
    }
    return undef;
}

Div rule

Á la http://www.oddmuse.org/cgi-bin/wiki/div_foo. Allows div and span tags with class and style attributes.

push(@MyRules, \&divRule);
sub divRule
{
    if (m/\G\<((?:div|span)(?:\s+(?:class|style)="[^\"]+")+)\>/cgi
	or m!\G\<(/(?:div|span))\>!cgi)
    {
	return CloseHtmlEnvironments() . '<' . UrlDecode($1) . '>';
    }
    return undef;
}

Note: This might produce invalid HTML for span tags. Alex (the Oddmuse wizard) suggests a different treatment for span tags here.

Comments in page source code

push(@MyRules, \&commentRule);
$RuleOrder{\&commentRule} = -100;
sub commentRule
{
    if (m/\G^(%.*)$/cmog)
    {
	#return '<!-- ' . UnquoteHtml($1) . ' -->';
    	return '';
    }
    return undef;
}

TODO

(merge with links above.. some day..)

Visitors to this page so far.