Skip to content

Commit 66353cb

Browse files
committed
adding workshop framework
via http://github.com/hughsk/workshop-app-shell
0 parents  commit 66353cb

31 files changed

Lines changed: 719 additions & 0 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
answers
2+
node_modules
3+
npm-debug.log
4+
build

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
PATH := $(PWD)/node_modules/.bin:$(PATH)
2+
APPNAME := WebGL\ Workshop
3+
OSXDEST := build/osx/$(APPNAME).app
4+
OSXFILE := $(OSXDEST)/Contents/Resources/app.nw
5+
6+
.PHONY: build/osx clean
7+
8+
purge: clean
9+
rm -rf node_modules; true
10+
rm -rf build; true
11+
12+
clean:
13+
rm -rf build/osx; true
14+
15+
optimize:
16+
rm -rf node_modules
17+
npm install --production
18+
npm dedupe
19+
20+
build: optimize build/osx
21+
build/osx: $(OSXFILE)
22+
23+
build/downloads/osx.zip:
24+
mkdir -p build/downloads
25+
test -f build/downloads/osx.zip || \
26+
(nw-download build/downloads/osx.zip -p osx -r 0.10.5); true
27+
28+
$(OSXDEST): build/downloads/osx.zip
29+
mkdir -p build/osx
30+
unzip -qo -d build/osx build/downloads/osx.zip
31+
cp -R build/osx/node-webkit-v*-ia32/node-webkit.app $(OSXDEST)
32+
33+
build/osx/app.icns:
34+
mkdir -p build/osx
35+
which iconutil
36+
iconutil --convert icns --output build/osx/app.icns app/app.iconset
37+
38+
$(OSXFILE): build/osx/app.icns $(OSXDEST)
39+
mkdir -p $(OSXFILE)
40+
rm -rf $(OSXFILE)/node_modules 2> /dev/null; true
41+
cp -R node_modules $(OSXFILE)/node_modules
42+
cp -R app/* $(OSXFILE)/
43+
mv $(OSXFILE)/Info.plist $(OSXDEST)/Contents/Info.plist
44+
rm -rf $(OSXFILE)/node_modules/nw-download
45+
cp build/osx/app.icns $(OSXFILE)/../nw.icns
46+
cp exercises.json $(OSXFILE)/exercises.json

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# WebGL Workshop
2+
3+
**WORK IN PROGRESS. Come back later? :)**
4+
5+
A boilerplate for creating your own frontend-focused
6+
[NodeSchool](http://nodeschool.io/) lessons, not unlike
7+
[shader-school](http://github.com/stackgl/shader-school).
8+
9+
Can be run as a vanilla node server, or bundled up as a node-webkit app. The
10+
latter case is great for getting something installed without hitting the
11+
terminal, among a bunch of other benefits. Currently only OSX is supported
12+
this way, but I imagine it wouldn't be too hard to get the same working for
13+
Windows/Linux – if you have some time to spare, pull requests would be very
14+
much appreciated!
15+
16+
This forms the base of an upcoming WebGL workshop being created for
17+
[CampJS](http://campjs.com/).
18+
19+
Parts of this may be refactored into independent packages in the future, but
20+
right now I'm in a haste to get this together!
21+
22+
## Setup
23+
24+
Requires [npm](http://npmjs.org/) `2.x.x`.
25+
26+
``` bash
27+
git clone git@github.com:hughsk/workshop-app-shell.git
28+
cd workshop-app-shell
29+
npm install
30+
npm start
31+
```
32+
33+
### Running the Server
34+
35+
``` bash
36+
npm start
37+
```
38+
39+
### Building the App
40+
41+
``` bash
42+
make clean build
43+
```
44+
45+
## Writing a New Exercise
46+
47+
In this project, each exercise is treated as an *independent* package, i.e. a
48+
directory with its own `package.json` file, dependencies and so on. You're also
49+
given almost full control with your exercise – it's essentially just a vanilla
50+
route handler. See the [`exercises`](exercises) directory for a few existing
51+
examples.
52+
53+
The steps are as follows:
54+
55+
1. Create a new directory in `exercises`. The name of this directory is not
56+
important.
57+
1. Place a `package.json` file in there, with `main` pointing to `server.js` and
58+
the `name` being `@exercise/my-exercise-name`. This name will be used across
59+
the app to refer to the exercise in question (feel free to change that last
60+
part as you wish).
61+
1. Copy `exercises/bare/server.js` into your new exercise directory.
62+
1. Add an entry to `exercises.json`, where the key should be the exercise name
63+
as it appears on the menu and the value should be the same `name` property
64+
used in your `package.json`.
65+
1. Run `npm install --save exercises/*` from the project root to update the
66+
exercise dependencies.
67+
68+
Next time you run the server you should be good to go!

app/Info.plist

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>BuildMachineOSBuild</key>
6+
<string>12F45</string>
7+
<key>CFBundleDevelopmentRegion</key>
8+
<string>en</string>
9+
<key>CFBundleDisplayName</key>
10+
<string>WebGL Workshop</string>
11+
<key>CFBundleDocumentTypes</key>
12+
<array>
13+
<dict>
14+
<key>CFBundleTypeIconFile</key>
15+
<string>nw.icns</string>
16+
<key>CFBundleTypeName</key>
17+
<string>node-webkit App</string>
18+
<key>CFBundleTypeRole</key>
19+
<string>Viewer</string>
20+
<key>LSHandlerRank</key>
21+
<string>Owner</string>
22+
<key>LSItemContentTypes</key>
23+
<array>
24+
<string>com.intel.nw.app</string>
25+
</array>
26+
</dict>
27+
</array>
28+
<key>CFBundleExecutable</key>
29+
<string>node-webkit</string>
30+
<key>CFBundleIconFile</key>
31+
<string>nw.icns</string>
32+
<key>CFBundleIdentifier</key>
33+
<string>webgl-workshop</string>
34+
<key>CFBundleInfoDictionaryVersion</key>
35+
<string>6.0</string>
36+
<key>CFBundleName</key>
37+
<string>WebGL Workshop</string>
38+
<key>CFBundlePackageType</key>
39+
<string>APPL</string>
40+
<key>CFBundleShortVersionString</key>
41+
<string>Version latest</string>
42+
<key>CFBundleVersion</key>
43+
<string>latest</string>
44+
<key>DTSDKBuild</key>
45+
<string>12F37</string>
46+
<key>DTSDKName</key>
47+
<string>macosx10.8</string>
48+
<key>DTXcode</key>
49+
<string>0511</string>
50+
<key>DTXcodeBuild</key>
51+
<string>5B1008</string>
52+
<key>LSFileQuarantineEnabled</key>
53+
<false/>
54+
<key>LSMinimumSystemVersion</key>
55+
<string>10.6.0</string>
56+
<key>NSPrincipalClass</key>
57+
<string>NSApplication</string>
58+
<key>NSSupportsAutomaticGraphicsSwitching</key>
59+
<true/>
60+
<key>UTExportedTypeDeclarations</key>
61+
<array/>
62+
</dict>
63+
</plist>

app/app.iconset/icon_512x512.png

148 KB
Loading
460 KB
Loading

app/bootstrap.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html>
2+
<head>
3+
<title>WebGL Workshop</title>
4+
</head>
5+
<style media="screen">
6+
body {
7+
background: #34363B;
8+
}
9+
</style>
10+
<body>
11+
<script charset="utf-8" src="bootstrap.js"></script>
12+
</body>
13+
</html>

app/bootstrap.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var exercises = require('./exercises.json')
2+
var url = require('url')
3+
4+
process.env.PATH = [
5+
process.env.PATH
6+
, '/usr/local/bin'
7+
].join(':')
8+
9+
window.resizeTo(
10+
window.screen.availWidth || window.screen.width
11+
, window.screen.availHeight || window.screen.height
12+
)
13+
14+
require('@workshop/server')({
15+
nw: true
16+
}, function(err, uri) {
17+
if (err) throw err
18+
19+
var iframe = document.body.appendChild(
20+
document.createElement('iframe')
21+
)
22+
23+
iframe.style.position = 'absolute'
24+
iframe.style.top = 0
25+
iframe.style.left = 0
26+
iframe.style.width = '100%'
27+
iframe.style.height = '100%'
28+
iframe.style.border = 0
29+
iframe.style.margin = 0
30+
iframe.style.padding = 0
31+
iframe.onload = function() {
32+
setTimeout(function() {
33+
win.show()
34+
win.focus()
35+
})
36+
}
37+
38+
// General UI setup
39+
var gui = require('nw.gui')
40+
var win = gui.Window.get()
41+
42+
var menu = new gui.Menu({ type: 'menubar' })
43+
var submenu = new gui.Menu()
44+
var list = new gui.MenuItem({
45+
label: 'Exercises'
46+
, submenu: submenu
47+
})
48+
49+
Object.keys(exercises).forEach(function(name) {
50+
var src = url.resolve(uri, exercises[name])
51+
52+
submenu.append(new gui.MenuItem({
53+
label: name
54+
, click: function() {
55+
iframe.src = src
56+
}
57+
}))
58+
})
59+
60+
if (process.platform === 'darwin') {
61+
menu.createMacBuiltin('WebGL Workshop')
62+
}
63+
64+
menu.append(list)
65+
66+
win.menu = menu
67+
iframe.src = uri
68+
})

app/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "WebGL Workshop",
3+
"version": "1.0.0",
4+
"description": "Boilerplate for frontend-focused NodeSchool lessons",
5+
"main": "bootstrap.html",
6+
"license": "MIT",
7+
"author": "stack.gl contributors (http://stack.gl/)",
8+
"contributors": [
9+
"Mikola Lysenko",
10+
"Hugh Kennedy <hughskennedy@gmail.com> (http://hughsk.io)"
11+
],
12+
"single-instance": true,
13+
"window": {
14+
"title": "WebGL Workshop",
15+
"toolbar": false,
16+
"resizable": true,
17+
"frame": true,
18+
"width": 500,
19+
"min_width": 500,
20+
"height": 300,
21+
"show": false
22+
}
23+
}

exercises.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"» SAMPLE SECTION: BEEFY": "@exercise/beefy",
3+
"» SAMPLE SECTION: BARE": "@exercise/bare"
4+
}

0 commit comments

Comments
 (0)