decrudify and update emailshare

pull/1/head
eric 2014-02-21 14:12:20 -05:00
parent 92e870d2b7
commit 665fd94e73
7 changed files with 18 additions and 35 deletions

View File

@ -69,7 +69,7 @@ $j(document).ready(function() {
<a href="https://www.facebook.com/sharer.php?u=https://{{ site.domain }}{% url work work.id|urlencode:"" %}"><li class="facebook first"><span>Facebook</span></li></a> <a href="https://www.facebook.com/sharer.php?u=https://{{ site.domain }}{% url work work.id|urlencode:"" %}"><li class="facebook first"><span>Facebook</span></li></a>
<a href="https://twitter.com/intent/tweet?url={{ request.build_absolute_uri|urlencode:"" }}&amp;text=I%27m%20enjoying%20{{ work.title|urlencode }}%2C%20a%20free%2C%20non%2DDRM%20ebook%2E%20You%20can%20too%21"><li class="twitter"><span>Twitter</span></li></a> <a href="https://twitter.com/intent/tweet?url={{ request.build_absolute_uri|urlencode:"" }}&amp;text=I%27m%20enjoying%20{{ work.title|urlencode }}%2C%20a%20free%2C%20non%2DDRM%20ebook%2E%20You%20can%20too%21"><li class="twitter"><span>Twitter</span></li></a>
{% endwith %} {% endwith %}
{% if request.user.is_authenticated %}<a href="{% url emailshare '' %}?next={% url work work.id %}"><li class="email"><span>Email</span></li></a>{% endif %} {% if request.user.is_authenticated %}<a href="{% url emailshare 'downloaded' %}?next={% url work work.id %}"><li class="email"><span>Email</span></li></a>{% endif %}
<a id="embed2"><li class="embed"><span>Embed</span></li></a> <a id="embed2"><li class="embed"><span>Embed</span></li></a>
<div id="widgetcode2">Copy/paste this into your site:<br /><textarea rows="7" cols="22">&lt;iframe src="https://{{ request.META.HTTP_HOST }}/api/widget/{{ work.first_isbn_13 }}/" width="152" height="325" frameborder="0"&gt;&lt;/iframe&gt;</textarea></div> <div id="widgetcode2">Copy/paste this into your site:<br /><textarea rows="7" cols="22">&lt;iframe src="https://{{ request.META.HTTP_HOST }}/api/widget/{{ work.first_isbn_13 }}/" width="152" height="325" frameborder="0"&gt;&lt;/iframe&gt;</textarea></div>
</ul> </ul>

View File

@ -1,4 +1,6 @@
I just pledged to unglue one of my favorite books, "{{ work.title }}", on Unglue.it: I just {{ action }} one of my favorite books, "{{ work.title }}", on Unglue.it:
https://{{site}}{% url work work.id %}. https://{{site}}{% url work work.id %}.
If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth. Will you join me? {% ifequal work.last_campaign.type 1 %}If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 2 %}If enough of us buy this book, the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 3 %}Creators of free ebooks need support if we want there to be more of them.{% endifequal %}
Will you join me?

View File

@ -1,4 +1,4 @@
Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it: Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it:
https://{{site}}{% url work work.id %} https://{{site}}{% url work work.id %}
If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth. {% ifequal work.last_campaign.type 1 %}If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 2 %}If enough of us buy this book, the ebook will become free to everyone on earth.{% endifequal %}{% ifequal work.last_campaign.type 3 %}Creators of free ebooks need support if we want there to be more of them.{% endifequal %}

View File

@ -1,4 +1,4 @@
Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it: Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it:
https://{{site}}{% url work work.id %} https://{{site}}{% url work work.id %}
If enough of us wishlist this book, Unglue.it may start a campaign to pay the creator and make the ebook free to everyone on earth. If enough of us fave this book, Unglue.it may start a campaign to pay the creator and make the ebook free to everyone on earth.

View File

@ -1,5 +1,5 @@
<ul> <ul>
{% if request.user.is_authenticated %}<a href="{% url emailshare 'pledge' %}?next={{ work_url|urlencode:"" }}"><li>Email it!</li></a>{% endif %} {% if request.user.is_authenticated %}<a href="{% url emailshare 'pledged' %}?next={{ work_url|urlencode:"" }}"><li>Email it!</li></a>{% endif %}
<a href="https://twitter.com/intent/tweet?url=https://{{ current_site.domain }}{{ work_url|urlencode:"" }}&text=I%27m%helping%20to%20unglue%20{{ title|urlencode }}%20at%20%40unglueit.%20Will%20you%20join%20me%3F"><li>Tweet it!</li></a> <a href="https://twitter.com/intent/tweet?url=https://{{ current_site.domain }}{{ work_url|urlencode:"" }}&text=I%27m%helping%20to%20unglue%20{{ title|urlencode }}%20at%20%40unglueit.%20Will%20you%20join%20me%3F"><li>Tweet it!</li></a>
<a href="https://www.facebook.com/sharer.php?u=https://{{ current_site.domain }}{{ work_url|urlencode:"" }}"><li>Share it on Facebook.</li></a> <a href="https://www.facebook.com/sharer.php?u=https://{{ current_site.domain }}{{ work_url|urlencode:"" }}"><li>Share it on Facebook.</li></a>
<li>Best idea: talk about it with those you love.</li> <li>Best idea: talk about it with those you love.</li>

