DOI resolver updated

(Jay Pfaffman) #1

I wrote a little DOI resolver that makes links to DOIs point to It’s just a single regex replace. It recognizes DOIs and adds a <a href=""> around it. It’s basically discourse-pirate-speak.

For those who don’t care about academic publishing, DOIs are unique identifiers for articles.

My next step for this extension is to add customizable regexps.

Discourse for Academic Use Features (Done and to be Done)
Beginner's Guide to Creating Discourse Plugins - Part 1
Dynamic replace string to another
Bootstrap-style labels as markdown
(Stefano Costa) #2

This is awesome and I :heart::heart::heart: to see features that make Discourse more palatable to academic communities.

A few weeks ago CrossRef published a revised presentation standard for DOI URLs

Basically, DOIs become full featured URLs

(Jay Pfaffman) #3

Well, that would obviate the need for my plugin. I’m sure it’ll be some time before the APA embraces making all DOIs urls, though. Maybe I’ll go ahead and fix it this week anyway.

(Jay Pfaffman) #4

Well, it now works again.

I added siteSettings configuration variables, but couldn’t figure out how to honor them.

Maybe another day.

(Christoph) #5

The plugin currently breaks in line links like [this one] (Organizing Spaces: Meeting Arenas as a Social Movement Infrastructure between Organization, Network, and InstitutionOrganization Studies - Christoph Haug, 2013) if the url includes a doi. (Obviously, the link is not broken here on meta, but if the plugin were installed here, it would render like this

(Jay Pfaffman) #6

Darn. I’ll see about fixing that.

Wait! Someone is using this plugin!?!

(Christoph) #7

Of course! It’s great! :thumbsup:

BTW: If you have any more ideas for a plugin that might improve/facilitate referencing (academic) literature, let’s discuss it. I might even be able to spend some money on that.

(Jay Pfaffman) #8

Will do. I’m now a recovering academic, but I had a couple ideas a while back. I’ll see if I can remember them. :slight_smile:

(Jay Pfaffman) #9

Fixed! Per this commit.

You’ll need to rebake (or just rebuild html if there aren’t many of them) to have it fix posts that are already entered.

If someone could have a look at

and tell me how to make my plugin honor the site setting I created for it, I’d appreciate it.

(Christoph) #10

Jay, I’m sorry if this is a false alarm, but is it possible that your plugin is causing this error:

TypeError: Cannot read property 'addPreProcessor' of undefined

If it is, something like this may be the fix:

Deactivated plugin causes Error 500 on post
(Jay Pfaffman) #11

I’ve been thinking that it’d get broken with the new markdown engine.

Thanks for the link. I’ll have a look in a couple of days.

(Jay Pfaffman) #12

Hey, @zogstrip or @eviltrout. Does discourse-pirate-speak still work? Could you take a look at it (or discourse-doi-resolver) so that I have a super-simple model so I can figure out how to make my trivial plugin work with the new engine?

(Robin Ward) #13

I suspect that one is broken with @sam’s new markdown work. Maybe he can circle back and fix at some point?

(Jay Pfaffman) #14

You mean that in your mind there are higher priorities than the Pirate Speak plugin!?

FWIW, Talk Like a Pirate Day is Sept 19.


(Sam Saffron) #15

The regex approach is deeply flawed on quite a few levels, it is edge case central, what happens when the text is already inside a hyperlink?

I will get around to fixing it, already cloned the repo.

(Jay Pfaffman) #16

Agreed! And imagine my surprise to find that someone’s using it!

(Jay Pfaffman) #17

Since some of the plugin howtos refer to discourse-pirate-speak, you might just fix it. This was a trivial modification of that.

If memory serves, I fixed the case where it’s inside of a URL & the only problem is that it fails to replace it if the DOI is at the start of a line.

(Robert) #18

If DOIs are now URLs, should a separate plugin not depreciated in favour of a Discourse onebox based on meta data fetched from Crossref?

As an academic, I generally appreciate the idea to make DOIs work nicely in Discourse. :man_student:

(Christoph) #19

Many (most?) dois when resolved on are merely pointers to another website which means that they already being oneboxed if the target website supports it:

I used for the box above.

Those that are not forwarded are not oneboxed because doesn’t seem to support OpenGraph:

For these urls it would indeed be great to have onebox support. So the question is whether the team would consider considering as worthy of it’s own oneboxing engine…

I wouldn’t say that the oneboxing feature would/should replace the doi-resolver plugin because you’d still want that in situations where a doi is mentioned inline, e.g. in a reference.

(Robert) #20

Papers (here from Springer) format DOIs usually like this:

So I would write in the text: doi:10.1109/PTP.2004.1334951 to make clear it is a doi. Now, crossref suggest to move over to and one can imagine to drop the scheme, thus one gets This would work also inline in Discourse: Aggregating information in peer-to-peer systems for improved join and leave - IEEE Conference Publication

The plugin would allow us to have a working link for those, who are too lazy to write .org/ instead of a colon. I am not sure if it is worth is considering that the url format is much better known and supported by various pieces of software.