mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 17:00:04 +02:00
Solves #451 explain permalink and import tree now, and add command
This commit is contained in:
parent
f872840544
commit
c1854a0d96
4 changed files with 19 additions and 1 deletions
|
@ -31,6 +31,10 @@ Type `levels` to see the available lessons / challenges (and which ones you have
|
|||
|
||||
For some added fun, there is a "git golf" concept where we keep track of how many commands you use to solve each level. See if you can match all of our records!
|
||||
|
||||
### Sharing permalinks
|
||||
|
||||
You can share a link to LearnGitBranching with an arbitrary set of commands that will execute upon load by using the `commmand` URL parameter. You will also likely want to disable the intro dialog for this case with the `NODEMO` url param; here is [an example](https://learngitbranching.js.org/?NODEMO&command=echo%20%22hello%22;%20git%20commit) to get started.
|
||||
|
||||
### Level Builder
|
||||
|
||||
You can build levels with `build level`. The dialog will walk you through the process, and at the end you can `export level` to get a JSON blob. Paste that in a gist or directly into an issue and I can check it out / merge in your changes! You can also share this level directly with friends by having them run "import level" or simply specify a gist ID in the url params like so:
|
||||
|
|
|
@ -14,6 +14,8 @@ exports.dialog = {
|
|||
'beginner, just go ahead and start with the first. If you already know some Git basics, ',
|
||||
'try some of our later more challenging levels.',
|
||||
'',
|
||||
'You can see all the commands available with `show commands` at the terminal.',
|
||||
'',
|
||||
'PS: Want to go straight to a sandbox next time?',
|
||||
'Try out ',
|
||||
'[this special link](http://pcottle.github.io/learnGitBranching/?NODEMO)'
|
||||
|
|
|
@ -125,7 +125,8 @@ var regexMap = {
|
|||
'importLevelNow': /^importLevelNow($|\s)/,
|
||||
'import tree': /^import +tree$/,
|
||||
'import level': /^import +level$/,
|
||||
'undo': /^undo($|\s)/
|
||||
'undo': /^undo($|\s)/,
|
||||
'share permalink': /^share( +permalink)?$/
|
||||
};
|
||||
|
||||
var getAllCommands = function() {
|
||||
|
|
|
@ -223,6 +223,16 @@ var Sandbox = Backbone.View.extend({
|
|||
});
|
||||
},
|
||||
|
||||
sharePermalink: function(command, deferred) {
|
||||
var treeJSON = JSON.stringify(this.mainVis.gitEngine.exportTree());
|
||||
var url =
|
||||
'https://learngitbranching.js.org/?NODEMO&command=importTreeNow%20' + escape(treeJSON);
|
||||
command.setResult(
|
||||
intl.todo('Here is a link to the current state of the tree: ') + url
|
||||
);
|
||||
command.finishWith(deferred);
|
||||
},
|
||||
|
||||
resetSolved: function(command, deferred) {
|
||||
LevelActions.resetLevelsSolved();
|
||||
command.addWarning(
|
||||
|
@ -253,6 +263,7 @@ var Sandbox = Backbone.View.extend({
|
|||
'importTreeNow': this.importTreeNow,
|
||||
'import level': this.importLevel,
|
||||
'importLevelNow': this.importLevelNow,
|
||||
'share permalink': this.sharePermalink,
|
||||
};
|
||||
|
||||
var method = commandMap[command.get('method')];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue