fix the odds implementation of kw facet

mostly, fixing missing url encoding
pull/1/head
eric 2015-01-12 12:03:47 -05:00
parent 65c2ebb158
commit ea4e489213
4 changed files with 16 additions and 10 deletions

View File

@ -3,6 +3,7 @@ from itertools import islice
from lxml import etree
import datetime
import urlparse
import urllib
import pytz
@ -29,6 +30,8 @@ def feeds():
yield globals()[facet]
for facet_path in facets.get_all_facets('Format'):
yield get_facet_facet(facet_path)
for facet_path in facets.get_all_facets('Keyword'):
yield get_facet_facet(facet_path)
def get_facet_class(name):
if name in old_facets:
@ -123,8 +126,8 @@ def work_node(work):
# subject tags
# [[subject.name for subject in work.subjects.all()] for work in ccworks if work.subjects.all()]
if work.subjects.all():
for subject in work.subjects.all():
if subject.is_visible:
category_node = etree.Element("category")
category_node.attrib["term"] = subject.name
node.append(category_node)
@ -257,7 +260,7 @@ def opds_feed_for_works(the_facet, page=None, order_by='newest'):
def append_navlink(feed, rel, path, page, order_by, group=None, active=None , title=""):
link = etree.Element("link")
link.attrib.update({"rel":rel,
"href": UNGLUEIT_URL + "/api/opds/" + path + '/?order_by=' + order_by + ('&page=' + unicode(page) if page!=None else ''),
"href": UNGLUEIT_URL + "/api/opds/" + urllib.quote(path) + '/?order_by=' + order_by + ('&page=' + unicode(page) if page!=None else ''),
"type": NAVIGATION,
"title": title,
})

View File

@ -3,16 +3,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.kbcafe.com/rss/atom.xsd.xml">
<title>Unglue.it Catalog</title>
<id>https://unglue.it/api/opds/</id>
<id>https://unglue.it{% url opds %}</id>
<updated>2014-06-13T21:48:34Z</updated>
<author>
<name>unglue.it</name>
<uri>https://unglue.it/</uri>
</author>
<link rel="start" href="https://unglue.it/api/opds/" type="application/atom+xml;profile=opds-catalog;kind=navigation" />
<link rel="start" href="https://unglue.it{% url opds %}" type="application/atom+xml;profile=opds-catalog;kind=navigation" />
<entry>
<title>{{ feed.title }} - Popular</title>
<id>https://unglue.it/api/opds/{{ feed.feed_path }}/?order_by=popular</id>
<id>https://unglue.it{% url opds_acqusition feed.feed_path %}?order_by=popular</id>
<updated>{{ feed.updated }}</updated>
<link href="{{ feed.feed_path }}/?order_by=popular"
rel="http://opds-spec.org/sort/popular"
@ -21,7 +21,7 @@
</entry>
<entry>
<title>{{ feed.title }} - New</title>
<id>https://unglue.it/api/opds/{{ feed.feed_path }}/?order_by=newest</id>
<id>https://unglue.it{% url opds_acqusition feed.feed_path %}?order_by=newest</id>
<updated>{{ feed.updated }}</updated>
<link href="{{ feed.feed_path }}/?order_by=popular"
rel="http://opds-spec.org/sort/new"
@ -31,9 +31,9 @@
{% for feed in feeds %}
<entry>
<title>{{ feed.title }}</title>
<id>https://unglue.it/api/opds/{{ feed.feed_path }}/</id>
<id>https://unglue.it{% url opds_acqusition feed.feed_path %}</id>
<updated>{{ feed.updated }}</updated>
<link href="{{ feed.feed_path }}/"
<link href="{% url opds_acqusition feed.feed_path %}"
rel="subsection"
type="application/atom+xml;profile=opds-catalog;kind=acquisition" />
<content type="text">{{ feed.description }}</content>

View File

@ -23,6 +23,6 @@ urlpatterns = patterns('',
url(r'^widgettest/$',TemplateView.as_view(template_name="widget_embed.html")),
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>[^\s]*)/$", OPDSAcquisitionView.as_view(), name="opds_acqusition"),
url(r"^opds/(?P<facet>.*)/$", OPDSAcquisitionView.as_view(), name="opds_acqusition"),
(r'^', include(v1_api.urls)),
)

View File

@ -174,6 +174,9 @@ class KeywordFacetGroup(FacetGroup):
@property
def label(self):
return self.keyword
@property
def description(self):
return "%s eBooks" % self.keyword
return KeywordFacet
# order of groups in facet_groups determines order of display on /free/