Help - Search - Members - Calendar
Full Version: Text filters: How to build?
Movable Type Community Forum > Additional Resources > Plugin Development and Usage
distler
So here's what I want to do.

I have an external C program which reads text on STDIN, processes it, and writes the result on STDOUT.

I would like to use it as a text filter in MT 2.6.

I gather that I am supposed to write some sort of Perl wrapper around it, and stick that in my plugins directory. But I haven't seen any documentation as to what that wrapper should look like.

Could some kind soul post some sample code?
kadyellebee
I don't know exactly if this will help, but there are some links for plugin authors over at the Plugin Directory that might get you started with the MT plugin writing process smile.gif  I haven't seen anything specific on text filter writing.

Kristine
distler
Maybe because MT 2.6 has only been out for a day?

On a related matter, does anyone know if there's an XML-RPC API for setting the Text Filter to be applied to a post? The mt.supportedTextFilters method presumably returns a list of the available filters, but I didn't see anything along the lines of an mt.setPostTextFilter method.

Update: Who cares what I can see? The author of Kung-Log has already implemented Text Filtering via XML-RPC.
Bryant
Check out Brad Choate's Textile plugin -- it's the first text filter plugin and it looks like it's amazingly simple. That is, the method for writing them is simple. Textile is very impressive. smile.gif
bmk
QUOTE
Maybe because MT 2.6 has only been out for a day?

For you.  :)
faf
yeah,bmk,  rub it in   sad.gif
bmk
heheee, I'm just joking around a little!  :)  Plugin developers and beta testers have had the new version already, so that's where kadyellebee was coming from on that.
kadyellebee
(hey, now, wouldn't you rather have moderators who know how to answer new questions than clueless moderators who just got 2.6 at the same time as you?!!!  We've spent a while learning and testing stuff out to try to be sure nothing would break once it got to you!  So no sad.gif only smile.gif )

And there is a second text-formatting plugin that you might want to look at to see how its writen: movable jive

Kristine
faf
i wont turn down a chance to see girlie sweat tho.

UPDATE: btw,  the mt-plugins site doesnt render properly in IE5.0.

I get the general layour of it but the text is placed  off to the top left of where i think it's s'posed to be (ie. center of the page) i'll get you a screen shot soon if you dont have one already.
kadyellebee
Yes, I'd love to see a screenshot.  I'ved tested in all of the major browsers, but only have IE6 here.  I know that N4.8 doesn't render it very nicely, but I'm not so worried about that because its so old.  If I can do something to tweak it for IE5, I will smile.gif

Kristine
faf
http://www.dotfaf.com/temp/mt-screen/

sorry about the large file sizes. I'm at work hence the backwards browser. The comp is a win2000 that doesnt support creating JPEGs.

The browser: IE5.00.3100.
bmk
I know it's not your fault which browser they're making your use smile.gif, but I have IE5.0 on a machine at home... that's what was on there by default with Win2k...  Alls I can say is ewwww!  It makes everything look terrible.  I was able to tweak a little to make it not all mash over to the left, so mine isn't *so* bad now.  But I wasn't happy with it, because I knew it was fine in moz/ns/phoenix/galeon/konquerer/etc. IE5 was the only stinker.  :)  Seems like too many people are stuck with it.  :(
kadyellebee
Wow, thanks for the screenshots.  That's CRAZY how its changing things.  I'll do some checking around to see what could possibly be moving things around so much.  Stupid old browsers!  LOL!
girlie
QUOTE
i wont turn down a chance to see girlie sweat tho.

Har har har...  :p
distler
Cheerful banter aside, I did manage to figure out how to create the text filters I wanted.

Kalsey's filter was moderately helpful in figuring it out (though it would have been much easier were the API documented somewhere).

More tricky (for me) was figuring out how to do bidirectional pipes in Perl.

