-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #742 from OpenGeoscience/tutorial-urls
Make a tutorial that acts as an editor
- Loading branch information
Showing
10 changed files
with
175 additions
and
60 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var exampleUtils = { | ||
/* Decode query components into a dictionary of values. | ||
* | ||
* @returns {object}: the query parameters as a dictionary. | ||
*/ | ||
getQuery: function () { | ||
var query = document.location.search.replace(/(^\?)/, '').split( | ||
'&').map(function (n) { | ||
n = n.split('='); | ||
if (n[0]) { | ||
this[decodeURIComponent(n[0].replace(/\+/g, '%20'))] = decodeURIComponent(n[1].replace(/\+/g, '%20')); | ||
} | ||
return this; | ||
}.bind({}))[0]; | ||
return query; | ||
}, | ||
|
||
/* Encode a dictionary of parameters to the query string, setting the window | ||
* location and history. This will also remove undefined values from the | ||
* set properites of params. | ||
* | ||
* @param {object} params: the query parameters as a dictionary. | ||
*/ | ||
setQuery: function (params) { | ||
$.each(params, function (key, value) { | ||
if (value === undefined) { | ||
delete params[key]; | ||
} | ||
}); | ||
var newurl = window.location.protocol + '//' + window.location.host + | ||
window.location.pathname + '?' + $.param(params); | ||
window.history.replaceState(params, '', newurl); | ||
} | ||
}; | ||
|
||
module.exports = exampleUtils; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ block mainTutorial | |
height: 100%; | ||
padding: 0; | ||
margin: 0; | ||
overflow: hidden; | ||
} | ||
|
||
:markdown-it | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* global start_tutorial */ | ||
|
||
$(function () { | ||
/* start_tutorial has to be called explicitly when we are ready since we need | ||
* to ask it to always keep url changes. */ | ||
start_tutorial(undefined, true); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends ../common/index.pug | ||
|
||
block mainTutorial | ||
:markdown-it | ||
# Editor | ||
Any changes made will be stored in the URL whenever the code is run. This can be sent as a link, bookmarked, or otherwise shared. | ||
|
||
You can interact with the code through the javascript console by accessing the top-level variables in the `tutorial` global parameter. | ||
|
||
+codeblock('javascript', 1, undefined, true). | ||
var map = geo.map({ | ||
node: "#map", | ||
center: {x: 4.90, y: 52.37}, | ||
zoom: 14 | ||
}); | ||
var layer = map.createLayer('osm'); | ||
+codeblock_test('map has one osm layer from openstreetmap', [ | ||
'map.layers().length === 1', | ||
'map.layers()[0] instanceof geo.osmLayer', | ||
'layer.url().match(/openstreetmap/)' | ||
]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"title": "Editor", | ||
"hideNavbar": true, | ||
"level": 10, | ||
"tutorialJs": ["editor.js"], | ||
"about": { | ||
"text": "Edit and save work in URL." | ||
} | ||
} |