Ind.ie is now Small Technology Foundation.
Commit 0299aaba authored by Aral Balkan's avatar Aral Balkan

Merge branch 'ekaitz-zarraga/set-master'

* Remove CoffeeScript as a runtime dependency
parents 03c62229 7790e1d5
node_modules
.git
\ No newline at end of file
.DS_Store
node_modules
npm-debug.log
\ No newline at end of file
npm-debug.log
/js
fs = require 'fs'
path = require 'path'
{spawn, exec} = require 'child_process'
ncp = (require 'ncp').ncp
TARGET = 'js'
SOURCE = 'coffee'
build = (source, target) ->
###
# Build sources directory.
###
exec "coffee -c --no-header -o #{target} #{source}",
(err, stdout, stderr) ->
if err then console.err stderr.trim()
else
done source, target
done = (source, target) ->
###
# Show ok message and append to manifest file
###
console.log "#{source}: successfully built in #{target}"
delete_recursive = (target) ->
###
# Delete directory or file recursively
###
if not fs.existsSync target
return
if (fs.lstatSync target).isDirectory()
files = fs.readdirSync target
delete_recursive path.join target, f for f in files
fs.rmdirSync target
console.log "#{target}: Deleted on clean"
else
fs.unlinkSync target
console.log "#{target}: Deleted on clean"
copy_recursive = (source, target) ->
###
# Copy directory recursively
###
console.log ""
console.log "COMPILING..."
console.log ""
target_dir = path.dirname target
if not fs.existsSync target_dir
fs.mkdirSync target_dir
ncp source, target, (err)->
if err then console.error err
else
done source, target
task 'build', 'Build coffeescript to javascript', (opt)->
# Compile code folders
for source in ['lib', 'test', 'routes', 'views']
target = path.join TARGET, source
source = path.join SOURCE, source
build source, target
# Compile standalone files
for source in ['server.coffee']
source = path.join SOURCE, source
build source, TARGET
# Dump static folders
for source in ['views']
target = path.join TARGET, source
source = path.join SOURCE, source
copy_recursive source, target
task 'clean', 'Remove last build', (opt)->
###
# Remove all in Manifest file and the file itself
###
console.log ""
console.log "CLEANING DIRECTORY..."
console.log ""
delete_recursive TARGET
web: node_modules/forever/bin/forever -c coffee server.coffee
\ No newline at end of file
web: node_modules/forever/bin/forever js/server.js
// CoffeeScript bootstrap for use with (e.g.) node --debug
require("coffee-script");
require("./server");
require("coffee-script/register");
require("./coffee/server");
......@@ -9,15 +9,10 @@
################################################################################
fs = require 'fs'
exports.route = (request, response) ->
# Get the version to display in the index page.
fs.readFile __dirname + '/../package.json', 'utf-8', (error, data) ->
if error
throw new Error(error)
packageJSON = JSON.parse(data)
version = packageJSON['version']
meta = require('../../package.json')
version = meta.version
response.render 'main', {version: version}
\ No newline at end of file
response.render 'main', {version: version}
......@@ -11,7 +11,7 @@
################################################################################
superagent = require 'superagent'
timer = require '../lib/timer.coffee'
timer = require '../lib/timer'
exports.route = (request, response) ->
......
......@@ -13,7 +13,7 @@ marked = require 'marked'
fs = require 'fs'
exports.route = (request, response) ->
fs.readFile __dirname + '/../readme.md', 'utf-8', (error, markdown) ->
fs.readFile __dirname + '/../../readme.md', 'utf-8', (error, markdown) ->
data = {}
if error
......@@ -25,4 +25,4 @@ exports.route = (request, response) ->
data.title = 'Read me!'
data.readme = readme
response.render 'readme', data
\ No newline at end of file
response.render 'readme', data
......@@ -12,24 +12,24 @@
express = require 'express'
set = require './lib/set-express.coffee'
set = require './lib/set-express'
superagent = require 'superagent'
# Helper: create a route from a route name (e.g., /simple -> /routes/simple.coffee)
createRoute = (routeName) ->
path = if routeName == '/' then 'main' else routeName[1..]
route = require('./routes/' + path + '.coffee').route
route = require('./routes/' + path).route
app.get routeName, route
#
# Set up Express with Set as the templating engine.
#
app = express()
app.engine 'html', (require './lib/set-express.coffee').__express
app.engine 'html', (require './lib/set-express').__express
app.set 'view engine', 'html'
app.set 'views', __dirname + '/views'
app.use express.static('views')
app.use express.static( __dirname + '/views')
# Index: links to the readme and examples.
createRoute '/'
......
......@@ -542,4 +542,4 @@
</div>
</body>
</html>
\ No newline at end of file
</html>
......@@ -433,7 +433,6 @@
<p>Go to <a href="http://localhost:3000/">http://localhost:3000</a> and play!</p>
<p class='footnote'>Note: Set is written in CoffeeScript. <code>npm install -g coffee-script</code></p>
</section>
</div>
......
npm start
\ No newline at end of file
#!/bin/sh
#
# Development of Set itself is carried out in CoffeeScript.
# (Please do not submit pull requests with changes to the genereated JavaScript.)
#
# If you just want to use set (not develop on it), please run:
#
# npm start
#
node_modules/forever/bin/forever -w -c coffee coffee/server.coffee
{
"name": "indie-set",
"description": "Set is an unobtrusive and DRY template engine for Node.js and browsers.",
"version": "2.0.1",
"version": "2.1.0",
"author": "Aral Balkan <aral@ind.ie>",
"repository": {
"type": "git",
"url": "git@source.ind.ie:project/set.git"
},
"main": "./lib/set-express.coffee",
"main": "./js/lib/set-express.js",
"files": [
"js"
],
"scripts": {
"start": "coffee server.coffee",
"test": "node_modules/.bin/mocha test/*.coffee --require coffee-script/register --require should --reporter spec --compilers coffee:coffee-script/register"
"start": "node js/server.js",
"prepublish": "cake clean && cake build",
"test": "node_modules/.bin/mocha js/test/* --require should --reporter spec"
},
"dependencies": {
"coffee-script": "1.10.0",
"express": "4.13.3",
"forever": "0.15.1",
"jsdom": "7.0.2",
......@@ -21,6 +24,8 @@
"superagent": "1.4.0"
},
"devDependencies": {
"ncp": "^2.0.0",
"coffee-script": "^1.10.0",
"should": "*",
"mocha": "*",
"publish": "*"
......@@ -28,6 +33,10 @@
"contributors": [
{
"email": "mocking@gmail.com"
},
{
"name": "Ekaitz Zárraga",
"email": "ekaitz.zarraga@protonmail.com"
}
],
"license": "MIT",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment