ShortCodes.jl to embed content from Twitter, YouTube etc in Pluto

I’m using Pluto more and more for presentations, and like to include some videos, tweets or images to spice it up a little. While using embed codes from each website works fine, I started playing around with something along the lines of the Hugo shortcodes. The result is ShortCodes.jl, which is pretty basic, but serves my current needs.

using ShortCodes

# Embed tweet by id
Twitter(1314967811626872842)

# Embed youtube video by id and seek to start time and pause 
# to show custom still image
YouTube("IAF8DjrQSSk", 2, 30) # 2 min 30 seconds

# Embed Flickr image by url
Flickr("https://www.flickr.com/photos/153311384@N03/29110717138")

# Share string, e.g. a url, with the audience of a presentation using QR code:
QRC("https://julialang.org/downloads/#current_stable_release")

As an example, the twitter embed should render something like this:

Let me know what you think, suggestions for improvements are welcome.

26 Likes

Cool stuff!

Isn’t it redundant to specify “flickr.com” for Flickr embeds?

Thanks!

Good point about Flickr, I guess since the API requires a url I just left it at that, but then so does Twitter. Perhaps the same trick could work for Flickr. I’ll have another look.

EDIT: The same trick seems to work for Flickr, did a minor update and now this should work:

2 Likes

Any plan to commit an updated version of the shortcodes.jl compatible with the current version of Pluto?

1 Like

I wasn’t aware there was a problem with newer Pluto versions. I just tried with Pluto version 0.19.19 on julia master and the first couple of things I tried worked as expected. Could you please open an issue on github with more details on any incompatibilities?

Hi!
The problem is that when I try to install ShortCode.jl using the Pkg.jl the version of Pluto is downgraded to 0.19.9. You probably need to update the github Project.toml file (?)

Oh, I see. ShortCodes.jl uses an older version of HTTP.jl, holding Pluto back. I’ve released a new version which should allow the same version as Pluto, please give it a try.

I typically don’t have ShortCodes and Pluto installed in the same environment, so I never noticed (just installing/using ShortCodes from the notebook).

1 Like

Thank you for the rapid reply!
It’s working great!

1 Like