paint-brush
ScalaFiddle comes to Mediumby@otto.chrons

ScalaFiddle comes to Medium

by Otto ChronsJune 13th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

One of the main design goals for <a href="https://scalafiddle.io">ScalaFiddle</a> is to make embedding your fiddles easy. Embedding has always been possible through the use of iframes from the very beginning, but today ScalaFiddle introduces support for directly embedding fiddles via&nbsp;<a href="https://embed.ly">embed.ly</a>

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - ScalaFiddle comes to Medium
Otto Chrons HackerNoon profile picture

One of the main design goals for ScalaFiddle is to make embedding your fiddles easy. Embedding has always been possible through the use of iframes from the very beginning, but today ScalaFiddle introduces support for directly embedding fiddles via embed.ly

To embed a fiddle on platforms using Embedly (like Medium), simply add a link to your fiddle and the service will take care of the rest. Click Run to see what the fiddle code below does!

<a href="https://medium.com/media/dc622d8cad83ea508742de0ea78bbfb2/href">https://medium.com/media/dc622d8cad83ea508742de0ea78bbfb2/href</a>

By default the embedded fiddle will provide interactivity, allowing the reader to run and modify the code. If you just want to provide a static version of the fiddle, with links back to ScalaFiddle, add ?static=true to the URL.

<a href="https://medium.com/media/03fc3c4a60c4d0e414f22ff7c5baa835/href">https://medium.com/media/03fc3c4a60c4d0e414f22ff7c5baa835/href</a>

Use these new embedding features to share interactive code snippets in your blog posts or documentation, to make them more interesting to the readers.

Under the hood

ScalaFiddle exposes these embedding features through two oembed endpoints at https://scalafiddle.io/oembed.json and https://scalafiddle.io/oembedstatic.json. As the name implies the latter endpoint always provides the static view and the former an interactive one (which you can override with the static=true parameter). If you have a publishing platform with oembed support, you can use these endpoints to provide automatic embedding of fiddles. ScalaFiddle also exposes the static endpoint as a meta tag in the header of every fiddle page, which may enable even more automatic embedding.

Next steps

In addition to Embedly, ScalaFiddle will soon also support Iframely, another embed provider. Through Iframely we can reach even more platforms, including chat services like Gitter.

ScalaFiddle is Open Source Software and its source code can be found in Github.