Skip to content

Commit

Permalink
moved social buttons into iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Aug 20, 2010
1 parent f4bde26 commit e8f1320
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
8 changes: 2 additions & 6 deletions templates/election_view.html
Expand Up @@ -44,12 +44,8 @@ <h2 class="title">{{ election.name }}


<br /><br />
{% if status_update_message %}
<span style="margin: 20px;">
<a name="fb_share" type="box_count" share_url="{{election_url}}" href="http://www.facebook.com/sharer.php?t={{status_update_message|urlencode}}">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></span>

<a href="http://twitter.com/share" class="twitter-share-button" data-url="{{election_url}}" data-text="{{status_update_message}}" data-count="none" data-via="heliosvoting">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

{% if socialbuttons_url %}
<iframe src="{{socialbuttons_url}}" frameborder="0" border="0" style="width: 300px; height:100px;"></iframe>
{% endif %}


Expand Down
5 changes: 5 additions & 0 deletions templates/socialbuttons.html
@@ -0,0 +1,5 @@
<span style="margin: 20px;">
<a name="fb_share" type="box_count" share_url="{{url}}" href="http://www.facebook.com/sharer.php?t={{text|urlencode}}">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></span>

<a href="http://twitter.com/share" class="twitter-share-button" data-url="{{url}}" data-text="{{text}}" data-count="none" data-via="heliosvoting">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

1 change: 1 addition & 0 deletions urls.py
Expand Up @@ -10,6 +10,7 @@
urlpatterns = patterns('',
(r'^$', home),
(r'^stats$', stats),
(r'^socialbuttons$', socialbuttons),

# election shortcut by shortname
(r'^e/(?P<election_short_name>[^/]+)$', election_shortcut),
Expand Down
26 changes: 22 additions & 4 deletions views.py
Expand Up @@ -11,7 +11,7 @@

from mimetypes import guess_type

import csv
import csv, urllib

from crypto import algs, electionalgs
from crypto import utils as cryptoutils
Expand Down Expand Up @@ -220,15 +220,33 @@ def one_election_view(request, election):
# result!
if election.result:
status_update_message = "Results are in for %s" % election.name


# a URL for the social buttons
socialbuttons_url = None
if status_update_message:
socialbuttons_url = "%s%s?%s" % (settings.SOCIALBUTTONS_URL_HOST,
reverse(socialbuttons),
urllib.urlencode({
'url' : election_url,
'text': status_update_message
}))

trustees = Trustee.get_by_election(election)

return render_template(request, 'election_view',
{'election' : election, 'trustees': trustees, 'admin_p': admin_p, 'user': user,
'voter': voter, 'votes': votes, 'notregistered': notregistered, 'eligible_p': eligible_p,
'can_feature_p': can_feature_p, 'election_url' : election_url,
'status_update_message' : status_update_message})

'socialbuttons_url' : socialbuttons_url})

def socialbuttons(request):
"""
just render the social buttons for sharing a URL
expecting "url" and "text" in request.GET
"""
return render_template(request, 'socialbuttons',
{'url': request.GET['url'], 'text':request.GET['text']})

##
## Trustees and Public Key
##
Expand Down

0 comments on commit e8f1320

Please sign in to comment.