diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index ead39ec5e..922acd875 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -271,12 +271,23 @@ Embedding = , key: 'Gist' regExp: /^\w+:\/\/gist\.github\.com\/[\w\-]+\/(\w+)/ - el: (a) -> - el = $.el 'iframe' - el.setAttribute 'sandbox', 'allow-scripts' - content = <%= html('${a.dataset.uid}') %> - el.src = E.url content - el + style: '' + el: do -> + counter = 0 + (a) -> + el = $.el 'pre', + hidden: true + id: "gist-embed-#{counter++}" + $.ajax "https://api.github.com/gists/#{a.dataset.uid}", + responseType: 'json' + onload: -> + el.textContent = Object.values(@response.files)[0].content + el.className = 'prettyprint' + $.global -> + window.prettyPrint? (() ->), document.getElementById(document.currentScript.dataset.id).parentNode + , id: el.id + el.hidden = false + el title: api: (uid) -> "https://api.github.com/gists/#{uid}" text: ({files}) -> diff --git a/src/globals/globals.js b/src/globals/globals.js index c9e91136b..993d572f1 100644 --- a/src/globals/globals.js +++ b/src/globals/globals.js @@ -43,7 +43,3 @@ E.cat = function(templates) { } return html; }; - -E.url = function(content) { - return "data:text/html;charset=utf-8," + encodeURIComponent(content.innerHTML); -};