From 65d21619784ccb4e7f448a80d0e358d8b5fa84e1 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Fri, 1 Oct 2010 01:34:02 +0000 Subject: [PATCH] vestigial unAPI/mods3 support It works well enough to import sample records into Zotero. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1025 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/urls.py | 1 + conifer/syrup/views/__init__.py | 1 + conifer/syrup/views/unapi.py | 23 + conifer/templates/components/site.xhtml | 1 + conifer/templates/item/item_metadata.xhtml | 1 + conifer/templates/master.xhtml | 1 + conifer/templates/unapi/MARC21slim2MODS3-3.xsl | 3771 ++++++++++++++++++++++++ conifer/templates/unapi/formats.xml | 9 + 8 files changed, 3808 insertions(+) create mode 100644 conifer/syrup/views/unapi.py create mode 100644 conifer/templates/unapi/MARC21slim2MODS3-3.xsl create mode 100644 conifer/templates/unapi/formats.xml diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index 21687b3..6e798bf 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -63,4 +63,5 @@ urlpatterns = patterns('conifer.syrup.views', # (r'^admin/terms/(?P\d+)/$', 'admin_term_edit'), # (r'^admin/terms/(?P\d+)/delete$', 'admin_term_delete'), # (r'^admin/terms/$', 'admin_term'), + (r'^unapi/$', 'unapi'), ) diff --git a/conifer/syrup/views/__init__.py b/conifer/syrup/views/__init__.py index f30317c..4a52676 100644 --- a/conifer/syrup/views/__init__.py +++ b/conifer/syrup/views/__init__.py @@ -5,3 +5,4 @@ from search import * from admin import * from feeds import * from auth import * +from unapi import * diff --git a/conifer/syrup/views/unapi.py b/conifer/syrup/views/unapi.py new file mode 100644 index 0000000..f26ebc1 --- /dev/null +++ b/conifer/syrup/views/unapi.py @@ -0,0 +1,23 @@ +from lxml import etree + +from _common import * + +stylesheet = etree.parse( + file(HERE('templates/unapi/MARC21slim2MODS3-3.xsl'))) + +xform = etree.XSLT(stylesheet) + +def unapi(request): + id = request.GET.get('id') + format = request.GET.get('format') + if not format: + return g.render_xml('unapi/formats.xml', id=id) + elif format=='mods3': + item = get_object_or_404(models.Item, pk=id) + xml = item.marcxml + if xml: + doc = etree.fromstring(xml) + mods = xform(doc) + return HttpResponse(etree.tostring(mods), + content_type='application/xml') + return HttpResponseNotFound() diff --git a/conifer/templates/components/site.xhtml b/conifer/templates/components/site.xhtml index 9b158c8..3c379a8 100644 --- a/conifer/templates/components/site.xhtml +++ b/conifer/templates/components/site.xhtml @@ -32,6 +32,7 @@ searchtext = _('search this site...') class="itemtree">
  • +
    +

    Display MARC Record