Twitter cards and open graph in page-structure.xsl

44 views
Skip to first unread message

Fitchett, Deborah

unread,
Feb 11, 2020, 5:22:58 PM2/11/20
to dspac...@googlegroups.com

Kia ora koutou,

 

Has anyone played around with Twitter cards and/or Open Graph with Dspace? The goal being that, if someone tweets a link to an item in the repository, Twitter (or Facebook or whoever) automatically displays a little preview of the item’s title, thumbnail etc. This seems likely to improve click-throughs/engagement.

 

I’ve edited page-structure.xsl (we’re on XMLUI, Mirage2) to get some basic metadata in – following the Google Scholar Metadata section:

                                                <!-- Add Open Graph tags for appearance on social media -->

                                                <meta property="og:type" content="article"/>

                                                <meta property="og:site_name" content="Research@Lincoln"/>

                                                <meta property="og:image" content="https://ltl.lincoln.ac.nz/wp-content/uploads/sites/20/2020/01/lincoln.png"/>

                                                <xsl:for-each select="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element = 'title']">

                                                                <meta property="og:title" content="{.}"/>

                                                </xsl:for-each>

                                                <xsl:for-each select="/dri:document/dri:meta/dri:pageMeta/dri:metadata[@element = 'identifier']">

                                                                <meta property="og:url" content="https://hdl.handle.net/{.}"/>

                                                </xsl:for-each>

Which experiments on Twitter show works! J

 

But note the image is a static logo, and I haven’t managed to get a description in. This content doesn’t appear to be included in the dri structure – except that dcterms.abstract is buried in the xhtml_head_item which is a giant blob-thing of xml as text so I can’t reach into it (unless maybe I play with substrings). Is there any other way to get at the abstract here?

 

And is there a way to access the mets data from page-structure.xsl? (If so, I should be able to get the item’s thumbnail to use for the image.) We have in item-view.xsl and I don’t see why it wouldn’t be accessible from page-structure.xsl, but maybe that shows how much I know. In any case so far all my trial-and-error messing around trying to access it has resulted in errors.

 

Ngā mihi,

 

Deborah

––––––––––––––––––––––––––––––––––

Deborah Fitchett

Head of Department: Digital Services

 

––––––––––––––––––––––––––––––––––

Library, Teaching and Learning – Te Wharepūrākau

PO Box 85064, Lincoln University

Lincoln 7647, Christchurch, New Zealand

+64 3 423 0358

deborah....@lincoln.ac.nz

ltl.lincoln.ac.nz

 

––––––––––––––––––––––––––––––––––

Lincoln University

Te Whare Wānaka o Aoraki

––––––––––––––––––––––––––––––––––

 

 




"The contents of this e-mail (including any attachments) may be confidential and/or subject to copyright. Any unauthorised use, distribution, or copying of the contents is expressly prohibited. If you have received this e-mail in error, please advise the sender by return e-mail or telephone and then delete this e-mail together with all attachments from your system."

Alan Orth

unread,
Feb 20, 2020, 5:38:45 AM2/20/20
to Fitchett, Deborah, dspac...@googlegroups.com
Dear Deborah,

This is a fantastic idea! I don't know why I never thought of it. Your work is a great starting point... I will play with it some more and keep testing in the Twitter Card validator to see how it looks:


It would be great to get a high-quality thumbnail and a description.

Thanks!

--
All messages to this mailing list should adhere to the DuraSpace Code of Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/SYCPR01MB475232A846F2EC2145DBA051C5180%40SYCPR01MB4752.ausprd01.prod.outlook.com.


--

Fitchett, Deborah

unread,
Feb 20, 2020, 3:21:00 PM2/20/20
to Alan Orth, dspac...@googlegroups.com

Thanks! Do let me know if you figure out a way to get at the thumbnail and/or abstract data.

 

Note, as far as I can tell the Twitter Card validator only works if there’s an actual twitter:card tag, which I haven’t included in my code below; but the card seems to display on Twitter without it.

 

It also works on LinkedIn – except that they’ve got a minimum image size requirement [https://www.linkedin.com/help/linkedin/answer/46687/making-your-website-shareable-on-linkedin?lang=en], so a mere logo isn’t displayed.

 

I haven’t yet tested Facebook.

 

Deborah

Reply all
Reply to author
Forward
0 new messages