Created
September 25, 2010 15:54
-
-
Save aribn/596981 to your computer and use it in GitHub Desktop.
Revisions
-
aribn revised this gist
Sep 26, 2010 . 1 changed file with 15 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ // To create a clone of pad CWrp961Hnw as of revision 3: // http://sketchpad.cc/sp/pad/newsketch?clonePadId=CWrp961Hnw&cloneRevNum=3 @@ -43,37 +42,29 @@ function _createIfNecessary(localPadId, pad) { var clonePadId = getQueryVariable("clonePadId"); var cloneRevNum = getQueryVariable("cloneRevNum"); var usePadId; if (isReadOnlyId(clonePadId)) { usePadId = readonlyToPadId(clonePadId); if (!pro_utils.isProDomainRequest()) { usePadId = padutils.getGlobalPadId(usePadId); } } else { usePadId = padutils.getGlobalPadId(clonePadId); } var padGlobal = usePadId; var padText = model.accessPadGlobal(usePadId, function(pad) { return pad.getRevisionText(cloneRevNum); }, 'r'); var historicalAuthorData = model.accessPadGlobal(usePadId, function(pad) { return buildHistoricalAuthorDataMapForPadHistory(pad); }, 'r'); var list = formatAuthorData(historicalAuthorData); var header = "// This sketch builds on a prior work created by " + list.join(" & ") + "\n"; var priorUrl = "// http://" + request.host + "/sp/pad/view/"+clonePadId+"/rev."+cloneRevNum + "\n\n"; pad.create(header + priorUrl + padText); return; } else { initialContent = getDefaultPadText(); -
aribn created this gist
Sep 25, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,119 @@ // To create a clone of pad CWrp961Hnw as of revision 3: // http://sketchpad.cc/sp/pad/newsketch?clonePadId=CWrp961Hnw&cloneRevNum=3 // -------------------------------------------------------------------------------- // in etherpad/src/etherpad/control/pad/pad_control.js // -------------------------------------------------------------------------------- import("etherpad.collab.collab_server.buildHistoricalAuthorDataMapForPadHistory"); function render_newsketch() { var session = getSession(); var padId; padId = randomUniquePadId(); session.instantCreate = padId; var query = ""; if (request.query && request.query != "") { query = "?"+request.query; } response.redirect("/"+padId+query); } function _createIfNecessary(localPadId, pad) { if (pad.exists()) { delete getSession().instantCreate; return; } var validPadId = padutils.makeValidLocalPadId(localPadId); if (localPadId != validPadId) { response.redirect('/'+validPadId); } if (request.params.createImmediately || getSession().instantCreate == localPadId) { var initialContent; if (request.query) { var clonePadId = getQueryVariable("clonePadId"); var cloneRevNum = getQueryVariable("cloneRevNum"); var usePadId; var usePadGlobal = false; if (isReadOnlyId(clonePadId)) { usePadId = readonlyToPadId(clonePadId); if (pro_utils.isProDomainRequest()) usePadGlobal = true; } else { usePadId = clonePadId; } if (usePadGlobal) { var padText = model.accessPadGlobal(usePadId, function(pad) { return pad.getRevisionText(cloneRevNum); }, 'r'); var historicalAuthorData = model.accessPadGlobal(usePadId, function(pad) { return buildHistoricalAuthorDataMapForPadHistory(pad); }, 'r'); } else { var padText = padutils.accessPadLocal(usePadId, function(pad) { return pad.getRevisionText(cloneRevNum); }, 'r'); var historicalAuthorData = padutils.accessPadLocal(usePadId, function(pad) { return buildHistoricalAuthorDataMapForPadHistory(pad); }, 'r'); } var list = formatAuthorData(historicalAuthorData); var header = "// This sketch builds on a prior work created by " + list.join(" & ") + "\n"; var priorUrl = "// http://" + request.host + "/sp/pad/view/"+clonePadId+"/rev."+cloneRevNum + "\n\n"; pad.create(header + priorUrl + padText); return; } else { initialContent = getDefaultPadText(); } pad.create(initialContent); delete getSession().instantCreate; return; } response.redirect("/sp/pad/create?padId="+encodeURIComponent(localPadId)); } function formatAuthorData(historicalAuthorData) { var authors_all = []; for (var author in historicalAuthorData) { var n = historicalAuthorData[author].name; authors_all[n] = (authors_all[n]) ? 1+authors_all[n] : 1; } var authors = []; for (var n in authors_all) { if (n == "undefined") { authors.push("[unnamed author]"); } else { authors.push(n); } } return authors; } function getQueryVariable(variable) { var query = request.query; var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return false; }