https://github.com/liatemplates/explaingit
Port of ExplainGit to LiaScript for enabling interactive git courses
https://github.com/liatemplates/explaingit
git liascript liascript-template markdown oer
Last synced: 7 months ago
JSON representation
Port of ExplainGit to LiaScript for enabling interactive git courses
- Host: GitHub
- URL: https://github.com/liatemplates/explaingit
- Owner: LiaTemplates
- License: gpl-3.0
- Created: 2020-03-26T13:03:42.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-14T09:19:59.000Z (almost 6 years ago)
- Last Synced: 2025-03-17T06:22:03.634Z (12 months ago)
- Topics: git, liascript, liascript-template, markdown, oer
- Language: JavaScript
- Homepage: https://liascript.github.io/course/?https://github.com/liaTemplates/ExplainGit
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## ExplainGit for LiaScript
Implementation of __ExplainGit with D3__ for LiaScript
[Original Source Code](https://github.com/onlywei/explain-git-with-d3)
[Original Website](https://onlywei.github.io/explain-git-with-d3/)
[LiaScript Page](https://liascript.github.io/course/?https://github.com/liaTemplates/ExplainGit)
There are three ways to use this template. The easiest way is to use the
`import` statement and the URL of the raw text-file of the master branch or any
other branch or version. But you can also copy the required functionality
directly into the header of your Markdown document, see therefor the
[Implementation](#Implementation). And of course, you could also clone this
project and change it, as you wish.
1. Load the macros via
`import: https://github.com/liaTemplates/ExplainGit/master/README.md`
2. Copy the definitions into your Project
3. Clone this repository on GitHub
## `@ExplainGit`
You can use the `@ExplainGit` macro to create a blank repository with only one
initial commit.
@ExplainGit
## `@ExplainGit.eval`
Or you can use the `@ExplainGit.eval` macro for preconfiguring your repository
with git commands.
You can use `create origin` to enable the remote origin. A big issue is that the used framework doesn't support branches in the
remote origin!
__Example:__
```` markdown
``` text @ExplainGit.eval
git commit
git commit -m Hello World
git branch dev
git checkout dev
git commit -m dev commit
git checkout master
git commit -m master commit
```
````
This code generates the repository below.
``` text @ExplainGit.eval
git commit
git commit -m Hello World
git branch dev
git checkout dev
git commit -m dev commit
git checkout master
git commit -m master commit
```
## Implementation
````` html
@ExplainGit: @ExplainGit._eval_(@uid, )
@ExplainGit.eval: @ExplainGit._eval_(@uid,```@0```)
@ExplainGit._eval_
function git(input) {
if (window.git) {
let srcdoc = window.git.replace("var cmds = \"\";", "var cmds = \"" + input + "\";")
let frame = document.getElementById("eval_@0");
frame.srcdoc = srcdoc
} else {
setTimeout(function(){git(input)}, 100)
}
}
git(`@1`.replace(/\n/g, "|").trim())
@end
@onload
window.git = `
Implementation of explaingit with d3 for LiaScript
var cmds = "";
if(cmds) {
explainGit.reset();
const gitHubJson = {
name: 'Zen',
height: '100%',
commitData: [
{id: 'e137e9b', tags: ['master'], message: 'first commit'}
],
initialMessage: "",
cmds: cmds.split("|").filter(cmd => cmd !== "" && cmd !== "create origin")
};
if(cmds.includes("create origin")) {
gitHubJson["originData"] = [{id: 'e137e9b', tags: ['master'], message: 'first commit'}]
}
explainGit.open(gitHubJson);
} else {
explainGit.reset();
explainGit.open({
name: 'Zen',
height: '100%',
commitData: [{id: 'e137e9b', tags: ['master'], message: 'first commit'}],
initialMessage:
'Type in your git commands below.'
});
}
`
@end
`````