I’m using Oddmuse:Indexed Search which also allows me to tag pages using `[[tag:foo]]`. I wanted to show a nice little RSS icon next to those tags to encourage people to subscribe to particular feeds only.
# I want my own tag rule with RSS icons. $SearchFreeTextTagUrl = $ScriptName . '?action=tag;id='; my $RssIconUrl = 'https://alexschroeder.ch/pics/rss.png'; my $RssFeedUrl = 'https://alexschroeder.ch/wiki?action=rss;rcfilteronly=tag:'; $RuleOrder{\&SearchFreeTextTagsRule} = 100; # too lazy to delete it from @MyRules push(@MyRules, \&TagsWithIconsRule); sub TagsWithIconsRule { if (m/\G(\[\[tag:$FreeLinkPattern\]\])/cog or m/\G(\[\[tag:$FreeLinkPattern\|([^]|]+)\]\])/cog) { # [[tag:Free Link]], [[tag:Free Link|alt text]] my ($tag, $text) = ($2, $3); return $q->a({-href=>$SearchFreeTextTagUrl . UrlEncode($tag), -class=>'outside tag', -title=>T('Tag'), -rel=>'tag' }, $text || $tag) . ' ' . $q->a({-href=>$RssFeedUrl . UrlEncode($tag), -class=>'feed'}, $q->img({-src=>$RssIconUrl, -class=>'smiley', -alt=>'RSS'})); } return undef; }
On an ordinary site, you’ll probably have CSS for linked images. I do. That’s why I needed the following:
/* for regular pictures on my pages */ div.content a img, div.journal a img { margin: 1em; padding: 0.5em; border:1px dotted; } /* but not for RSS icons */ div.content a img.smiley, div.journal a img.smiley, img.smiley { margin: 0; padding: 0; border: none; }
#Oddmuse ← Yay baby!! 😄
(Please contact me if you want to remove your comment.)
⁂
Hello Alex!
Very nice, but what provides this `action=tag;id=` ?
Thanks.
– DeDaLu 2009-04-15 23:02 UTC
---
Some code in my config file. 😄
$Action{tag} = \&DoTag; sub DoTag { my $id = shift; if ($IndexHash{$id}) { ReBrowsePage($id); } else { SetParam('search', 'tag:' . $id); DoJournal(); } }
– Alex Schroeder 2009-04-15 23:30 UTC
---
It is amazing how you code complex things into so small snippets! Thanks!
– DeDaLu 2009-04-17 12:33 UTC
---
Thank you. 😄
– Alex Schroeder 2009-04-17 13:48 UTC