View File

@ -52,7 +52,7 @@
<ul class="social menu pledge"> <ul class="social menu pledge">
<a href="https://www.facebook.com/sharer.php?u=https://{{ site.domain }}{% url work work.id|urlencode:"" %}"><li class="facebook first"><span>Facebook</span></li></a> <a href="https://www.facebook.com/sharer.php?u=https://{{ site.domain }}{% url work work.id|urlencode:"" %}"><li class="facebook first"><span>Facebook</span></li></a>
<a href="https://twitter.com/intent/tweet?url=https://{{ site.domain }}{% url work work.id|urlencode:"" %}&amp;text=I%20just%20supported%20{{ work.title|urlencode }}%20at%20%40unglueit.%20Will%20you%20join%20me%3F"><li class="twitter"><span>Twitter</span></li></a> <a href="https://twitter.com/intent/tweet?url=https://{{ site.domain }}{% url work work.id|urlencode:"" %}&amp;text=I%20just%20supported%20{{ work.title|urlencode }}%20at%20%40unglueit.%20Will%20you%20join%20me%3F"><li class="twitter"><span>Twitter</span></li></a>
{% if request.user.is_authenticated %}<a href="{% url emailshare 'pledge' %}?next={% url work work.id|urlencode:"" %}"><li class="email"><span>Email</span></li></a>{% endif%} {% if request.user.is_authenticated %}<a href="{% url emailshare 'pledged' %}?next={% url work work.id|urlencode:"" %}"><li class="email"><span>Email</span></li></a>{% endif%}
<a href="#" id="embed"><li class="embed"><span>Embed</span></li></a> <a href="#" id="embed"><li class="embed"><span>Embed</span></li></a>
</ul> </ul>
</div> </div>

View File

@ -2474,44 +2474,25 @@ def emailshare(request, action):
work_id = next.split('/')[-2] work_id = next.split('/')[-2]
work_id = int(work_id) work_id = int(work_id)
work = models.Work.objects.get(pk=work_id) work = models.Work.objects.get(pk=work_id)
if action == 'pledge': if not action:
message = render_to_string('emails/i_just_pledged.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = "Help me unglue "+work.title
else:
try:
status = work.last_campaign().status status = work.last_campaign().status
except:
status = None
# customize the call to action depending on campaign status
if status == 'SUCCESSFUL' or work.first_ebook():
message = render_to_string('emails/read_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = 'I think you\'d like this book I\'m reading'
elif status == 'ACTIVE':
message = render_to_string('emails/pledge_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = 'Please help me give this book to the world'
else:
message = render_to_string('emails/wish_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
subject = 'Come see one of my favorite books on Unglue.it'
form = EmailShareForm(initial={ 'next':next, 'subject': subject, 'message': message})
except: except:
pass pass
context = {'request':request,'work':work,'site': Site.objects.get_current(), 'action': action}
if action == 'pledge': if work and action :
message = render_to_string('emails/i_just_pledged.txt',{'request':request,'work':work,'site': Site.objects.get_current()}) message = render_to_string('emails/i_just_pledged.txt', context)
subject = "Help me unglue "+work.title subject = "Help me unglue "+work.title
else: else:
# customize the call to action depending on campaign status # customize the call to action depending on campaign status
if status == 'ACTIVE': if status == 'ACTIVE':
message = render_to_string('emails/pledge_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()}) message = render_to_string('emails/pledge_this.txt', context)
subject = 'Please help me give this book to the world' subject = 'Please help me give this book to the world'
elif work: elif work:
message = render_to_string('emails/wish_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()}) message = render_to_string('emails/wish_this.txt', context)
subject = 'Come see one of my favorite books on Unglue.it' subject = 'This is one of my favorite books on Unglue.it'
else: else:
# for email shares not bound to a campaign or pledge # for email shares not bound to a campaign or pledge
message = render_to_string('emails/join_me.txt',{'request':request,'site': Site.objects.get_current()}) message = render_to_string('emails/join_me.txt', context)
subject = "Help me give books to the world" subject = "Help me give books to the world"
form = EmailShareForm(initial={ 'next':next, 'subject': subject, 'message': message}) form = EmailShareForm(initial={ 'next':next, 'subject': subject, 'message': message})