Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move index.js to examples.js

  • Loading branch information...
commit 9367eede07966310bcc766fe1b1721293018d5c6 1 parent fe98cd4
@Caged authored
Showing with 47 additions and 46 deletions.
  1. +46 −0 examples.js
  2. +1 −46 index.js
View
46 examples.js
@@ -0,0 +1,46 @@
+fs = require('fs')
+connect = require('connect')
+coffee = require('coffee-script')
+highlight = require('highlight').Highlight
+
+connect()
+ .use(connect.logger('dev'))
+ .use(connect.static(__dirname + '/examples/ven'))
+ .use(connect.static(__dirname))
+ .use(connect.favicon())
+ .use(connect.directory(__dirname + '/examples', {
+ filter: function(file) {
+ return (/\.coffee$/).test(file)
+ }}))
+ .use(function(req, res, next) {
+ if(req.url.match(/\.(js|css|png|gif|svg)$/))
+ return next()
+
+ fs.readFile(__dirname + "/examples/layout.html", 'utf8', function(err, data) {
+ if(err) return next()
+
+ var out = "",
+ view = req.url,
+ source = __dirname + "/examples" + req.url.replace(/\.html/, '.coffee')
+
+ fs.readFile(source, 'utf8', function(err, coffeedata) {
+ if(err) return next()
+
+ var compiled = coffee.compile(coffeedata, {filename: source, bare: false})
+ res.writeHead(200, 'OK', {
+ 'content-type': 'text/html; charset=utf-8',
+ 'cache-control': 'public, max-age=0'
+ })
+
+ out = data.replace('{{{SOURCE_ME}}}', highlight(coffeedata))
+ out = out.replace('{{{REPLACE_ME}}}', compiled)
+ res.end(out)
+ })
+ })
+ })
+ .use(function(req, res, next) {
+ res.writeHead(404, 'Not Found', {'content-type':'text/html'})
+ res.end("<h1>404 - Not Found</h1>")
+ })
+ .listen(9292);
+ console.log('Examples available at http://localhost:9292');
View
47 index.js
@@ -1,46 +1 @@
-fs = require('fs')
-connect = require('connect')
-coffee = require('coffee-script')
-highlight = require('highlight').Highlight
-
-connect()
- .use(connect.logger('dev'))
- .use(connect.static(__dirname + '/examples/ven'))
- .use(connect.static(__dirname))
- .use(connect.favicon())
- .use(connect.directory(__dirname + '/examples', {
- filter: function(file) {
- return (/\.coffee$/).test(file)
- }}))
- .use(function(req, res, next) {
- if(req.url.match(/\.(js|css|png|gif|svg)$/))
- return next()
-
- fs.readFile(__dirname + "/examples/layout.html", 'utf8', function(err, data) {
- if(err) return next()
-
- var out = "",
- view = req.url,
- source = __dirname + "/examples" + req.url.replace(/\.html/, '.coffee')
-
- fs.readFile(source, 'utf8', function(err, coffeedata) {
- if(err) return next()
-
- var compiled = coffee.compile(coffeedata, {filename: source, bare: false})
- res.writeHead(200, 'OK', {
- 'content-type': 'text/html; charset=utf-8',
- 'cache-control': 'public, max-age=0'
- })
-
- out = data.replace('{{{SOURCE_ME}}}', highlight(coffeedata))
- out = out.replace('{{{REPLACE_ME}}}', compiled)
- res.end(out)
- })
- })
- })
- .use(function(req, res, next) {
- res.writeHead(404, 'Not Found', {'content-type':'text/html'})
- res.end("<h1>404 - Not Found</h1>")
- })
- .listen(9292);
- console.log('Examples available at http://localhost:9292');
+module.exports = require("./octo")
Please sign in to comment.
Something went wrong with that request. Please try again.