Skip to content

Commit b4b4149

Browse files
committed
Add a Makefile, and autodeploy to github pages using travis-ci.
1 parent 0593abc commit b4b4149

15 files changed

+127
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
elm-stuff
2+
build

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: elm
2+
3+
script: bash ./deploy.sh
4+
env:
5+
global:
6+
- ENCRYPTION_LABEL: "8690585ce1fc"
7+
- COMMIT_AUTHOR_EMAIL: "[email protected]"

Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ELM_FILES = $(shell find . -path ./elm.json -prune -o -type f -name '*.elm' ! -wholename './src/Main.elm' ! -wholename './src/Rule.elm')
2+
3+
all: build $(ELM_FILES) build/js/Rule.js build/js/Main.js
4+
5+
.PHONY: clean build
6+
7+
build/js/%.js: src/%.elm
8+
elm make $< --optimize --output $@
9+
10+
build:
11+
mkdir -p build
12+
cp -r static/* build/
13+
cp README.md build/index.md
14+
15+
clean:
16+
rm -rf build

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Introduction
2+
3+
Grape is a visual editor for the [GP 2 programming language](https://timothyatkinson.github.io/). It provides both a [host graph editor](https://sdhand.github.io/grape/graph), and a [rule editor](https://sdhand.github.io/grape/rule).
4+
5+
## Usage
6+
7+
The basic graph editing interface described in the table below is the same across both editors. Selected elements can be edited using the toolbar at the top. Note that changing the label or ID of an element requires confirmation by means of the button next to the input, or the enter key. This prevents the entering of invalid attributes.
8+
9+
| Operation | Action |
10+
|:--------------------- | ------------------------------------------:|
11+
| Create Node | Double click background |
12+
| Move Node | Left click and drag node |
13+
| Create Edge | Right click and drag from source to target |
14+
| Select Item | Left click item |
15+
| Delete selected item | Press delete on keyboard |
16+
| Zoom In/Out | Mouse wheel up/down |
17+
| Pan | Left click and drag background |
18+
19+
20+
Adding an element to the left hand side of a rule will automatically add it to the right hand side. This way, any modifications made by the rule are explicitly stated by modifying the right hand side of the rule. For example, to create a rule that deletes a node, first create the node in the left hand side, then delete it from the right hand side.
21+
22+
Graphs and rules can both be saved in the DOT and GP 2 formats with the buttons in the toolbar. The default format is DOT, and the dropdown can be used to select GP 2 instead. The DOT representation for rules differentiates between created and deleted elements through the use of shapes.
23+
24+
The rule declaration and condition can be set in the text boxes above and below the rule, respectively.
25+
26+
## Installation
27+
28+
If you wish to host the editor yourself then just clone the repository and run `make`. This requires that you have elm installed. A set of files will be produced in the `build` directory. Copy these to somewhere where they can be served with a webserver.

deploy.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
SOURCE_BRANCH="master"
5+
TARGET_BRANCH="gh-pages"
6+
7+
function doCompile {
8+
make
9+
}
10+
11+
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
12+
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
13+
echo "Skipping deploy; just doing a build."
14+
doCompile
15+
exit 0
16+
fi
17+
18+
# Save some useful information
19+
REPO=`git config remote.origin.url`
20+
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
21+
SHA=`git rev-parse --verify HEAD`
22+
23+
# Clone the existing gh-pages for this repo into out/
24+
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
25+
# Delete all existing contents except .git (we will re-create them)
26+
git clone $REPO build
27+
cd build
28+
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
29+
find -maxdepth 1 ! -name .git ! -name . | xargs rm -rf
30+
cd ..
31+
32+
# Run our compile script
33+
doCompile
34+
35+
# Now let's go have some fun with the cloned repo
36+
cd build
37+
git config user.name "Travis CI"
38+
git config user.email "$COMMIT_AUTHOR_EMAIL"
39+
40+
# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
41+
if git diff-index --quiet; then
42+
echo "No changes to the output on this push; exiting."
43+
exit 0
44+
fi
45+
46+
# Commit the "changes", i.e. the new version.
47+
# The delta will show diffs between new and old versions.
48+
git add -A .
49+
git commit -m "Deploy to GitHub Pages: ${SHA}"
50+
51+
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
52+
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
53+
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
54+
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
55+
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
56+
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../deploy_key.enc -out ../deploy_key -d
57+
chmod 600 ../deploy_key
58+
eval `ssh-agent -s`
59+
ssh-add ../deploy_key
60+
61+
# Now that we're all set up, we can push.
62+
git push $SSH_REPO $TARGET_BRANCH

deploy_key.enc

3.17 KB
Binary file not shown.

src/Main.elm

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ init _ =
5050

5151
view : Model -> Document Msg
5252
view model =
53-
{ title = "gp2editor"
53+
{ title = "grape - Host Editor"
5454
, body =
5555
[ div
5656
[ class "host-container" ]

src/Rule.elm

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ init _ =
6666

6767
view : Model -> Document Msg
6868
view model =
69-
{ title = "gp2editor"
69+
{ title = "grape - Rule Editor"
7070
, body =
7171
[ div
7272
[ class "host-container" ]

static/_config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-slate
File renamed without changes.
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<html>
22
<head>
3-
<link rel="stylesheet" href="sushi.css">
3+
<link rel="stylesheet" href="../css/grape.css">
44
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
55
<meta charset="UTF-8">
66
</head>
77
<body>
8-
<script type="text/javascript" src="viz.js"></script>
9-
<script type="text/javascript" src="full.render.js"></script>
8+
<script type="text/javascript" src="../js/viz.js"></script>
9+
<script type="text/javascript" src="../js/full.render.js"></script>
1010
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
1111
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
1212
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
13-
<script type="text/javascript" src="main.js"></script>
13+
<script type="text/javascript" src="../js/Main.js"></script>
1414
<script type="text/javascript">
1515
var app = Elm.Main.init();
1616
</script>
17-
<script type="text/javascript" src="ports.js"></script>
17+
<script type="text/javascript" src="../js/ports.js"></script>
1818
</body>
1919
</html>
File renamed without changes.

docs/ports.js static/js/ports.js

File renamed without changes.

docs/viz.js static/js/viz.js

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<html>
22
<head>
3-
<link rel="stylesheet" href="../sushi.css">
3+
<link rel="stylesheet" href="../css/grape.css">
44
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
55
<meta charset="UTF-8">
66
</head>
77
<body>
8-
<script type="text/javascript" src="../viz.js"></script>
9-
<script type="text/javascript" src="../full.render.js"></script>
8+
<script type="text/javascript" src="../js/viz.js"></script>
9+
<script type="text/javascript" src="../js/full.render.js"></script>
1010
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
1111
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
1212
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
13-
<script type="text/javascript" src="../rule.js"></script>
13+
<script type="text/javascript" src="../js/Rule.js"></script>
1414
<script type="text/javascript">
1515
var app = Elm.Rule.init();
1616
</script>
17-
<script type="text/javascript" src="../ports.js"></script>
17+
<script type="text/javascript" src="../js/ports.js"></script>
1818
</body>
1919
</html>

0 commit comments

Comments
 (0)