parent
9ddd8de2d6
commit
f7411d9525
|
@ -13,6 +13,17 @@
|
|||
{% else %}
|
||||
<p> Please <a href="{% url 'superlogin' %}?next={% firstof request.get_full_path|urlencode '/' %}"><span>sign in</span></a> first.</p>
|
||||
{% endif %}
|
||||
<h3>Ebook Widgets</h3>
|
||||
<p>You don't need an API key to embed Ebook (HTML) widgets. </p>
|
||||
<div>Here's a widget that displays Unglue.it's featured ebook - it changes most every day! <a href="{% url 'widget' 'featured' %}">{{base_url}}{% url 'widget' 'featured' %}</a>. Copy/paste this into your site:<br /><textarea rows="7" cols="22"><iframe src="{{base_url}}/api/widget/featured/" width="152" height="325" frameborder="0"></iframe></textarea>
|
||||
<iframe src="{{base_url}}{% url 'widget' 'featured' %}" width="152" height="325" frameborder="0"></iframe></div>
|
||||
{% if campaign %}
|
||||
<div>Here's a sample widget for the book <span style="font-style: italic">{{campaign.name}}</span> with ISBN {{campaign_isbn}}: <a href="{% url 'widget' campaign_isbn %}">{{base_url}}{% url 'widget' campaign_isbn %}</a>. Copy/paste this into your site:<br /><textarea rows="7" cols="22"><iframe src="{{base_url}}/api/widget/{{campaign_isbn}}/" width="152" height="325" frameborder="0"></iframe></textarea>
|
||||
<iframe src="{{base_url}}{% url 'widget' campaign_isbn %}" width="152" height="325" frameborder="0"></iframe>
|
||||
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h3>Basic API info</h3>
|
||||
|
||||
|
@ -52,13 +63,6 @@ XML: <a href="/api/v1/identifier/?format=xml&api_key={{api_key}}&usernam
|
|||
<p> In addition to isbn, you can use 'goog' if you have a google books id, and 'oclc' for oclc numbers.</p>
|
||||
{% endif %}
|
||||
|
||||
<h3>Campaign Widgets</h3>
|
||||
<p>You don't need a key to embed campaign (HTML) widgets. </p>
|
||||
{% if campaign %}
|
||||
Here's a sample widget for the book <span style="font-style: italic">{{campaign.name}}</span> with ISBN {{campaign_isbn}}: <a href="{% url 'widget' campaign_isbn %}">{{base_url}}{% url 'widget' campaign_isbn %}</a>
|
||||
{% else %}
|
||||
<p>Since there are currently no campaigns, there are no corresponding widgets.</p>
|
||||
{% endif %}
|
||||
|
||||
<h3>OPDS Catalog Feeds</h3>
|
||||
<p>We have a basic implementation of <a href="http://opds-spec.org/specs/opds-catalog-1-1-20110627/">OPDS</a> feeds. You don't need a key to use them. The starting point is <code><a href="{% url 'opds' %}">{{base_url}}{% url 'opds' %}</a></code></p>
|
||||
|
|
|
@ -20,7 +20,7 @@ v1_api.register(resources.FreeResource())
|
|||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^help$', ApiHelpView.as_view(), name="api_help"),
|
||||
url(r'^widget/(?P<isbn>\w+)/$','regluit.api.views.widget', name="widget"),
|
||||
url(r'^widget/(?P<isbn>\w+)/$','regluit.api.views.widget',name="widget"),
|
||||
url(r"^opds/$", OPDSNavigationView.as_view(template_name="opds.xml"), name="opds"),
|
||||
url(r"^opds/(?P<facet>.*)/$", OPDSAcquisitionView.as_view(), name="opds_acqusition"),
|
||||
url(r"^onix/(?P<facet>.*)/$", OnixView.as_view(), name="onix"),
|
||||
|
|
34
api/views.py
34
api/views.py
|
@ -47,25 +47,31 @@ def negotiate_content(request,work_id):
|
|||
|
||||
return HttpResponseRedirect(reverse('work', kwargs={'work_id': work_id}))
|
||||
|
||||
def widget(request,isbn):
|
||||
def widget(request, isbn):
|
||||
"""
|
||||
supply info for book panel. parameter is named isbn for historical reasons. can be isbn or work_id
|
||||
"""
|
||||
|
||||
|
||||
if len(isbn)==10:
|
||||
isbn = regluit.core.isbn.convert_10_to_13(isbn)
|
||||
if len(isbn)==13:
|
||||
if isbn == 'featured':
|
||||
try:
|
||||
identifier = models.Identifier.objects.get(type = 'isbn', value = isbn )
|
||||
work = identifier.work
|
||||
except models.Identifier.DoesNotExist:
|
||||
return render_to_response('widget.html',
|
||||
{ 'work':None,},
|
||||
context_instance=RequestContext(request)
|
||||
)
|
||||
else:
|
||||
work= models.safe_get_work(isbn)
|
||||
work = models.Work.objects.filter(featured__isnull=False).distinct().order_by('-featured')[0]
|
||||
except:
|
||||
#shouldn't occur except in tests
|
||||
work = models.Work.objects.all()[0]
|
||||
else :
|
||||
if len(isbn)==10:
|
||||
isbn = regluit.core.isbn.convert_10_to_13(isbn)
|
||||
if len(isbn)==13:
|
||||
try:
|
||||
identifier = models.Identifier.objects.get(type = 'isbn', value = isbn )
|
||||
work = identifier.work
|
||||
except models.Identifier.DoesNotExist:
|
||||
return render_to_response('widget.html',
|
||||
{ 'work':None,},
|
||||
context_instance=RequestContext(request)
|
||||
)
|
||||
else:
|
||||
work= models.safe_get_work(isbn)
|
||||
return render_to_response('widget.html',
|
||||
{'work':work, },
|
||||
context_instance=RequestContext(request)
|
||||
|
|
Loading…
Reference in New Issue