From d2765da9bbcbf3acf170a820dfb747fa2761a39d Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 21 Sep 2020 13:24:51 -0400 Subject: [PATCH] set charset on opds --- api/opds.py | 3 ++- api/views.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/opds.py b/api/opds.py index 3bc6dff5..434ea59b 100644 --- a/api/opds.py +++ b/api/opds.py @@ -25,7 +25,8 @@ FORMAT_TO_MIMETYPE = {'pdf':"application/pdf", 'text':"text/html"} UNGLUEIT_URL = 'https://unglue.it' -ACQUISITION = "application/atom+xml;profile=opds-catalog;kind=acquisition" +ACQUISITION = "application/atom+xml; profile=opds-catalog ;kind=acquisition; charset=utf-8" +NAVIGATION = "application/atom+xml; profile=opds-catalog; kind=navigation; charset=utf-8" FACET_RELATION = "http://opds-spec.org/facet" old_facets = ["creative_commons", "active_campaigns"] diff --git a/api/views.py b/api/views.py index 1bde04ce..f85ae050 100755 --- a/api/views.py +++ b/api/views.py @@ -176,7 +176,7 @@ class OPDSNavigationView(TemplateView): if self.json: response_kwargs['content_type'] = "application/vnd.opds.navigation+json" else: - response_kwargs['content_type'] = "application/atom+xml;profile=opds-catalog;kind=navigation" + response_kwargs['content_type'] = opds.NAVIGATION return super(TemplateView, self).render_to_response(context, **response_kwargs) def get_context_data(self, **kwargs): @@ -199,7 +199,7 @@ class OPDSAcquisitionView(View): content_type="application/opds-publication+json") else: return StreamingHttpResponse(opds.opds_feed_for_work(work), - content_type="application/atom+xml;profile=opds-catalog;kind=acquisition") + content_type=opds.ACQUISITION) facet = kwargs.get('facet') page = request.GET.get('page', None) order_by = request.GET.get('order_by', 'newest') @@ -214,11 +214,11 @@ class OPDSAcquisitionView(View): if self.json: facet_class = opds_json.get_facet_class(facet)() return StreamingHttpResponse(facet_class.feed(page,order_by), - content_type="application/opds+json") + content_type="application/opds+json; charset=utf-8") else: facet_class = opds.get_facet_class(facet)() return StreamingHttpResponse(facet_class.feed(page,order_by), - content_type="application/atom+xml;profile=opds-catalog;kind=acquisition") + content_type=opds.ACQUISITION) class OnixView(View): def get(self, request, *args, **kwargs):