Page 2 of 7

Posted: Wed Dec 12, 2007 10:54 pm
by Don Chambers
Great news!!! I hope you are able to incorporate some of the suggestions made in this thread as well.... I also hope the plugin is able to use different graphics if available.

Posted: Thu Dec 13, 2007 2:16 pm
by garvinhicking
Hi!

Very great news! Guess I can start counting my dollars then! :-)

Regards,
Garvin

Posted: Fri Dec 14, 2007 12:15 am
by gregman
Hi again,

I think, I'm done. You can have a look at the new karma_plugin diamond style at http://www.boerse-aktien-geld.de. It's far from being perfect, but it's works. Changing the images is possible, but related to some work (creating the images, renaming the images (adding the score into the filename!), changing the js and css file). Maybe you wonder about the size of the diamonds. Well I like them big ;-) But don't expect to much! As I'm not into Ajax, the plugin is not as user friendly as the wp one.

Any suggestions welcome!

Greg

Posted: Fri Dec 14, 2007 11:50 am
by garvinhicking
Hi!

I like that! Care to share some code to show us what you modified? Preferrable a unified diff, or the full file(s)?

Regards,
Garvin

Posted: Fri Dec 14, 2007 2:13 pm
by gregman
Hi,

sure, where shall I put it? Finishing the plugin kept me from falling asleep the last view nights. It shouldn't be for nothing. I won't be able to show you every line of code I modified or added, because my discipline in commenting my code is not very well grown. But I can tell you what I did:
  • 1.Changed the vote range to 1 to 5.
    2. Created four different images (grey diamond, yellow diamond, half yellow half grey diamond, green diamond)
    3. Gave each of the 5 diamonds a different id.
    4. Wrote an css file to get the right diamonds in place.
    5. Created a new javscript file in order to get them glowing
    6. Added both files in the frontend header
    7. Changed the calculation of the karma_points to fit the scale (I didn't want to change the database, so I decided to calculate the points in variation of the user votes with a 5 step rounding: 0, 5, 10, 15, ..., 50)
    8. Created static images to display at the frontpage for acceleration reasons
    9. Made lots of other changes to get the plugin working.
Sounds easy, but made me investing much time. So I hope it will be of much use for many people.

Greg

Posted: Fri Dec 14, 2007 2:47 pm
by garvinhicking
Hi!

Sure, as I offered, I'm willing to add in a donation - do you have a paypal account? Then I could donate money so that the plugin can be contribued to serendipity. I think carl will/might drop his dollars in as well, and then you could post the files somewhere on your blog or on http://nopaste.php-q.net so that we can view and add them?

Best regards,
Garvin

Posted: Fri Dec 14, 2007 3:41 pm
by gregman
Hi,

na, you missunderstood me. I will contribute the plugin to s9y being rewarded or not (this is, what makes it open source, right?). On the other hand: "Christmas presents" are always welcome! I don't have a paypal account, but set up an amazon wishlist (see the signature).

best regards
Greg

BTW: I will post a zip file on my blog.

Posted: Fri Dec 14, 2007 3:47 pm
by garvinhicking
Hi!
na, you missunderstood me. I will contribute the plugin to s9y being rewarded or not (this is, what makes it open source, right?). On the other hand: "Christmas presents" are always welcome! I don't have a paypal account, but set up an amazon wishlist (see the signature).
Ah, okay. But it would've been fine if you wanted to be rewarded first. That was, what this thread was about.

Maybe you'd like to setup a paypal account? Your wishlist-items are actually a bit higher than what I can donate right now. :)

Tell us when you'Ve posted the plugin on your blog! :)

Regards,
Garvin

Posted: Fri Dec 14, 2007 4:54 pm
by Don Chambers
Great job. What is the javascript for? The reason I ask is I am wondering if some simple image map, combined with background and foreground images might get the job done, but perhaps not.

Something I see as critical is the ability to use different images, which also means different sized images, without the need to need to modify the plugin or js. But perhaps suggestions would be better made after everyone has had an opportunity to review the actual code.

One other thing - the "popular entries" plugin can work in conjunction with the karma plugin. Have you tested these 2 together to see what, if any, impact your calculation has on the popular entries?

Again - great job!!

Posted: Fri Dec 14, 2007 4:58 pm
by gregman
Hi,

I posted the zip file (serendipity-event_karma_ds.zip) on my blog http://www.boerse-aktien-geld.de. I also created a payppal account (paypal (at) boerse-aktien-geld (dot) de).

Best regards
Greg

Posted: Fri Dec 14, 2007 5:08 pm
by gregman
Don Chambers wrote:Great job. What is the javascript for?
Thanks for the compliment. Actually the karma plugin already contained javascript (in the plugin itself, not in an external file) and I thought it would be better for future improvements (e.g. ajax).

Sorry, I had no time to test the plugin substantially. But it propably might work, as I didn't change the database...

Greg

Posted: Fri Dec 14, 2007 11:50 pm
by gregman
UPDATE:

I did some minor changes. Especially the loading time of the green diamond when "hovering" the diamonds for the fist time was a thorn in my side. Therefore the green diamond is loaded in in the background of an empty div container when loading the entry site. Sorry for this hack, but I didn't find a pure css solution for the interactivity even after hours of searching. Further I experienced some difficulties with IE 5.x. The voting action of the karma plugin (the text based one too) wasn't working. So I changed the javascript href code into pure html href. But as I can't imagine why Garvin preferred the javascript solution, this might to be revoked.

Greg

Posted: Sat Dec 15, 2007 12:36 am
by Don Chambers
I have not reviewed it yet, but I promise to do so within the next day. The good news is that a lot of people were interested in this plugin, so you should be able to get a lot of quality feedback quickly (subject to everyone's availability, of course!).

Just like I mentioned before though - a key issue from my perspective is to be able to replace the images as mindlessly as possible... which includes the size of the images I don't like big! :lol: :lol: Maybe bulletproof has a couple of concepts that could be utilized here. First, we have the ability to detect any filename that ends in a certain naming convention. We use this to "see" available colorset stylesheets so a user can select one. Perhaps there is a concept there you can take advantage to allow users to select images with a particular naming convention that happen to be available in the plugin folder.

Something else we do is to switch the default xml icon, which is usually orange, with a colorset-specific version. This is as simple as hiding the foreground image and applying our desired background image.

Not sure if any of this can work for you, but thought I would mention it.

Posted: Sat Dec 15, 2007 12:57 am
by garvinhicking
Hi!

I just had a very minor, quick review. Some notes:

1. Try to use "(int)$serendipity['GET']['id']" when you use it like in the frontend_header place, else you might be subject to SQL injection

2. Use propper array access: Instead of $diamond[0][points] you need to use $diamond[0]['points'] (quotes around non-numerical array indices are else first interpreted as constants, which costs performance and looks strange)

3. Try to concatenate echo strings like "echo $var1 . $var2 . $var3" instead of "echo $var1, $var2, $var3" to keep the coding style consistent with other s9y code. Also, proper indenting (4 spaces, no tabes) is a nice thing to have ;). Also use { and } even if they're optional, and use breaks after that (especially in files like diamondstyle.*.php)

4. Instead of emitting your own stylesheet through diamondstyle.css.php you could use the existing "css" event hook in the plugin api to inject the things you need to have. The less additional HTTP calls, the better.

5. In your diamondstyle.js.php use htmlspecialchars() around $_SERVER['PHP_SELF'] as well, else you'Re subject to XSS attacks.

6. You can simplify your javascript a lot, to someting like this:

Code: Select all

function glow(rating) {
  for (i = 1; i <= rating; i++) {
document.getElementById('serendipity_karmaVoting_link' + rating).style.backgroundImage = 'url(<?php echo dirname($_SERVER['PHP_SELF']) ; ?>/img/<?php echo $glow_image; ?>)';    
  }
}
Then you could emit that javascript inline in the karma plugin, also removing another external PHP file that would need calling. :)

7. Instead of creating a new plugin for using the image-style voting, you could add a plugin option to choose between the old s9y method and your new one?


As I wrote above - those are minor details. I like the general direction and I believe it could greatly enhance this plugin!

Regards,
Garvin

Posted: Fri Dec 21, 2007 4:10 pm
by gregman
Hi,

many thanks for your suggestions.

1. - 3. done
4. Can you tell me, how to get the entryid in the css event hook? $serendipity['GET']['id'] seems not to be set in there.
5. done
6. Sorry, I tried to lessen the code, but it did not work, i.e. it didn't show the same glowing effect. To me putting the script-code into the karma_plugin is not very search engine friendly, but surely will work.
7. Due to the different calculation of the points that won't make much sense ;-)

Regards
Greg