Page 1 of 1

New Plugin Advice

Posted: Wed Aug 11, 2004 11:06 pm
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

Re: New Plugin Advice

Posted: Thu Aug 12, 2004 10:00 am
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

Posted: Fri Aug 20, 2004 7:43 am
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!

Postgresql Problems

Posted: Fri Aug 20, 2004 7:45 am
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

Re: Postgresql Problems

Posted: Fri Aug 20, 2004 9:38 am
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

Posted: Fri Aug 20, 2004 4:57 pm
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

Posted: Fri Aug 20, 2004 5:13 pm
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