This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ck = require 'coffeekup' | |
| tpl = -> | |
| html -> | |
| head -> | |
| title 'title' | |
| body -> | |
| render 'index.coffee' | |
| render = (file) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ck = require 'coffeekup' | |
| template = -> | |
| doctype 5 | |
| html -> | |
| head -> | |
| title 'title' | |
| body -> | |
| render @user_panel, user: @user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| express = require 'express' | |
| io = require 'socket.io' | |
| ck = require 'coffeekup' | |
| app = express.createServer() | |
| app.get '/', (req, res) -> | |
| res.send ck.render -> | |
| @title = 'WebSockets tracker' | |
| doctype 5 | |
| html -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get '/': -> | |
| @items = [ | |
| {name: 'coffeescript', url: 'http://coffeescript.org'} | |
| {name: 'ruby', url: 'http://ruby-lang.org'} | |
| {name: 'python', url: 'http://python.org'} | |
| ] | |
| # I think helpers belong in the template's locals "namespace", | |
| # but we cannot currently specify the template's locals in zappa. | |
| @partial = partial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get '/': -> | |
| @items = [ | |
| {name: 'coffeescript', url: 'http://coffeescript.org'} | |
| {name: 'ruby', url: 'http://ruby-lang.org'} | |
| {name: 'python', url: 'http://python.org'} | |
| ] | |
| render 'default' | |
| view -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| helper requires_login: (cb) -> | |
| if request.session.user then cb() | |
| else redirect "/sessions/new?redir=" + request.url | |
| get "/accounts/new": -> | |
| requires_login -> | |
| render "home/accountNew" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| log = console.log | |
| ben = require 'ben' | |
| vm = require 'vm' | |
| times = 10000 | |
| global.sum = (x, y) -> x + y | |
| vm_script = vm.createScript 'console.log(typeof require);', 'vm_script' | |
| new_function = new Function('locals', 'console.log(typeof require);') | |
| applied = -> console.log(typeof require) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| zappa = | |
| run: (f)-> | |
| # Re-compile the function in a context that contains the Zappa | |
| # methods as globals. | |
| app = require('express').createServer() | |
| vm = require 'vm' | |
| code = 'zappa_code='+f.toString() | |
| views = {} | |
| router = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # auth_helper.coffee | |
| @include = -> | |
| helper auth: (cb) -> | |
| if session.user | |
| @user = session.user | |
| cb() | |
| else | |
| redirect '/login' | |
| # account_controller.coffe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require('zappa') -> | |
| before = (req, res, next) -> | |
| console.log 'before' | |
| next() | |
| @use before | |
| @get '/': -> | |
| console.log 'route' | |
| 'route' |
OlderNewer