Anyway, I now have my two filters. With Mozilla, and the proper fonts, you can see them in action:  itex to MathML and itex to MathML with parbreaks.

They're not currently packaged in a drag 'n drop installable fashion (you need to -- at least -- be able to compile and install a C program), but if anyone is interested, I could see about packaging them up for distribution.
kadyellebee
Did the API stuff that I linked in the first reply not help?  I just ask because I'd love to make the "helping plugin authors" section more helpful smile.gif

Kristine
distler
Oh yeah, and the popup RSS feeds in the BlogRoll of mt-plugins.org pop up right (ie, 90% offscreen) for me. That makes them kinda unusable.

In my blog, I made sure they pop up left, which ensures that they are onscreen.

Just a suggestion ...
distler
QUOTE
Did the API stuff that I linked in the first reply not help?  I just ask because I'd love to make the "helping plugin authors" section more helpful.


Well, since they don't document the API for the MT->add_text_filter method, the answer is "not really". Together with Kalsey's plugin, however, they did provide enough clues to figure it out. It just took a little more experimentation than should have been strictly necessary.

Anyway, for what I wanted to do (use a pre-written C program as a filter), that was actually the easy part. Figuring out bi-directional pipes in Perl was more of a challenge (at least for me).
kadyellebee
Yes, I saw you had made this suggestion elsewhere.

Since many visitors of visitors can't see the RSS feeds on the sidebar (due to it being Gecko-based), I figured that it wouldn't be an issue-- there's a "view all" link below them which has the full data, and each feed links to the site the feed is from.  So that's already 2 alternate ways to view it.  I realize that only users with higher than 800x600 browsers are able to see it as intended, but that's most people according to my stats from my other sites.  So basically, I'm targetting the newer browser crowd with that listing as a feature, not something that is necessary to the viewing of the information of the site.

Just my thoughts....
Kristine
distler
QUOTE
...many visitors of visitors can't see the RSS feeds on the sidebar (due to it being Gecko-based)


Not just Gecko, now. They also work in the latest (b60) build of Safari
(and, presumably will soon in other KHTML-based browsers as well).

QUOTE
I realize that only users with higher than 800x600 browsers are able to see it as intended.


My screen resolution is habitually set at 1024x768, and I don't browse in full-screen mode. So your sidebar appears more-or-less flush-right in the browser window (and the popups appear mostly out of the browser window). It just seems odd to me to place them so that they are only visible in full-screen mode. I rarely encounter a site that causes a horizontal scrollbar to appear, let alone forces me to switch to full screen mode to view it.

But the popups are hardly the most important feature of your wonderful new site. So don't feel compelled to fix 'em on my account  :) .
YrAlterEgo
So, yeah, before you read this question do me the favor of entering all the 'I'm an idiot' banter others post about to apply to me:

[Here].

Now that that's settled, can somebody please explain to me how to get the MoveableJive filter to work once I have it installed? What are the kick phrases (on/off) etc..? My brain isn't working and I would love to be able to play with this one.

Thank you for your time.
girlie
When you post an entry, you can select the Jive filter that you want from the Text Formatting box on the Edit Entry screen.
YrAlterEgo
huh.gif

I don't see the option at all. I've looked through the edit options and all to no avail. I'm just not seeing it.  :(
Bryant
Are you using 2.6? It won't work in earlier versions.
YrAlterEgo
Yes, I'm running 2.6. Just upgrading yesterday, I'm also running the MySQL version for the record.
tamaracks
From what I understand, you might have to go into the Customize Display link on your entry screen and make sure that Text Formatting is picked. If you had previously customized it, you won't see the new box by default.
YrAlterEgo
No, the problem is that I'm an idiot. :0

I had replaced my edit_entry.tpml with an older one not thinking about it and it killed the ability convert line breaks in the Text Formatting box. Now I just need to edit the new one the way the old one had been in order to get my link to the dictionary to work again. It's all cool and understood now. Thank for the help folks.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.