Bugzilla – Attachment 20697 Details for
Bug 6594
Add schema.org microdata
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6594: Schema.org structured data for OPAC display
Bug-6594-Schemaorg-structured-data-for-OPAC-displa.patch (text/plain), 18.65 KB, created by
Chris Cormack
on 2013-08-28 11:07:23 UTC
(
hide
)
Description:
Bug 6594: Schema.org structured data for OPAC display
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2013-08-28 11:07:23 UTC
Size:
18.65 KB
patch
obsolete
>From 0ec0d78c4d74292a6d7a00e375d47867b35c3758 Mon Sep 17 00:00:00 2001 >From: Dan Scott <dan@coffeecode.net> >Date: Thu, 22 Aug 2013 07:00:12 -0400 >Subject: [PATCH] Bug 6594: Schema.org structured data for OPAC display > >To support schema.org processors, such as Google, Bing, and Yandex, >structure our data so that it has machine-readable attributes. This pass >declares the CreativeWork sub-types as well as Product for the main >bibliographic record details, and uses the Offer type for holdings >information per the W3C Schema Bib Extend community group discussions. > >Signed-off-by: Dan Scott <dan@coffeecode.net> >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >Comments on final patch. > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > .../prog/en/includes/item-status-schema-org.inc | 11 ++++ > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 18 +++--- > .../prog/en/xslt/MARC21slim2OPACDetail.xsl | 71 +++++++++++++++++----- > 3 files changed, 78 insertions(+), 22 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/item-status-schema-org.inc > >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/item-status-schema-org.inc b/koha-tmpl/opac-tmpl/prog/en/includes/item-status-schema-org.inc >new file mode 100644 >index 0000000..6f1acc8 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/item-status-schema-org.inc >@@ -0,0 +1,11 @@ >+[% USE KohaAuthorisedValues %] >+ >+[% IF ( item.damaged or item.datedue or item.itemlost or item.transfertwhen or item.waiting ) %] >+ <link property="availability" href="http://schema.org/OutOfStock" /> >+[% ELSIF ( item.wthdrawn ) %] >+ <link property="availability" href="http://schema.org/Discontinued" /> >+[% ELSIF ( item.itemnotforloan or item.notforloan_per_itemtype ) %] >+ <link property="availability" href="http://schema.org/InStoreOnly" /> >+[% ELSE %] >+ <link property="availability" href="http://schema.org/InStock" /> >+[% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index 77a62f0..cc05199 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -1511,9 +1511,11 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% IF ( ShowCourseReservesHeader ) %]<th id="item_coursereserves">Course reserves</th>[% END %] > </tr></thead> > <tbody>[% FOREACH ITEM_RESULT IN items %] >- [% IF ITEM_RESULT.this_branch %]<tr class="highlight-row-detail">[% ELSE %]<tr>[% END %] >+ <tr[% IF ITEM_RESULT.this_branch %] class="highlight-row-detail"[% END %] vocab="http://schema.org/" typeof="Offer"> > [% IF ( item_level_itypes ) %]<td class="itype">[% UNLESS ( noItemTypeImages ) %][% IF ( ITEM_RESULT.imageurl ) %]<img src="[% ITEM_RESULT.imageurl %]" title="[% ITEM_RESULT.description %]" alt="[% ITEM_RESULT.description %]" />[% END %][% END %] [% ITEM_RESULT.description %]</td>[% END %] >- <td class="location"> >+ <td class="location" property="seller"> >+ <link property="itemOffered" href="#record" /> >+ <link property="businessFunction" href="http://purl.org/goodrelations/v1#LeaseOut"> > [% UNLESS ( singleBranchMode ) %] > <div class="[% ITEM_RESULT.branch_opac_info ? 'branch-info-tooltip-trigger' : '' %]"> > [% IF ( ITEM_RESULT.branchurl ) %] >@@ -1527,23 +1529,23 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <span class="shelvingloc">[% ITEM_RESULT.location_description %]</span> > </td> > [% IF ( itemdata_ccode ) %]<td class="collection">[% ITEM_RESULT.ccode %]</td>[% END %] >- <td class="call_no">[% IF ( ITEM_RESULT.itemcallnumber ) %] [% ITEM_RESULT.itemcallnumber %][% IF ( OPACShelfBrowser ) %] (<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ITEM_RESULT.biblionumber %]&shelfbrowse_itemnumber=[% ITEM_RESULT.itemnumber %]#[% tab %]">Browse shelf</a>)[% END %][% END %]</td> >+ <td class="call_no" property="sku">[% IF ( ITEM_RESULT.itemcallnumber ) %] [% ITEM_RESULT.itemcallnumber %][% IF ( OPACShelfBrowser ) %] (<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% ITEM_RESULT.biblionumber %]&shelfbrowse_itemnumber=[% ITEM_RESULT.itemnumber %]#[% tab %]">Browse shelf</a>)[% END %][% END %]</td> > [% IF ( itemdata_enumchron ) %]<td class="vol_info">[% ITEM_RESULT.enumchron %]</td>[% END %] > [% IF ( itemdata_uri ) %]<td class="url"> > [% IF ITEM_RESULT.uri %] > [% IF trackclicks == 'track' || trackclicks == 'anonymous' %] >- <a href="/cgi-bin/koha/tracklinks.pl?uri=[% ITEM_RESULT.uri | url %]&biblionumber=[% biblionumber |url %]&itemnumber=[% ITEM_RESULT.itemnumber | url %]"> Link to resource </a> >+ <a href="/cgi-bin/koha/tracklinks.pl?uri=[% ITEM_RESULT.uri | url %]&biblionumber=[% biblionumber |url %]&itemnumber=[% ITEM_RESULT.itemnumber | url %]" property="url"> Link to resource </a> > [% ELSE %] >- <a href="[% ITEM_RESULT.uri %]">[% ITEM_RESULT.uri %]</a> >+ <a href="[% ITEM_RESULT.uri %]" property="url">[% ITEM_RESULT.uri %]</a> > [% END %] > [% END %] > </td> > [% END %] > [% IF ( itemdata_copynumber ) %]<td class="copynumber">[% ITEM_RESULT.copynumber %]</td>[% END %] >- <td class="status">[% INCLUDE 'item-status.inc' item = ITEM_RESULT %]</td> >- [% IF ( itemdata_itemnotes ) %]<td class="notes">[% ITEM_RESULT.itemnotes %]</td>[% END %] >+ <td class="status" [% INCLUDE 'item-status-schema-org.inc' item = ITEM_RESULT %]>[% INCLUDE 'item-status.inc' item = ITEM_RESULT %]</td> >+ [% IF ( itemdata_itemnotes ) %]<td class="notes" property="description">[% ITEM_RESULT.itemnotes %]</td>[% END %] > <td class="date_due"><span title="[% ITEM_RESULT.datedue %]">[% ITEM_RESULT.datedue | $KohaDates %]</span></td> >- [% IF ( OPACShowBarcode ) %]<td class="barcode">[% ITEM_RESULT.barcode %]</td>[% END %] >+ [% IF ( OPACShowBarcode ) %]<td class="barcode" property="serialNumber">[% ITEM_RESULT.barcode %]</td>[% END %] > [% IF holds_count.defined || show_priority %] > <td class="holds_count"> > [% IF holds_count.defined %] [% ITEM_RESULT.holds_count %] [% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl >index fd0eb68..f3bd0f9 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl >+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl >@@ -8,6 +8,7 @@ > exclude-result-prefixes="marc items"> > <xsl:import href="MARC21slimUtils.xsl"/> > <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/> >+ > <xsl:template match="/"> > <xsl:apply-templates/> > </xsl:template> >@@ -91,10 +92,27 @@ > </xsl:choose> > </xsl:variable> > >+ <!-- Schema.org type --> >+ <xsl:variable name="schemaOrgType"> >+ <xsl:choose> >+ <xsl:when test="$materialTypeLabel='Book'">Book</xsl:when> >+ <xsl:when test="$materialTypeLabel='Map'">Map</xsl:when> >+ <xsl:when test="$materialTypeLabel='Music'">MusicAlbum</xsl:when> >+ <xsl:otherwise>CreativeWork</xsl:otherwise> >+ </xsl:choose> >+ </xsl:variable> >+ >+ <!-- Wrapper div for our schema.org object --> >+ <xsl:element name="div"> >+ <xsl:attribute name="class">record</xsl:attribute> >+ <xsl:attribute name="vocab">http://schema.org/</xsl:attribute> >+ <xsl:attribute name="typeof"><xsl:value-of select='$schemaOrgType' /> Product</xsl:attribute> >+ <xsl:attribute name="resource">#record</xsl:attribute> >+ > <!-- Title Statement --> > <!-- Alternate Graphic Representation (MARC 880) --> > <xsl:if test="$display880"> >- <h1 class="title"> >+ <h1 class="title" property="alternativeHeadline"> > <xsl:call-template name="m880Select"> > <xsl:with-param name="basetags">245</xsl:with-param> > <xsl:with-param name="codes">abhfgknps</xsl:with-param> >@@ -103,7 +121,7 @@ > </xsl:if> > > <xsl:if test="marc:datafield[@tag=245]"> >- <h1 class="title"> >+ <h1 class="title" property="name"> > <xsl:for-each select="marc:datafield[@tag=245]"> > <xsl:call-template name="subfieldSelect"> > <xsl:with-param name="codes">a</xsl:with-param> >@@ -141,7 +159,7 @@ > </xsl:if> > <xsl:choose> > <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]"> >- <h5 class="author">by >+ <h5 class="author" property="author">by > <xsl:call-template name="showAuthor"> > <xsl:with-param name="authorfield" select="marc:datafield[@tag=100 or @tag=110 or @tag=111 or @tag=700 or @tag=710 or @tag=711]"/> > <xsl:with-param name="UseAuthoritiesForTracings" select="$UseAuthoritiesForTracings"/> >@@ -308,28 +326,38 @@ > <xsl:if test="marc:datafield[@tag=260]"> > <span class="results_summary publisher"><span class="label">Publisher: </span> > <xsl:for-each select="marc:datafield[@tag=260]"> >+ <span property="publisher" typeof="Organization"> > <xsl:if test="marc:subfield[@code='a']"> >+ <span property="location"> > <xsl:call-template name="subfieldSelect"> > <xsl:with-param name="codes">a</xsl:with-param> > </xsl:call-template> >+ </span> > </xsl:if> > <xsl:text> </xsl:text> > <xsl:if test="marc:subfield[@code='b']"> > <a href="/cgi-bin/koha/opac-search.pl?q=pb:{marc:subfield[@code='b']}"> >+ <span property="name"> > <xsl:call-template name="subfieldSelect"> > <xsl:with-param name="codes">b</xsl:with-param> > </xsl:call-template> >+ </span> > </a> > </xsl:if> >+ </span> > <xsl:text> </xsl:text> >- <xsl:call-template name="chopPunctuation"> >- <xsl:with-param name="chopString"> >- <xsl:call-template name="subfieldSelect"> >- <xsl:with-param name="codes">cg</xsl:with-param> >- </xsl:call-template> >- </xsl:with-param> >- </xsl:call-template> >- <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> >+ <xsl:if test="marc:subfield[@code='c' or @code='g']"> >+ <span property="datePublished"> >+ <xsl:call-template name="chopPunctuation"> >+ <xsl:with-param name="chopString"> >+ <xsl:call-template name="subfieldSelect"> >+ <xsl:with-param name="codes">cg</xsl:with-param> >+ </xsl:call-template> >+ </xsl:with-param> >+ </xsl:call-template> >+ </span> >+ </xsl:if> >+ <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </span> > </xsl:if> >@@ -347,6 +375,7 @@ > <xsl:if test="marc:datafield[@tag=250]"> > <span class="results_summary edition"><span class="label">Edition: </span> > <xsl:for-each select="marc:datafield[@tag=250]"> >+ <span property="bookEdition"> > <xsl:call-template name="chopPunctuation"> > <xsl:with-param name="chopString"> > <xsl:call-template name="subfieldSelect"> >@@ -354,6 +383,7 @@ > </xsl:call-template> > </xsl:with-param> > </xsl:call-template> >+ </span> > <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </span> >@@ -372,6 +402,7 @@ > <xsl:if test="marc:datafield[@tag=300]"> > <span class="results_summary description"><span class="label">Description: </span> > <xsl:for-each select="marc:datafield[@tag=300]"> >+ <span property="description"> > <xsl:call-template name="chopPunctuation"> > <xsl:with-param name="chopString"> > <xsl:call-template name="subfieldSelect"> >@@ -379,6 +410,7 @@ > </xsl:call-template> > </xsl:with-param> > </xsl:call-template> >+ </span> > <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </span> >@@ -387,9 +419,11 @@ > <xsl:if test="marc:datafield[@tag=020]"> > <span class="results_summary isbn"><span class="label">ISBN: </span> > <xsl:for-each select="marc:datafield[@tag=020]"> >+ <span property="isbn"> > <xsl:variable name="isbn" select="marc:subfield[@code='a']"/> > <xsl:value-of select="marc:subfield[@code='a']"/> > <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> >+ </span> > </xsl:for-each> > </span> > </xsl:if> >@@ -441,6 +475,7 @@ > <xsl:if test="marc:datafield[@tag=246]"> > <span class="results_summary other_title"><span class="label">Other title: </span> > <xsl:for-each select="marc:datafield[@tag=246]"> >+ <span property="alternativeHeadline"> > <xsl:call-template name="chopPunctuation"> > <xsl:with-param name="chopString"> > <xsl:call-template name="subfieldSelect"> >@@ -448,6 +483,7 @@ > </xsl:call-template> > </xsl:with-param> > </xsl:call-template> >+ </span> > <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </span> >@@ -457,6 +493,7 @@ > <xsl:if test="marc:datafield[@tag=242]"> > <span class="results_summary translated_title"><span class="label">Title translated: </span> > <xsl:for-each select="marc:datafield[@tag=242]"> >+ <span property="alternativeHeadline"> > <xsl:call-template name="chopPunctuation"> > <xsl:with-param name="chopString"> > <xsl:call-template name="subfieldSelect"> >@@ -464,6 +501,7 @@ > </xsl:call-template> > </xsl:with-param> > </xsl:call-template> >+ </span> > <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </span> >@@ -471,17 +509,20 @@ > > <!-- Uniform Title Statement: Alternate Graphic Representation (MARC 880) --> > <xsl:if test="$display880"> >+ <span property="alternativeHeadline"> > <xsl:call-template name="m880Select"> > <xsl:with-param name="basetags">130,240</xsl:with-param> > <xsl:with-param name="codes">adfklmor</xsl:with-param> > <xsl:with-param name="class">results_summary uniform_title</xsl:with-param> > <xsl:with-param name="label">Uniform titles: </xsl:with-param> > </xsl:call-template> >+ </span> > </xsl:if> > > <xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]"> > <span class="results_summary uniform_titles"><span class="label">Uniform titles: </span> > <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]"> >+ <span property="alternativeHeadline"> > <xsl:variable name="str"> > <xsl:for-each select="marc:subfield"> > <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))"> >@@ -496,6 +537,7 @@ > > </xsl:with-param> > </xsl:call-template> >+ </span> > <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose> > </xsl:for-each> > </span> >@@ -504,7 +546,7 @@ > <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']"> > <span class="results_summary subjects"><span class="label">Subject(s): </span> > <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']"> >- <a> >+ <a property="keywords"> > <xsl:choose> > <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'"> > <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute> >@@ -552,7 +594,7 @@ > <span class="results_summary online_resources"><span class="label">Online resources: </span> > <xsl:for-each select="marc:datafield[@tag=856]"> > <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable> >- <a> >+ <a property="url"> > <xsl:choose> > <xsl:when test="$OPACTrackClicks='track'"> > <xsl:attribute name="href">/cgi-bin/koha/tracklinks.pl?uri=<xsl:value-of select="marc:subfield[@code='u']"/>;biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute> >@@ -628,7 +670,7 @@ > </xsl:otherwise> > </xsl:choose> > </xsl:if> >- <div class='contentblock'> >+ <div class='contentblock' property='description'> > <xsl:choose> > <xsl:when test="@ind2=0"> > <xsl:call-template name="subfieldSelectSpan"> >@@ -939,6 +981,7 @@ > </xsl:for-each> > </xsl:if> > >+ </xsl:element> > </xsl:template> > > <xsl:template name="showAuthor"> >-- >1.8.4.rc2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6594
:
20566
|
20567
|
20568
|
20569
| 20697 |
20698
|
20699
|
20700