Created
September 18, 2021 15:46
-
-
Save rogeruiz/5505d0c39f50ba6e5eef73289d3352ec to your computer and use it in GitHub Desktop.
Some JavaScript to create inline updates to command documentation
This file contains 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 characters
BlogPage.prototype.repo_migration_form_on_change = function() { | |
var ___iced_passed_deferral, | |
__iced_deferrals, | |
__iced_k; | |
__iced_k = __iced_k_noop; | |
___iced_passed_deferral = iced.findDeferral(arguments); | |
this.cleanse_repo_inputs(); | |
this.make_repo_migration(); | |
$("#repo-migration-extras").slideDown(); | |
$(".myteam-2nd").text($("#repo-teamname").val()); | |
if (!this.checked_repo_username) { | |
this.checked_repo_username = true; | |
(function(_this) { | |
return function(__iced_k) { | |
__iced_deferrals = new iced.Deferrals(__iced_k, { | |
parent: ___iced_passed_deferral, | |
funcname: "BlogPage.repo_migration_form_on_change" | |
}); | |
$.get("/_/api/1.0/sesscheck.json", (function(data) { | |
var u; | |
if ((u = data != null ? data.username : void 0) != null) { | |
$("#repo-username").val(u); | |
return _this.repo_migration_form_on_change() | |
} | |
})); | |
__iced_deferrals._fulfill() | |
} | |
})(this)(__iced_k) | |
} else { | |
return __iced_k() | |
} | |
}; | |
BlogPage.prototype.cleanse_repo_inputs = function() { | |
var replace_if_bad; | |
replace_if_bad = function(sel, replace_rxx) { | |
var correct_v, | |
old_v; | |
old_v = $(sel).val(); | |
correct_v = old_v.replace(replace_rxx, ""); | |
if (old_v !== correct_v) { | |
return $(sel).val(correct_v) | |
} | |
}; | |
replace_if_bad("#old-repo-path", /[^a-z0-9:\/\/@\-\_\.~]/gi); | |
replace_if_bad("#new-repo-name", /[^a-z0-9\-\_\.]/gi); | |
replace_if_bad("#repo-teamname", /[^a-z0-9\-\_\.]/gi); | |
return replace_if_bad("#repo-username", /[^a-z0-9\-\_\.]/gi) | |
}; | |
BlogPage.prototype.make_repo_migration = function() { | |
var is_team, | |
new_repo_name, | |
old_repo_path, | |
teamname, | |
username; | |
old_repo_path = $("#old-repo-path").val(); | |
new_repo_name = $("#new-repo-name").val(); | |
is_team = $("#team-repo-checkbox").is(":checked"); | |
if (is_team) { | |
$("#repo-teamname-wrapper").show(); | |
$("#repo-username-wrapper").hide() | |
} else { | |
$("#repo-teamname-wrapper").hide(); | |
$("#repo-username-wrapper").show() | |
} | |
teamname = is_team ? $("#repo-teamname").val() : null; | |
username = is_team ? null : $("#repo-username").val(); | |
return $("#repo-migration-output").html(this.generate_repo_migration_str({ | |
old_repo_path: old_repo_path, | |
new_repo_name: new_repo_name, | |
teamname: teamname, | |
username: username | |
})) | |
}; | |
BlogPage.prototype.generate_repo_migration_str = function(_arg) { | |
var new_repo_name, | |
new_repo_path, | |
old_repo_path, | |
team_extra, | |
teamname, | |
tmp_path, | |
username; | |
old_repo_path = _arg.old_repo_path, | |
new_repo_name = _arg.new_repo_name, | |
teamname = _arg.teamname, | |
username = _arg.username; | |
tmp_path = "_tmp.git"; | |
new_repo_path = teamname != null ? "keybase://team/" + teamname + "/" + new_repo_name : "keybase://private/" + username + "/" + new_repo_name; | |
team_extra = teamname ? " --team=" + teamname : ""; | |
return '<pre><code class="lang-bash"><span class="hljs-comment"># 1. make the encrypted remote repo\n</span><span class="hljs-built_in">keybase git</span> create ' + new_repo_name + team_extra + '\n\n<span class="hljs-comment"># 2. get your old stuff into a temp directory\n</span><span class="hljs-built_in">git</span> clone --mirror ' + old_repo_path + " " + tmp_path + '\n\n<span class="hljs-comment"># 3. head north of the wall\n</span><span class="hljs-built_in">cd</span> ' + tmp_path + '\n\n<span class="hljs-comment"># 4. push onward, to Craster\'s keep\n</span><span class="hljs-built_in">git push</span> --mirror <span class="hljs-string">' + new_repo_path + '</span>\n\n<span class="hljs-comment"># 5. back to Winterfell; kill some boltons\n</span><span class="hljs-built_in">cd</span> .. && <span class="hljs-built_in">rm</span> -rf ' + tmp_path + '\n\n<span class="hljs-comment"># 6. DONE. You can clone anywhere and find this repo in the Keybase app\n</span><span class="hljs-built_in">git clone</span> <span class="hljs-string">' + new_repo_path + "</span>\n</code></pre>" | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copied from this file and this example.