24

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.

  • 2
    It might be good if we had a tentative design for the preview, showing the data we want to be shown. – Manishearth Apr 25 '14 at 16:50
  • 2
    Man, that'd be really great. I'm linking to arxiv articles all the time in chat. – Jonathan Beardsley Apr 25 '14 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 Apr 26 '14 at 4:44
  • Another meta question about arXiv.org. – Qmechanic Dec 12 '14 at 13:04
6

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='http://i.stack.imgur.com/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 .