Fiddle-based gist forking demo with images
Demonstrate that without any server-side code, you can generate new gists and provide a fork-me link to save deltas author(s): Jason Kridner
by DiegoTc
HTML
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css">
<div id="editor"><h1><span style="color: inherit; font-family: inherit; font-size: 38.5px;">Self-forkable JSFiddle with image on gist.github.com</span></h1><h1><img...
CSS
#editor {overflow:scroll; min-height:350px;}
JavaScript
var s = function s() {
$.getScript('http://mindmup.github.io/bootstrap-wysiwyg/external/jquery.hotkeys.js', loadWysiwyg);
function loadWysiwyg() {
$.getScript('http://mindmup.github.io/bootstrap-wysiwyg/bootstrap-wysiwyg.js', enableEdit);
}
function enableEdit() {
$('#editor').wysiwyg();
}
s.testData = {
"description": "Demo of self-replicating JSFiddle on gist.github.com with an image",
"public": true,
"files": {
"fiddle.css": {
"content": '#editor {overflow:scroll; min-height:350px;}'
},
"fiddle.manifest": {
"content":
"name: Fiddle-based gist forking demo with images\n\
description: Demonstrate that without any server-side code, you can generate new gists and provide a fork-me link to save deltas\n\
authors:\n\
- Jason Kridner\n\
resources:\n\
- http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css\n\
- http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css"
}
}
};
s.dofork = function() {
var url = "https://api.github.com/gists";
s.testData.files["fiddle.html"] = {
"content": '<div id="editor">' + $('#editor').cleanHtml() + '</div>\n\
<div class="btn-toolbar" data-role="editor-toolbar" data-target="#editor">\n\
<input type="file" data-role="magic-overlay" data-edit="insertImage" />\n\
</div>\n\
<a onclick="s.dofork();" href="#">dofork</a> <a id="url"></a>'
};
console.log("Doing post of " + JSON.stringify(s.testData) + " to " + url);
$.ajax({
type: "POST",
url: url,
data: JSON.stringify(s.testData),
success: onsuccess,
dataType: "json"
}).fail(onfail);
function onsuccess(response) {
console.log('success: ' + JSON.stringify(response));
$('#url').append('<a...