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 'execjs' | |
class HandlebarsFilter < Filter | |
class << self | |
def contents | |
@@contents ||= [File.read("headless-ember.js"), File.read("ember.js")].join("\n") | |
end | |
def context | |
@@context ||= ExecJS.compile(contents) |
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
var path = require('path') | |
var vm = require('vm') | |
var handlebarsjs = fs.readFileSync(__dirname + '/vendor/handlebars.js', 'utf8') | |
var emberjs = fs.readFileSync(__dirname + '/vendor/ember/ember.js', 'utf8') | |
browserify.register('handlebars', function (body, file) { | |
//dummy jQuery | |
var jQuery = function () { return jQuery } | |
jQuery.ready = function () { return jQuery } | |
jQuery.inArray = function () { return jQuery } |
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
// use NuGet to add BundleTransformer to your project | |
// add ember.js and handlebars.js to the /Scripts folder | |
// in bundle config add something like this | |
bundles.Add(new ScriptBundle("~/bundles/templates").IncludeDirectory( | |
"~/templates", "*.handlebars")); | |
// or like this | |
bundles.Add(new ScriptBundle("~/bundles/teamplates").Include( | |
"~/templates/application.handlebars", |
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
// | |
// check that the user has the correct role for access to the route. | |
// to use, ensure that user has a roles array then add the following to routes | |
// | |
// app.get('/admin-route', app.authorise('admin', 'super-admin'), function (req, res) { ... }) | |
// | |
app.authorise = app.authorize = function () { | |
var roles = Array.prototype.slice.call(arguments) | |
return function (req, res, next) { | |
if (req.user && _.any(roles, function (role) { |
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
#entry point for js/coffee dependency tree | |
rootfile = 'root.js' | |
#get the file names and content | |
files = snockets.getCompiledChain rootfile, { async: false } | |
#package each file in eval with trailing //@ sourceURL | |
scripts = [] | |
for file in files | |
script = file.js.replace(/\\/g, '\\\\').replace(/\n/g, '\\n').replace(/'/g, '\\\'') |
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
// enable emberjs globally | |
GLOBAL.Ember = { lookup: GLOBAL } | |
require('./vendor/ember/ember-runtime') | |
// define the client App object | |
GLOBAL.App = Ember.Application.create({}) | |
// include ember models | |
require('./public/js/login') |
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
window.App = Ember.Application.create({}) | |
require('./applicationController') |
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
App.DataAccess = Ember.Object.create({ | |
namespace: 'api', | |
cache: {}, | |
getTypeName: function (type) { | |
return type.toString().match(/\w+$/); | |
}, | |
isId: function (query) { | |
return typeof query === 'string' || typeof query == 'number'; |
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
var system = require('system'); | |
var fs = require('fs'); | |
if (system.args.length !== 2) { | |
console.log('Usage: runner.js website-base-path'); | |
phantom.exit(1); | |
} | |
var basePath = system.args[1]; | |
var outputFile = basePath + '/test.html'; |