mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 01:10: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!
|
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
|
### 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:
|
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, ',
|
'beginner, just go ahead and start with the first. If you already know some Git basics, ',
|
||||||
'try some of our later more challenging levels.',
|
'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?',
|
'PS: Want to go straight to a sandbox next time?',
|
||||||
'Try out ',
|
'Try out ',
|
||||||
'[this special link](http://pcottle.github.io/learnGitBranching/?NODEMO)'
|
'[this special link](http://pcottle.github.io/learnGitBranching/?NODEMO)'
|
||||||
|
|
|
@ -125,7 +125,8 @@ var regexMap = {
|
||||||
'importLevelNow': /^importLevelNow($|\s)/,
|
'importLevelNow': /^importLevelNow($|\s)/,
|
||||||
'import tree': /^import +tree$/,
|
'import tree': /^import +tree$/,
|
||||||
'import level': /^import +level$/,
|
'import level': /^import +level$/,
|
||||||
'undo': /^undo($|\s)/
|
'undo': /^undo($|\s)/,
|
||||||
|
'share permalink': /^share( +permalink)?$/
|
||||||
};
|
};
|
||||||
|
|
||||||
var getAllCommands = function() {
|
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) {
|
resetSolved: function(command, deferred) {
|
||||||
LevelActions.resetLevelsSolved();
|
LevelActions.resetLevelsSolved();
|
||||||
command.addWarning(
|
command.addWarning(
|
||||||
|
@ -253,6 +263,7 @@ var Sandbox = Backbone.View.extend({
|
||||||
'importTreeNow': this.importTreeNow,
|
'importTreeNow': this.importTreeNow,
|
||||||
'import level': this.importLevel,
|
'import level': this.importLevel,
|
||||||
'importLevelNow': this.importLevelNow,
|
'importLevelNow': this.importLevelNow,
|
||||||
|
'share permalink': this.sharePermalink,
|
||||||
};
|
};
|
||||||
|
|
||||||
var method = commandMap[command.get('method')];
|
var method = commandMap[command.get('method')];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue