An enzyme for transcluding a web page

2018-06-14: This post was very different when I first published it, many years ago. Time goes by, and IFRAME is no longer that good an option when websites can specify new headers like X-Frame-Options. Meanwhile, I also had to deactivate my Enzymes plugin and only keep my newer Nzymes plugin active. Confronted with the alternative to leave this here as a useless contribution to mankind, I opted for changing the examples while keeping their original spirit instead.

Enzymes Nzymes can be complex PHP scripts, but basic enzymes are also very useful. These allow to transclude some web content into a post. Enzymes Nzymes makes it easy to do it over and over, without having to remember: “how did I do it?”

This is got by the statement {[.show-image()]}:

This is got by the statement {[.show-quote()]}:

show-image:

return "<img src='https://picsum.photos/200/300/?random' />";

show-quote:

$response = file_get_contents('https://random-quote-generator.herokuapp.com/api/quotes/random');
$decoded = json_decode($response, TRUE);
$quote = htmlspecialchars($decoded['quote']);
$author = htmlspecialchars($decoded['author']);
return "<span>$quote (by $author)</span>";

Easy, isn’t it?

TinyMCE extended

This is great! I always wondered why this TinyMCE editor in WordPress is so poor, but when you go to their web site you see many many useful buttons. Finally there is a simple way to extend the default toolbar.

The thing I probably missed most was the U button. In fact I use to render underlined text with a maroon color by means of the WordPress stylesheet. I always had to add the markup manually, and in WordPress 2.1 it got trickier because I had to make a Visual-Code-Visual roundtrip, due to the escaping facility added to the Visual side.

Goon 1.0 Released Today

Goon is a JavaScript tool for DOM-based on-demand script loading

Features

  • Independent
    Goon is a selfcontained script, no external library needed
  • Short
    Goon is less than 2 KB (packed)
  • Rigorous
    Goon guarantees that required scripts are executed before the requiring script is executed
  • Clean
    Goon is tree oriented. Each gooned script is a node: if it’s not required by another node, then it’s a root, and if it’s not requiring any node, then it’s a leaf. Loading goes from root to leaves, while execution goes the other way around.
  • Easy
    Goon’s nodes are calls to the Goon() function, nodes’ results are available as entries of the goon repository, and the last tree’s result by means of the goony shortcut
  • Elegant
    Goon provides a simple environment, where a node can access imported results by means of this, and export its own results by means of return
  • Flexible
    Goon can load the same node many times in the same tree and its behavior can be tailored by specifying how each script is required: in link mode, in exec mode, or in redo mode
  • Flexible
    Goon’s nodes can be used as roots for their subtrees, without any modification, simply by loading them directly from a page
  • Flexible
    Gooned pages can load all the needed trees, each with its own root, and they can be completely independent or grafted
  • Flexible
    Goon’s loading trees can be transplanted between hosts, for example from localhost to a deployment host, by changing the query string used for loading Goon itself

Files