Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenn Schiffer committed May 22, 2014
0 parents commit 4f360da
Show file tree
Hide file tree
Showing 13 changed files with 235 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/*
npm-debug.log
30 changes: 30 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

jshint: {
options: {
node: true
},
all: [
'Gruntfile.js',
'app.js',
'public/js/*.js'
]
},

csslint: {
all: {
src: ['public/css/base.css']
}
}

});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-csslint');

grunt.registerTask('test', ['jshint', 'csslint']);

};
41 changes: 41 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// require express, stylus + nib
var express = require('express');
var stylus = require('stylus');
var nib = require('nib');

// require route scripts
var routes = require('./routes/index');
var routesPage = require('./routes/page');

// create express app
var app = express();

// set views and engine as jade
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');

// compile stylus and import nib for reset/css3
function compile(str, path) {
return stylus(str)
.set('filename', path)
.set('compress', true)
.use(nib())
.import('nib');
}
app.use(stylus.middleware({
src: __dirname + '/public',
compile: compile
})
);

// set dir for static css/js/assets
app.use(express.static(__dirname + '/public'));

// set up routes
app.use('/', routes);
app.use('/page', routesPage);

// on `node app.js` app will run at localhost:5678
app.listen('5678');

module.exports = app;
21 changes: 21 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Jenn Schiffer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "express-playground",
"description": "just a base for a node app using express, jade, and stylus",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "4.x",
"jade": "*",
"stylus": "*",
"nib": "*"
},
"devDependencies": {
"grunt": "~0.4.4",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-csslint": "~0.2.0"
}
}
1 change: 1 addition & 0 deletions public/css/base.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions public/css/base.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
global-reset()

body
font-family 'Courier New', monospace
margin 20px

h1
font-weight bold
margin 1em 0
font-size 2em

h2
font-weight bold
margin 1em 0
font-size 1.5em

nav ul li
display inline-block

a
padding 10px
&:hover
background-color blue
color white

.container
padding 10px

p
margin 1em 0

footer
font-size .8em
font-style italic
20 changes: 20 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# express playground

This is just a base for a node app using express, jade, and stylus.

## dependencies

* [express](http://expressjs.com/) - node web app framework, using version 4 because "hash tag yo-lo"
* [jade](http://jade-lang.com/) - templating engine
* [stylus](http://learnboost.github.io/stylus/) - css preprocessor, compiled in `app.js`
* [grunt](http://gruntjs.com/) - currently just used for jshint'ing & csslint'ing

## running it

* `grunt test` to [jshint](http://www.jshint.com/) & [csslint](http://csslint.net/)
* `node app.js` to run at `localhost:5678`

## made by jenn

* [@jennschiffer](http://twitter.com/jennschiffer)
* email: jenn @ dotbiz.info (yes, this is a real email)
15 changes: 15 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// require express and create router
var express = require('express');
var router = express.Router();

// router for index page
router.get('/', function(req, res) {
res.render('index',
{
title: 'home',
bodyID: 'home'
}
);
});

module.exports = router;
15 changes: 15 additions & 0 deletions routes/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// require express and create router
var express = require('express');
var router = express.Router();

// router for /page
router.get('/', function(req, res) {
res.render('page',
{
title: 'example page',
bodyID: 'page'
}
);
});

module.exports = router;
6 changes: 6 additions & 0 deletions views/index.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extend layout

block content
p This is just a base for a node app using express, jade, and stylus, ok?
p
i Ok.
26 changes: 26 additions & 0 deletions views/layout.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
doctype html
html(lang="en")
head
title #{title} • express playground
link(rel="stylesheet", href="/css/base.css")

body(id!="#{bodyID}")
header
h1 express playground

nav
ul
li
a(href="/") home
li
a(href="/page") example page

.container
block content

footer
p
made by
a(href="http://twitter.com/jennschiffer") jenn schiffer
| •
a(href="http://github.com/jennschiffer/express-playground") fork it on githugs
7 changes: 7 additions & 0 deletions views/page.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extend layout

block content
h2 #{title}
p Here's an example page showcasing express routes.
p
strong Pretty cool.

0 comments on commit 4f360da

Please sign in to comment.