[typo] Is there any kind of doc on how to write textfilter plugins?

Rick DeNatale rick.denatale at gmail.com
Wed Mar 25 09:00:52 EDT 2009

2009/3/25 de Villamil Frédéric <frederic at de-villamil.com>

> Le 25 mars 09 à 03:26, Rick DeNatale a écrit :
>  Now that I've got my blog back on the air and up to Typo 5.2, I'm starting
>> to get some ideas.
>> Recently I'd started adding a re-tweet button to each article using
>> tweetmeme.cm.  This is pair of javascript tags which are boilerplate,
>> except for needing the url of the current page inserted.
>> This seems like a perfect opportunity for a textfilter which could turn
>> something like <tweetmeme/> into the javascript tags.
>> I guess I can suss out how to code and install a new plugin, but if
>> there's some doc somewhere it would help.
> OK, I see, there is definitely an international conspiracy organized to
> have me write all the long missing documentation I've been too lazy to write
> during the almost 3 years since I took over the project and show how poor my
> English is just before I release 5.3...
> I've written the typo macro doc, you can find it at
> http://wiki.github.com/fdv/typo/how-to-create-your-own-typo-macro-filters

Bravo Frédéric!
Your English is excellent, certainly better than my French!

So if I want the popup to show the permalink for the content it could just

def self.macrofilter(blog,content,attrib,params,text="")
  %{<script type="text/javascript">alert('#{content.permalink}');</script>}


By the way, playing around with script/console, it looks like the sense of
the only_path argument is reversed:

>> article = Article.find(:first)
=> #<Article id: 2, type: "Article", title: "On Hunting Ducks", author:
"rdenatale", body: "Five doctors go duck hunting, they draw lots to det...",
extended: "Last week, I ran across a thread on the ruby forum ...", excerpt:
"", keywords: "types oop", created_at: "2006-07-26 15:39:07", updated_at:
"2009-03-24 07:05:39", user_id: 1, permalink:
"my-favorite-duck-typing-story", guid:
"be83a184-9f5b-4ab2-97de-de47263fa986", text_filter_id: 5, whiteboard: nil,
name: "", published: true, allow_pings: true, allow_comments: true,
published_at: "2006-07-26 15:39:00", state: "just_published">
>> article.permalink_url
=> "
>> article.permalink_url(nil, false)
=> "/2006/07/26/my-favorite-duck-typing-story"
>> article.permalink_url("foo", false)
=> "/2006/07/26/my-favorite-duck-typing-story#foo"
>> article.permalink_url(nil, true)
=> "

Note that if the second argument is true (which is also the default value,
that the entire url is returned, not just the path, if it's false you get
just the path.

Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/typo-list/attachments/20090325/34ce03a3/attachment-0001.html>

More information about the Typo-list mailing list