Page 6 of 7

Posted: Thu Jan 17, 2008 3:11 pm
by garvinhicking
Hi!

I, too, can't sadly follow this whole thread because of very little time (work + s9y-book related).

However, I also love what you guys are up to. It will hugely increase the fun with entry voting.

Since it was me that introduced this legacy code: Feel free to drop it. IMHO an ordered list (even IMHO better than an unordered list) is semantecially much better than a simple div.

It might make styling a bit harder though, because margins/paddings are not so easily stackable than within a div if you want that to work cross-browser, as I remember.

Regards,
Garvin

Posted: Thu Jan 17, 2008 4:23 pm
by Don Chambers
carl_galloway wrote:2. I'd love to see a sidebar list of most popular entries, but not the current karma ranking which lists the author and their popularity, I'd prefer a list similar to the recent entries list but showing the top x number of popular entries.
Carl - there is a popular entries plugin that does exactly that.... and the method used to determine what is popular is selectable. It can be based on comment count, karma total and a few other things. Actually, that plugin desperately needs to be updated after this. I don't want to sidetrack this thread, but what would be sweet is the ability to factor in a few different things to determine what is popular.... the rating, hit count, # comments, etc, all factored in, possibly with some kind of weight scale the user could configure. I would also like to see the plugin have the ability to show most popular by month, year, and possibly all time. But, first lets get this one cleaned up!!! :wink:

Posted: Fri Jan 18, 2008 12:38 am
by judebert
Great job, everybody! I think we've got a mostly-complete graphical extension for our karma plugin. All that's left is to simplify that old legacy code, and maybe a little bit of formatting.

I'm finally making progress on the categorytemplate priority thing. I expect to have that done tomorrow; after that, I'll be happy to pick up gregman's latest mods and clean out the legacy cruft. We'll talk about the sidebar plugin some other time.

Are there any outstanding bugs I should be paying attention to while I'm at it? Anything that we know needs close attention?

Posted: Fri Jan 18, 2008 5:56 pm
by Don Chambers
Jude - thanks for taking on the task of cleaning up the legacy code. You have a lot of experience doing that with s9y plugins, so I'm sure this will be right up your alley!! I don't envy you though!!! :o)

Posted: Fri Jan 18, 2008 7:04 pm
by judebert
There's a lot of spaghetti and redirection. Nevertheless, I think I'm making pretty good progress. I should have something soon.

Posted: Fri Jan 18, 2008 7:16 pm
by carl_galloway
Hey Jude, that's great news, this particular feature has been asked for so many times in the past so I'm really pleased to see this plugin getting so much attention right now. I downloaded the latest version on Gregman's site and I'm really impressed that it works well in IE6 as well, and getting rid of that legacy code is a major step forward - sorry garv
:D

Posted: Fri Jan 18, 2008 7:50 pm
by garvinhicking
Hi!
judebert wrote:There's a lot of spaghetti and redirection. Nevertheless, I think I'm making pretty good progress. I should have something soon.
Do you mean that javascript redirection? That was added to prevent bots like Google etc. to "hit" a voting.

Regards,
Garvin

Posted: Tue Jan 22, 2008 8:48 pm
by judebert
No, although I'll keep that in mind as I sweep through it. I'm thinking "redirection" in the way that a variable will be assigned a value, which isn't used, but instead added to a string, which is then used in an sprintf(); you can't figure out what the output will be unless you redirect your attention repeatedly to different lines.

Several variables seem to go through multiple transformations before they're finally used. I'm going to try to simplify that, so you can easily tell where a variable is assigned its final value and what's going to be output.

Posted: Wed Jan 23, 2008 11:06 am
by garvinhicking
Hi Judebert!

Ah, okay. I see. I generally use this when I want to keep string modifications as performance-low as possible. But deal with this as you see fit. :)

Regards,
Garvin

Posted: Thu Jan 24, 2008 3:30 pm
by judebert
I recently got a question about my progress, and figured I should let everyone know what I'm up to.

I got sidetracked by the categorytemplates plugin. I'm back to working on the karma plugin now.

My first step was some code formatting and documentation. Then I uploaded it to my site for a test. The existing karma bar disappeared.

This is the same problem I had with the categorytemplates plugin: upgrading wasn't fully tested. I'm dealing with that, then I'll move on to the rest of the cleanup.

Posted: Thu Jan 24, 2008 3:40 pm
by Don Chambers
No apologies necessary for delays caused by working on the category templates plugin!!!

Voting plugin status

Posted: Mon Jan 28, 2008 9:33 pm
by judebert
My status as of right now:

