Remote voting widget

FatPitchFinancials - August 5, 2006 - 18:09
Project:Vote up/down Package
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs review)
Description

I thing a really cool feature would be to have a widget that authors could add to stories on their sites that would allow their users to vote (or submit if the story is not already in the system) on their stories and have them promoted on the Vote Up/Down enabled Drupal site. I have something like this going on at my main site, www.fatpitchfinancials.com that then allows users to vote up the stories on my pligg powered site, news.fatpitchfinancials.com. Would something like this be possible with the Vote up/down package?

By the way, I like the bookmarklet feature, which I guess is kind of a precursor to the feature I'm suggesting in this post.

#1

patchak - October 24, 2006 - 15:42

+1 for this feature...

Would anyone be willing to shell out a few bucks to get the attention of the module maintainer??
I'm ready to thrown in some money for this feature...

Thanks

#2

frjo - November 2, 2006 - 11:46
Status:active» postponed

This sound like a JavaScript powered feature and that is not my strong side. If someone commit a nice and clean solution I will take a look at it. Drupal 5 includes the jQuery JavaScript library that can do many cool thing and probably can make stuff like this more easy to implement.

#3

FatPitchFinancials - November 3, 2006 - 01:17

I'm not sure JavaScript is needed. What we could really use is the ability to bring up a storylink by referencing the story's URL. Something like http://www.example.com/storylink?URL=http://www.storyslink.com. Any chance we already have that ability using the link package api? If not, I'd really like to see that added to the storylink portion of the Vote up/down Package.

#4

patchak - November 13, 2006 - 21:17

Well I don't know how to do it, but it seems to me the code must be similar to the one used in the bookmarklet one?? Any ideas ??

Thanks

#5

Ron Williams - January 10, 2007 - 18:14

+1 to getting this feature worked on. I would like to have this.

#6

Dusty Puppet - January 16, 2007 - 15:29

...and another +1. Much awe and adulation for any fine young soul out there who can do it...

#7

unleached - January 18, 2007 - 19:18

I would be extremely happy if such a feature should become available.

#8

JBI - March 11, 2007 - 15:15

I think it's an important part of the viral effect of DIGG.
So it's a must have.

#9

xeniox - April 7, 2007 - 18:13
Status:postponed» patch (code needs review)

This patch is an attempt to get a remote voting widget for the vote-up-down module.
It was designed & tested for the Drupal 4.7-dev branch.
On my website i installed the vote-up-down package as described in the install instructions, without a lot of customisations (as far as i recall).
I used the normal widget, not the alternate one, and the standard vote_storylink module as content type.

Note also that this functionality was added to the vote_storylink module which i had installed locally (v 1.14.2.1). I've seen that the module is at version 1.25 right now.
I have tested it with 1.25, but not as thoroughly as i should have :)

The patch file attached however is a patch against the latest version of vote_storylink: v1.25

