The Serendipity Handbook

You can now read the (german) handbook here: PDF - https://github.com/s9y/Book (LaTeX source).

Forum-Information

Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Plugins I need a voting plugin, will pay

Creating and modifying plugins.
User avatar
judebert
Regular
 
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL

Postby judebert » Thu Jan 31, 2008 9:35 pm

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?
Judebert
---
Website | Wishlist | PayPal

User avatar
garvinhicking
Core Developer
 
Posts: 28954
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Thu Jan 31, 2008 9:42 pm

Hi!

But when I vote

http://judebert.com/wasted_youth/index. ... erendipity[karmaVote]=2&serendipity[karmaId]=204#karma_vote204

I *do* get back to the extended article page?

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/

User avatar
judebert
Regular
 
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL

Postby judebert » Thu Jan 31, 2008 10:08 pm

Yes, but that's expected, because it's not permalinked. It's in archives/.

Try this page instead:
http://judebert.com/wasted_youth/permalink/CSS-star-rating.html
Judebert
---
Website | Wishlist | PayPal

User avatar
garvinhicking
Core Developer
 
Posts: 28954
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Fri Feb 01, 2008 1:44 am

Hi!

Ah, you meant "Custom Permalinks" using the plugin.

Are you already using the version I updated yesterday? Actually I believe the fix I applied will also fix your problem.

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/

User avatar
judebert
Regular
 
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL

Postby judebert » Fri Feb 01, 2008 6:15 pm

Excellent, I'll give that a shot.

I expect to finish this soon; possibly before the weekend.
Judebert
---
Website | Wishlist | PayPal

User avatar
judebert
Regular
 
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL

Postby judebert » Mon Feb 11, 2008 5:49 am

One week later...

It's done! I checked it in this evening. There is a nice explanation of the improved Karma Plugin on my website.
Judebert
---
Website | Wishlist | PayPal

User avatar
Don Chambers
Regular
 
Posts: 3077
Joined: Mon Feb 13, 2006 3:40 am
Location: Chicago, IL, USA

Postby Don Chambers » Fri Feb 15, 2008 7:13 am

And for more images, be sure to see this forum entry: http://board.s9y.org/viewtopic.php?t=12300

gregman
Regular
 
Posts: 92
Joined: Wed Aug 15, 2007 9:32 pm

Postby gregman » Fri Feb 15, 2008 10:44 am

AWESOME, GUYS!

I just installed the new plugin and I am speechless!

Just some few suggestions:

Code: Select all
        @define('PLUGIN_KARMA_IMAGE_NONE_RATING', 'keine');
        @define('PLUGIN_KARMA_TAB_OPTIONS', 'Optionen');
        @define('PLUGIN_KARMA_TAB_APPEARANCE', 'Aussehen');
        @define('PLUGIN_KARMA_TAB_TEXT', 'Text');

was missing in the german language files.

Further I experienced some problems with word rating switched on. The word-rating doesn't match to a negative given vote. This probably is caused by the integer converting (e.g. integer of -2 + 0.5 = - 1!). Therefore I removed this line and switched the following code to
Code: Select all
            if ($rating < -1.5) {
                $rating = PLUGIN_KARMA_VOTEPOINT_1;
            } elseif ($rating < -0.5) {
                $rating = PLUGIN_KARMA_VOTEPOINT_2;
            } elseif ($rating < 0.5) {
                $rating = PLUGIN_KARMA_VOTEPOINT_3;
            } elseif ($rating < 1.5) {
                $rating = PLUGIN_KARMA_VOTEPOINT_4;
            } else {
                $rating = PLUGIN_KARMA_VOTEPOINT_5;
            }


Greg

User avatar
judebert
Regular
 
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL

Postby judebert » Fri Feb 15, 2008 8:05 pm

Ah, good idea. (I guess I never had any entries rated below "Okay". :)) No need to truncate to an integer. Why didn't I think of that?

I'll have that checked in about 10 minutes from now.

And thanks! You contributed the impetus to get this moving; I'm glad you're impressed with the result!
Judebert
---
Website | Wishlist | PayPal

gregman
Regular
 
Posts: 92
Joined: Wed Aug 15, 2007 9:32 pm

Postby gregman » Sat Feb 16, 2008 2:38 pm

I just thought about the problem with the custom permalink plugin. Wouldn't it help to use $_SERVER['REQUEST_URI'] on every entry with an .htm/l ending, e.g.
Code: Select all
if (stristr($_SERVER['REQUEST_URI'], ".htm")) {
    $url = $_SERVER['REQUEST_URI'] . '?';
} else {
    $url = serendipity_currentURL() . '&amp;';
}

It works fine on my installation.

Greg

User avatar
garvinhicking
Core Developer
 
Posts: 28954
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Postby garvinhicking » Sat Feb 16, 2008 3:59 pm

Hi!

That would create trouble on servers without URL rewriting cause it would then use index.php?/archives/permalink.htm?blabla with two "?"s.

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/

gregman
Regular
 
Posts: 92
Joined: Wed Aug 15, 2007 9:32 pm

Postby gregman » Sat Feb 16, 2008 6:14 pm

Ah, I see. Well then, how about:
Code: Select all
if (stristr($_SERVER['REQUEST_URI'], "index.php?")) {
    $url = serendipity_currentURL() . '&amp;';
} else {
    $url = $_SERVER['REQUEST_URI'] . '?';
}

Greg

User avatar
blog.brockha.us
Regular
 
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany

Postby blog.brockha.us » Sun Feb 17, 2008 6:34 pm

I would like to see some enhancements in the plugin:

* It would be nice to have the voting implemented as AJAX calls, so we don't have to reload the page for this.
* An option to disable the page call counter, if the visitor is just voting, proviewing or comitting a comment.

Is there something we can do about it?

About the German language files: I already changed them in the cvs. It seems my last changes didn't reach judebert, so they didn't made it into the cvs.
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/

User avatar
judebert
Regular
 
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL

Postby judebert » Mon Feb 18, 2008 8:47 pm

blog.brockha.us wrote:* It would be nice to have the voting implemented as AJAX calls, so we don't have to reload the page for this.

I'll look into it and see what I can do.
blog.brockha.us wrote:* An option to disable the page call counter, if the visitor is just voting, proviewing or comitting a comment.

An interesting idea. It should be possible: just check for the appropriate fields and refuse to increment the visit counter if they're present.
blog.brockha.us wrote:About the German language files: I already changed them in the cvs. It seems my last changes didn't reach judebert, so they didn't made it into the cvs.

I thought I included those. If you send them again, I'll be happy to re-commit them.
Judebert
---
Website | Wishlist | PayPal

gregman
Regular
 
Posts: 92
Joined: Wed Aug 15, 2007 9:32 pm

Postby gregman » Sat Mar 19, 2011 12:26 am

blog.brockha.us wrote:* It would be nice to have the voting implemented as AJAX calls, so we don't have to reload the page for this.


I recently managed to do this using jquery but the "ajax call" feature only supports imagevoting and no voting timeouts. If it seems to be of use anyhow let me know. I will share some code.

Previous


Return to Plugins

Who is online

Users browsing this forum: Google [Bot] and 2 guests