25

SE chat has a support for oneboxing non-SE links like Wikipedia,

Screenshot of oneboxed Wikipedia link in chat

I was hoping that this support could be extended to arXiv.

For those that are not familiar with arXiv, it is a website/service that hosts pre-print editions of articles in Physics, Mathematics, Computer Science, Quantitative Biology, Quantitative Finance and Statistics. I am occasionally linking to arXiv preprints into chat when I find particularly interesting articles (e.g., The Nature of Scientific Proof in the Age of Simulations) or when someone is asking about a particular research topic.

Is it possible to have arXiv articles oneboxed in chat?

For example, I would think that the Title, author, & abstract should be pulled in for the preview:

Mockup of arXiv onebox

Note that the X image on the left is taken from the Android app.

4
  • 2
    It might be good if we had a tentative design for the preview, showing the data we want to be shown. Commented Apr 25, 2014 at 16:50
  • 2
    Man, that'd be really great. I'm linking to arxiv articles all the time in chat. Commented Apr 25, 2014 at 17:48
  • I personally find the iOS app's color scheme a bit less... sinister. Strange that the arxiv itself doesn't seem to have any concise logo.
    – user206562
    Commented Apr 26, 2014 at 4:44
  • 1
    Another meta question about arXiv.org: Trackbacks from SE to the arXiv.org?
    – Qmechanic
    Commented Dec 12, 2014 at 13:04

1 Answer 1

8

I've made a 'plugin' for this to be used with my custom onebox userscript at Stack Apps. It uses the arXiv API to get the title, author and abstract. The logo is from the Android app.

The end onebox:

enter image description here

It works for both links to the PDFs or just the abstract page

You can install the custom onebox userscript from GitHub

All you need to do then is paste the below code (or 'plugin') at the top of the file, before the --------------------------------------------------------

customSites['arxiv.org'] = function(link, $obj) {
    $('head').append('<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/shu8/SE-Chat-Custom-Oneboxes/master/arxiv.css">');
    var id = link.split('/')[4];
    if (id.indexOf('pdf') > -1) {
        id = id.replace('.pdf', '');
    }
    $.get("http://export.arxiv.org/api/query?search_query="+id, function(d) {
        var $xml = $(d);
        console.log($xml);
        var title = $xml.find('entry title').text();
        var author = $xml.find('entry author').text();
        var summary = $xml.find('entry summary').text();
        var url = $xml.find('entry link[type="text/html"]');
        
        var template = "<div class='arxiv-container'> \
                            <img src='https://i.sstatic.net/0h65A.jpg' /> \
                            <div class='title'><a href='"+url+"'>"+title+"</a></div> \
                            <div class='author'>"+author+"</div> \
                            <div class='desc'>"+summary+"</div> \
                        </div>";
        $obj.html(template);
    });    
};

This would, of course, be best if implemented by SE themselves because then it doesn't require extra installation, but I think it'll do for now! ;)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .