New Plugin Advice

Creating and modifying plugins.
Post Reply
bahwi
Regular
Posts: 9
Joined: Wed Aug 11, 2004 10:55 pm

New Plugin Advice

Post by bahwi »

I've been working on a plugin that displays the data from an XML file for my "What I'm Listening To" section of my site at http://ynko.com/. Unfortunately, a lot of stuff is hard coded. It uses the plugin from http://brandon.fuller.name/archives/hacks/nowplaying/ with iTunes. That plugin generates an amazon image link most of the time. What I have is a hardcoded section that overrides that to catch most of the ones without images or the ones I want a different image for. What is the best way to incorporate this into a plugin configuration instead of hardcoding it in?

I saw the shoutbox creates and maintains it's own table. Is this the best way to go? Or are there any API hooks that does the same thing? (Or would it be best to add API hooks that would do the same thing?). Thanks. I'd like to publish this plugin and hopefully convert it to work with the XMMS Now Playing plugin as well. It's far from done (When iTunes is off it just shows two dashes).

Thanks,
--Joey
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: New Plugin Advice

Post by garvinhicking »

Hi!

Sounds like an interesting plugin! However I don'T have a real clue about what hardcoded stuff you exactly mean. Maybe you could post snippets of your plugin and tell us which things you want to get configurized, then we/I could help you :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bahwi
Regular
Posts: 9
Joined: Wed Aug 11, 2004 10:55 pm

Post by bahwi »

No problem. The XML file coming in will only sometimes have an image location(it automatically generates Amazon links to the image of the album cover). However, when it does not, I prefer to override it and display another image.

Here are some snippets of what is hardcoded:

$translate = array (
'Wig in a Box: Songs from & Inspired By Hedwig and the Angry Inch' =>
$imgroot . "WigInABox.jpg");

if (empty($imageurl) AND !empty($album)) {
$imageurl = $translate[$album];
}

if (empty($imageurl)) {
if (strstr($artist, "Judy Garland")) {
$imageurl = $imgroot . "JudyGarland.jpg";
} else
if (strstr($artist, "Missy Elliot")) {
$imageurl = $imgroot . "MissyElliot.jpg";
} else
if (strstr($artist, "Carol Channing")) {
$imageurl = $imgroot . "CarolChanning.jpg";
} else
if (strstr($artist, "Cher")) {
$imageurl = $imgroot . "Cher.jpg";
}
}

As you can see it is performing two checks, if $imageurl is blank it tries to determine another image to display compared to the album, if it is blank after that, then it does it again based on the artist. I cut these back, I have about 20 different albums in $translate array. Ideally a user would be able to add as many as they need, either albums or artists.

I was thinking doing a database table as with the shoutbox plugin, but I wasn't sure if that was the best or not and what the best way to do it would be.

Thanks for any help!
bahwi
Regular
Posts: 9
Joined: Wed Aug 11, 2004 10:55 pm

Postgresql Problems

Post by bahwi »

Most of the postgresql problems were not honoring the prefix (I went with s9y_ instead of serendipity_ ) and not updating the database properly. I will try a fresh install when I get a chance and post the errors to the Bugs forum. I am also having a problem now about it not recording the category whenever I make a new post, and it also does the trackbacks a second time when I edit a post(edit will save category, so I post, then edit, but this generates two trackbacks). Maybe a trackback cache or something so it doesn't do it twice? I'd be more than happy to help.

Thanks,
--Joey
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Postgresql Problems

Post by garvinhicking »

Hi!

That's strange you're having problems with prefix. All our .sql files contain a {PREFIX} variable, so that can't be the case. Maybe you changed your prefix in the config-file, but not in the database? So s9y kept a different prefix in reality?

About the trackbacks, those are not sent twice, they are already cached in the serendipity_references table. Which version are you using? It should only trackback links that were not in the entry before.

About your hardcoded plugin stuff: That really is something which should not be hardcoded. Either you go with a config table, or maybe easier, a config file which contains all the mappings. For the final distribution of your plugin you can provide a small sample file, and you for yourself can maintain your current config.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bahwi
Regular
Posts: 9
Joined: Wed Aug 11, 2004 10:55 pm

Post by bahwi »

Yeah, I know it shouldn't be hardcoded. I just wanted advice on the best way to do it. =)

Hmm, is there a way to do a more advanced configuration area than the propbag currently allows? I know it handles pretty much everything currently, but is there a list type of thing?

--

When I get a chance I will install the latest CVS and let you know what problems with Postgresql I see, and will try to fix it myself and commit patches. I am still learning postgres myself though so it may not be the best.

The trackbacks are cached? Was this recently submitted to CVS or maybe there is a problem with the postgresql. I'll take a look and see if I can figure it out! Thanks. Glad to hear it's already done. =)

--Joey
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
Hmm, is there a way to do a more advanced configuration area than the propbag currently allows? I know it handles pretty much everything currently, but is there a list type of thing?
Yes, there are lists and many more types: http://www.s9y.org/43.html#A8

And thanks about your postgresql offer, we gladly take it! And the trackback caching should work ever since 0.4 or so...so you are probably right about a postgre issue! Even though I heard of people having no problems with it...maybe you still have trouble with a wrong {prefix}?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply