Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions resources/gorilla-repl-client/js-viewer/ipfs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* This file is part of gorilla-repl. Copyright (C) 2014-, Jony Hudson.
*
* gorilla-repl is licenced to you under the MIT licence. See the file LICENCE.txt for full details.
*/

var getFromIpfs = function (hash, callback) {
$.get("http://gateway.ipfs.io/ipfs/" + hash, callback);
};

var getFromIpns = function (hash, callback) {
$.get("http://gateway.ipfs.io/ipns/" + hash, callback);
};
23 changes: 17 additions & 6 deletions resources/gorilla-repl-client/js-viewer/main-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ var app = function () {
self.copyBoxVisible(false);
};

self.start = function (worksheetData, sourceURL, worksheetName, source) {
self.start = function (worksheetData, sourceURL, worksheetName, host) {

var ws = worksheet();
ws.segments = ko.observableArray(worksheetParser.parse(worksheetData));
self.worksheet(ws);
self.sourceURL(sourceURL);
self.filename(worksheetName);
self.source(source);
self.host((source.toLowerCase() === "bitbucket") ? "Bitbucket" : "GitHub");
self.host(host);

// wire up the UI
ko.applyBindings(self, document.getElementById("document"));
Expand Down Expand Up @@ -64,14 +63,14 @@ $(function () {
var repo = getParameterByName("repo");
var path = getParameterByName("path");
getFromGithub(user, repo, path, function (data) {
viewer.start(data, "https://github.com/" + user + "/" + repo, path, source);
viewer.start(data, "https://github.com/" + user + "/" + repo, path, "GitHub");
});
return;
case "gist":
var id = getParameterByName("id");
var filename = getParameterByName("filename");
getFromGist(id, filename, function (data) {
viewer.start(data, "https://gist.github.com/" + id, filename, source);
viewer.start(data, "https://gist.github.com/" + id, filename, "GitHub");
});
return;
case "bitbucket":
Expand All @@ -80,7 +79,19 @@ $(function () {
var path = getParameterByName("path");
var revision = getParameterByName("revision") || "HEAD";
getFromBitbucket(user, repo, path, revision, function (data) {
viewer.start(data, "https://bitbucket.org/" + user + "/" + repo, path, source);
viewer.start(data, "https://bitbucket.org/" + user + "/" + repo, path, "Bitbucket");
});
return;
case "ipfs":
var hash = getParameterByName("hash");
getFromIpfs(hash, function(data) {
viewer.start(data, "http://gateway.ipfs.io/ipfs/" + hash, hash, "IPFS");
});
return;
case "ipns":
var hash = getParameterByName("hash");
getFromIpns(hash, function(data) {
viewer.start(data, "http://gateway.ipfs.io/ipns/" + hash, hash, "IPFS");
});
return;
case "test":
Expand Down
1 change: 1 addition & 0 deletions resources/gorilla-repl-client/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<script type="text/javascript" src="js-viewer/worksheet-viewer.js"></script>
<script type="text/javascript" src="js-viewer/github.js"></script>
<script type="text/javascript" src="js-viewer/bitbucket.js"></script>
<script type="text/javascript" src="js-viewer/ipfs.js"></script>
<script type="text/javascript" src="js-viewer/main-viewer.js"></script>

<title data-bind="text: title">Gorilla REPL viewer</title>
Expand Down