Skip to content

Commit 2577c93

Browse files
author
James Halliday
committed
webapp part 1
1 parent d93efec commit 2577c93

11 files changed

+440
-0
lines changed

webapp.markdown

+13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
# web application
22

3+
---
4+
# start a project
5+
6+
```
7+
$ mkdir foo
8+
$ cd foo
9+
$ npm init
10+
```
11+
12+
---
13+
314
building a web application from zero
415

516
* http server
617
* static files
718
* routing
819
* client vs server
920
* rendering html
21+
* sorting hash
22+
* tween
1023
* database
1124

1225
---

webapp/lib/houses.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"cuddlepuff",
3+
"dragondor",
4+
"kittenclaw",
5+
"serpensnake"
6+
]

webapp/lib/sorthash.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var houses = require('./houses.json')
2+
var crypto = require('crypto')
3+
4+
module.exports = function (name) {
5+
var h = crypto.createHash('sha256')
6+
var hash = h.update(name).digest('hex')
7+
8+
var houseIndex = parseInt(hash.charAt(0), 16) % 4
9+
return houses[houseIndex]
10+
}

webapp/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "webapp",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"dependencies": {
7+
"body": "^5.1.0",
8+
"collect-stream": "^1.0.0",
9+
"ecstatic": "^0.8.0",
10+
"routes": "^2.1.0"
11+
},
12+
"devDependencies": {},
13+
"scripts": {
14+
"test": "echo \"Error: no test specified\" && exit 1"
15+
},
16+
"author": "",
17+
"license": "ISC"
18+
}

webapp/public/cuddlepuff.svg

+65
Loading

webapp/public/dragondor.svg

+64
Loading

webapp/public/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>cyberwizard school of witchcraft and wizardry</title>
5+
</head>
6+
<body>
7+
<h1>cyberwizard school</h1>
8+
<ul>
9+
<a href="/">home</a>
10+
<a href="/apply">apply to be sorted</a>
11+
</ul>
12+
<div id="content"></div>
13+
</body>
14+
</html>

webapp/public/kittenclaw.svg

+65
Loading

0 commit comments

Comments
 (0)