[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] Open graph Tags



Hi John

That's perfect! I saw all the <meta> tags when I viewed the source and have
been trying to suss out where they're added/made. I got as far as
template_core.pl, DataObj.pm and EPrint.pm. I wasn't even close in the end.

I've taken a look at those subs you pointed out and I think I know what I
need to do, so I'll start properly on Monday. I'll report back when it does
what I want it to do...

Thanks,
James

On Fri, Mar 1, 2019 at 2:21 PM John Salter <J.Salter at leeds.ac.uk> wrote:

> Hi James,
>
> The page I linked to is useful for static pages. It also mentions 'dynamic
> pins', but doesn't really give much explanation.
>
>
>
> For abstract pages, take a look at:
>
> ~/archives/[ARCHIVEID]/cfg/cfg/eprint_render.pl, specifically (towards
> the end):
>
> my $links = $repository->xml()->create_document_fragment();
>
> if( !$preview )
>
> {
>
>     $links->appendChild( $repository->plugin( "Export::Simple"
> )->dataobj_to_html_header( $eprint ) );
>
>     $links->appendChild( $repository->plugin( "Export::DC"
> )->dataobj_to_html_header( $eprint ) );
>
> }
>
>
>
> For your purposes, the 'proper' solution would be to create an export
> format for 'TwitterCard', and implement something very similar to the
> dataobj_to_html_header methods in Export::DC or Export::Simple.
>
>
>
> Then, update the code above, regenerate an abstract to test, and hopefully
> away you go!
>
>
>
> (Then, if you get it all working, and think it might be useful to other
> EPrints sites, stick the code on GitHub, package it for the Bazaar, and
> release it! :o)
>
>
>
> Cheers,
>
> John
>
>
>
> NB Depending on what extensions you have installed in your repository, the
> 'render_eprint' function may be redefined in a later config file?
>
>
>
> *From:* James Kerwin [mailto:jkerwin2101 at gmail.com]
> *Sent:* 01 March 2019 12:27
> *To:* eprints-tech at ecs.soton.ac.uk; John Salter <J.Salter at leeds.ac.uk>
> *Subject:* Re: [EP-tech] Open graph Tags
>
>
>
> Hi John,
>
>
>
> Thanks for the tip. I've been looking at that page this morning since my
> hacky way of getting the tags to work has come back to bite me.
>
>
>
> Ultimately, I had to go to "Facebook for Developers" and clear the cache
> and "scrape" the repository again (it hadn't been done since the start of
> Feb). The reason the abstracts were working is because they had never been
> scraped so loaded up my new tags without using the cache. It appears just
> putting them in the default.xml template was enough.
>
>
>
> Now I'm having fun with "Twitter Cards" - the Twitter equivalent to og
> tags. Unfortunately, I think I need to take a step back and add these tags
> to the <head> in a different way as in each case the tags need access to
> variables such as EPrint titles, abstracts etc.
>
>
>
> I'll get there in the end.
>
>
>
> Thanks for you help,
>
> James
>
>
>
> On Thu, Feb 28, 2019 at 4:51 PM John Salter via Eprints-tech <
> eprints-tech at ecs.soton.ac.uk> wrote:
>
> Hi James,
>
> How are you including the tags in the index.xpage?
>
>
>
> If you're adding them to the <xpage:body>, then this might be useful:
>
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FAPI%3AEPrints%2FApache%2FTemplate%23Static_HTML_Pages&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C8691e8e68c72449c7e7008d69e604680%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=LQsRn8anLaCr%2BVTYE4X%2Bzmr9TX%2BGSvOhPqCOqYOwLq0%3D&amp;reserved=0
> <https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FAPI%3AEPrints%2FApache%2FTemplate%23Static_HTML_Pages&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C8691e8e68c72449c7e7008d69e604680%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=LQsRn8anLaCr%2BVTYE4X%2Bzmr9TX%2BGSvOhPqCOqYOwLq0%3D&amp;reserved=0>
>
>
>
> There's an <xpage:head> which will get added to the template in the <head>
> area - which might be what you need?
>
>
>
> Cheers,
>
> John
>
>
>
>
>
> *From:* eprints-tech-bounces at ecs.soton.ac.uk [mailto:
> eprints-tech-bounces at ecs.soton.ac.uk] *On Behalf Of *James Kerwin via
> Eprints-tech
> *Sent:* 28 February 2019 16:33
> *To:* eprints-tech at ecs.soton.ac.uk
> *Subject:* [EP-tech] Open graph Tags
>
>
>
> Hi All,
>
>
>
> Has anybody attempted to use Open Graph tags in EPrints to facilitate
> sharing links on social media?
>
>
>
> I'm attempting it now and I can get it to work on EPrint abstracts, but
> not on the repository home page. On the latter I'm getting a title
> different to my test title and an image that isn't the one I stipulate.
>
>
>
> For example, my Test versions of the og tags are:
>
>
>
> <meta property="og:title"  content="zebra"/>
>
> <meta property="og:image" content="
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.liverpool.ac.uk%2Fmedia%2Flivacuk%2Fliverpool-advantage.jpg&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C8691e8e68c72449c7e7008d69e604680%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=xPxeH8L1MdrSi%2B36mo5vnjBoFfibYJq6zVZkwvTKYis%3D&amp;reserved=0
> <https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.liverpool.ac.uk%2Fmedia%2Flivacuk%2Fliverpool-advantage.jpg&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C8691e8e68c72449c7e7008d69e604680%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=xPxeH8L1MdrSi%2B36mo5vnjBoFfibYJq6zVZkwvTKYis%3D&amp;reserved=0>
> "/>
>
>
>
> I have included these in my default.xml template. This allows the link to
> be shown with the correct title and image for abstracts. Unfortunately it
> doesn't work for the home page, so I inserted these tags into my
> index.xpage which doesn't seem to have worked either. When sharing a link
> to the home page it shows me the title of the page that exists between the
> <title></title> tags in default.xml and the first image that occurs in
> index.xpage.
>
>
>
> I've tried putting the OG tags in different places, restarting the server
> after changes and removing the previously mentioned <title></title> tags to
> see what happens and no success so I'm assuming it might be a quirk of
> EPrints? Or am I putting these in the wrong place? I appreciate it's a
> broad question as we all have different tags etc in our various files, but
> if anybody can shed any light on this I would be really grateful.
>
>
>
> When I started this earlier I thought it wouldn't take long as it's not
> particularly difficult, how wrong I was!
>
>
>
> Thanks,
>
> James
>
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C8691e8e68c72449c7e7008d69e604680%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=qxTPO8lo9CEIfskqKIW3mvZz0s6WZppYfFf8E%2BY71q4%3D&amp;reserved=0
> *** EPrints community wiki: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C8691e8e68c72449c7e7008d69e604680%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=MZkMa6ECRFyINbRb5PUrVS0Z2mZoBFazn7Hm9KJM%2BS4%3D&amp;reserved=0
> *** EPrints developers Forum: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fforum.eprints.org%2F&amp;data=01%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C8691e8e68c72449c7e7008d69e604680%7C4a5378f929f44d3ebe89669d03ada9d8%7C1&amp;sdata=9Ql1HjKWNMo1a95pVXyFwZWry%2BfgPWiQeA8M67ucIgs%3D&amp;reserved=0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20190301/a28609fa/attachment-0001.html