How to get the widget working:
==============================
1/ Backup your vote_storylink.module, and don't test this on a live site yet!
2/ patch your vote_storylink.module
3/ edit externalvote.js and change "YOURSITE.COM" to your site URL.
4/ put the externalvote.js file in the /scripts/ directory
5/ OPTIONAL: overwrite the theme functions to adjust the votebox to your needs:
- theme_vote_storylink_remote_box (the box shown on external pages already voted on showing the # of points)
- theme_vote_storylink_remote_box_plus (the link to vote underneath the points box)
- theme_vote_storylink_remote_box_add (the box shown on external pages not already voted on - shows 'add this article' link)
6/ add one of the scripts on the external page as mentioned in the following example case.

Example case:
============
situation:
----------
www.site1.com is a Drupal site with the vote-up-down module installed.
www.site2.com is a random site with articles (to test, take one which your are able to edit). eg. www.site2.com/article/33

instructions:
-------------

There are 2 different cases with according scripts:
The 1st script case: you want the voting widget on the page which will be / has been submitted to site1.com: site2.com/article/33
edit the page site1.com/article/33 and put the following script wherever you want the voting box, changing site1.com to your URL:

<script src="http://www.site1.com/scripts/externalvote.js"
  type="text/javascript">
</script>

The 2nd script case: you want the voting widget on another page of site2.com: eg. on the site2.com/ frontpage (where article/33 might be shown as a teaser)

edit the page you want the widget to appear on on your site2.com, and put the following script in:

<script type="text/javascript">
  site-url = "<URL>";
  site-title = "<TITLE>";
</script>
<script src="http://www.YOURSITE.COM/scripts/externalvote.js"
  type="text/javascript">
</script>

In the above script, change site1.com to your URL again, and the variables 'site-url' and 'site-title' to the URL and title of the appropriate article.
If needed, these variables could be filled in automatically, with some PHP code, but that's up to you.

testing:
--------
If all goes well, you should get a box with a 'add this article' link on your site2.com article page. When clicked, it takes you to node/add/storylink on site1.com, and fills

in the title and URL (site1.com/article/33 in this case), similar to the bookmarklet functionality.

Once you have added this storylink on your site1.com, you will see on site2.com/article/33 that the voting widget has changed after being refreshed, and now shows the number

of points (should be 0 at this point), plus a link to vote on this particular article.
If you click on the vote link (and are logged in on site1.com!), you will be taken to the storylink on site1.com and a vote will have been added.
If you would refresh the site2.com/article/33 page again, the widget should show 1 point now.

If possible, i would like some people to test this. I will do some more testing too on a fresh Drupal installation, because right now i have been testing it on a testsite

which had a lot of modules and customisations.

If my code seems to be working OK and frjo wants me to, i can update the current CVS version of the vote_storylink.module, to get this functionality in it, but right now i'd

rather don't touch the CVS too much, as this is one of my first patches ever :)
Anyway, i guess we should test this more thoroughly first.

Any comments & suggestions are welcome.
Be also on the lookout for possible security issues when testing.

Kind regards,

xeniox

AttachmentSize
remote-voting.patch4.55 KB

#10

xeniox - April 7, 2007 - 18:15

Oops.. forgot the javascript file externalvote.js
See attachment :)

AttachmentSize
externalvote.js_.txt387 bytes

#11

xeniox - April 7, 2007 - 18:23

Hmm seems i applied the patch against the HEAD version (which is for Drupal 5 if i am correct?), where it should have been against the 4-7 branch.
However i have no idea how to get to the 4.7 version of vote_storylink, as i can only see one version in the CVS through my Eclipse.
I'll have a look at how to create the right patch for the right version :)

#12

xeniox - April 7, 2007 - 18:43

Okay here is the correct patch for Drupal 4.7.

Please give me some feedback if possible :) I'm quite new to all of this.

xeniox

AttachmentSize
remote-voting-1.patch4.5 KB

#13

FatPitchFinancials - April 10, 2007 - 00:27

Thank you very much for working on this. I plan on testing it soon.

I have a question first. Do I apply this patch to the 4.7 official release or the 4.7 development snapshot?

#14

xeniox - April 10, 2007 - 13:05

It has only been tested against 4-7-dev right now..

#15

FatPitchFinancials - April 14, 2007 - 13:23

There is a typo in the javascript.
Look for:
encodeURIComponent(titel)

It should read:
encodeURIComponent(title)

Even after this fix, I can't get this working. The page URL is not getting passed correctly to the iframe. Do you have a demo of the external vote widget set up somewhere?

#16

FatPitchFinancials - April 14, 2007 - 14:19

It looks like I have it working now.
See http://www.fatpitchfinancials.com/551/broadridge-financial-solutions-ana...

I just had to run update.php so that the patch changes could take effect.

#17

shimamoto - May 31, 2007 - 19:25

Anyone know what code I would need to use to make this work for forum topics with a CCK link field instead of a storylink?

#18

Ron Williams - August 15, 2007 - 05:27

Are there plans to get this committed to the current build?

#19

FatPitchFinancials - December 19, 2007 - 14:57

Has anyone ported the remote voting code to version 5 of Vote up/down? I had it working under version 4.7 but never figured out what I needed to change when I upgraded to Drupal 5.3. I'd like to get this feature back, especially now that my site is getting more traffic.

#20

chazz - February 8, 2008 - 01:44

is it working for drupal 5 now ?

#21

jiggle - February 29, 2008 - 12:28

#22

FatPitchFinancials - February 29, 2008 - 16:00

That's great news jiggle! Did you have to modify the code in any way to get it to work? I want to implement this at my Drupal 5 site right away.

#23

chazz - July 24, 2008 - 11:19

Yeah, how we can do it now ?

 
 

Drupal is a registered trademark of Dries Buytaert.