I've simplified a lot of the code. (It no longer generates the HTML for every possibility, but only for the one that it's actually going to use). I've bypassed a lot of the sprintf() calls, which I've determined to be a PHP performance hog.

I'm working on getting a graphical preview for all the available rating bars in the plugin configuration. (You have to use the "css_backend" hook for the admin page, not the "css" hook. I feel like an idiot for allowing that to take up so much of my time.)

Once I've got that, I'm going to do some more cleanup, then add a config item for a minimum number of votes before the rating is displayed (and possibly something similar for visits).

Then I think I'll be done. Any comments?

Re: Voting plugin status

Posted: Tue Jan 29, 2008 10:07 am
by garvinhicking
Hi!
I've simplified a lot of the code. (It no longer generates the HTML for every possibility, but only for the one that it's actually going to use). I've bypassed a lot of the sprintf() calls, which I've determined to be a PHP performance hog.
IMHO "performance hog" is really relative. You usually don't have millions of sprintf() calls on a page, where this would really take impact.

IMHO the worth of better readability and clarity of sprintf, when many variable placements are involved, is worth the slight drawback.

But since you planned on improving the plugins code readability, I'm sure you found a good solution to this :)

Best regards,
Garvin

Re: Voting plugin status

Posted: Wed Jan 30, 2008 4:48 pm
by judebert
garvinhicking wrote: IMHO the worth of better readability and clarity of sprintf, when many variable placements are involved, is worth the slight drawback.

But since you planned on improving the plugins code readability, I'm sure you found a good solution to this :)
Boy, I sure hope so. The original code made a huge format string, often including pieces from other sprintf() calls. Then it used an sprintf() with 6 parameters -- which we expanded to 11 to include all the link descriptions!

At this point, I'm leaving the sprintf() calls that are already in language files, so we don't have to retranslate them. But I'm axing the giant sprintf() and replacing it with something more understandable.

The original code also generated all the possible HTML (including sprintf() calls) and then printed only the one it needed. That's been optimized to only create the HTML when it's required.

I'm currently doing my real, paying job; but when I get any free moments, I go back to the karma plugin. I've got it displaying a preview of the available rating bars on its config page, which I'm hashing out with Don. I've also got it using graphics on an upgrade without changing the configuration.

The big problem at the moment is the alignment. The plugin defaults to flush-right; it was easy enough for templates to change that just by styling the text-align. But text-align doesn't apply to the tags we have to use for a graphical rating bar.

I'm going to program something that checks the stylesheet and styles the graphics accordingly. That should create a result that matches the template's intention 90% of the time. I'll probably add an override in the plugin configuration, too, so anybody who gets a default result he doesn't like can just go configure the plugin.

Don and I are also having a usability discussion that we'll likely bring into the forums, too. It's about the text used to indicate the current karma. If we keep the current textual rating, it tells the total karma points. That's pretty confusing if you just voted "5 stars" and the total only goes up by 2. But if we change the rating system to show an average, then an article voted "worst" five times gets 5 total points, and an article voted "good" once only gets four points. The "popular entries" plugin would have to be changed to understand that. No good solution yet, so we're skipping the display (Greg's solution) and working on other stuff for now.

SO: progress. Slow but steady. Big things in the works. Development version on display at my website.

Posted: Thu Jan 31, 2008 8:35 pm
by judebert
I'm getting closer! I've just run into my first difficult problem!

The voting doesn't work well with permalinks.

If you're voting from the extended article of a permalinked page, you get returned to the front page. If the article is still on the front page, its voting bar is placed at the top. Your vote still gets recorded.

I was expecting to be returned to the permalinked page, with the voting bar at the top.

I think the problem is the URL of the voting link. It's created by appending "&serendipity[karmaVote]=X&serendipity[karmaID]=Y#karmaVoteY" to the original URL. The karmaVote and karmaID are still used, and the #karmaVoteY moves you to the voting bar.

Unfortunately, on a permalink page, the url looks like this:
yourblog/index.php?/permalink/Permalink.html&serendipity[karma...

While the relevant RewriteRules, at the very bottom of the .htaccess, are:
RewriteRule ^index\.(html?|php.+) index.php [R=permanent,L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]

I'm not certain, but I think the first one of that three is picking up the URL. We are pointing to index.php.+, so we're getting redirected to index.php, right? (My address bar still points to the full URL, and all the voting links are still pointing to the full URL, too.)

When I do this from a non-permalinked article, it works as expected.

In the code, I get the URL with serendipity_currentURL(). Is there a better way to get the URL of the current page, for my purposes?