Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upon deployment, visit to http://euchre.nodejitsu.com/
index.jade renders
Included assets fail in browser debug console messages:
GET http://euchre.nodejitsu.com/javascripts/vendor/require.js 404 (Not Found) euchre.nodejitsu.com:1
GET http://euchre.nodejitsu.com/stylesheets/style.css 404 (Not Found) euchre.nodejitsu.com:1
(visually, js would add some visible elements were it able to run)
folder structure:
public
javascripts
app
vendor
require.js
jade-runtime.js
jquery.js
main.js
template.js
stylesheets
style.css
routes
index.coffee
views
index.jade
layout.jade
package.json
server.coffee
require('coffee-script')
server = require("./server");
config = require("./config");
server.startServer(config, function(){});
var path = require('path');
var config = {
"watch": {
"sourceDir": [
"assets"
],
"compiledDir": [
"public"
],
"javascriptDir": [
"javascripts"
],
"exclude": [],
"throttle": 0,
"excludeRegex": {},
"compiledJavascriptDir": [
"public",
"javascripts"
]
},
"liveReload": {
"enabled": false
},
"server": {
"defaultServer": {
"enabled": false,
"onePager": false
},
"path": [
"server.coffee"
],
"port": 80,
"base": "",
"views": {
"compileWith": "jade",
"extension": "jade",
"path": [
"views"
]
}
}
}
var resolvePath = function (pathPieces) {
var returnPath = __dirname;
pathPieces.forEach(function(piece) {
returnPath = path.join(returnPath, piece);
})
return returnPath;
}
if (config.watch) {
config.watch.compiledDir = resolvePath(config.watch.compiledDir);
config.watch.sourceDir = resolvePath(config.watch.sourceDir);
config.watch.javascriptDir = resolvePath(config.watch.javascriptDir)
config.watch.compiledJavascriptDir = resolvePath(config.watch.compiledJavascriptDir);
}
if (config.server) {
if (config.server.path) {
config.server.path = resolvePath(config.server.path);
}
if (config.server.views && config.server.views.path) {
config.server.views.path = resolvePath(config.server.views.path);
}
}
module.exports = config;
{
"name": "euchre",
"version": "0.0.1-38",
"homepage": "",
"author": "jim@less2do.com",
"description": "",
"contributors": [
{
"name": "",
"email": ""
}
],
"private": true,
"dependencies": {
"express": "3.1.0",
"coffee-script": "1.6.2",
"consolidate": "0.8.0",
"jade": "0.28.2"
},
"subdomain": "euchre",
"scripts": {
"start": "app.js"
},
"engines": {
"node": "0.8.x"
}
}
express = require 'express'
engines = require 'consolidate'
path = require 'path'
exports.startServer = (config, callback) ->
app = express()
server = app.listen config.server.port, ->
console.log "Express server listening on port %d in %s mode", server.address().port, app.settings.env
app.configure ->
app.set 'port', config.server.port
app.set 'views', config.server.views.path
app.engine config.server.views.extension, engines[config.server.views.compileWith]
app.set 'view engine', config.server.views.extension
app.use express.favicon()
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.compress()
#original line, value = /opt/haibu/apps/jimmack1963/euchre/package/public
app.use express.static(config.watch.compiledDir)
#console.log '2 param'
app.use '/public', express.static(config.watch.compiledDir)
#path.join(config.watch.compiledDir, 'stylesheets')
#more verbose?
app.use '/stylesheets', express.static( path.join(config.watch.compiledDir, 'stylesheets'))
app.use '/public/stylesheets', express.static(path.join(config.watch.compiledDir, 'stylesheets'))
app.use config.server.base, app.router
app.configure 'development', ->
app.use express.errorHandler()
routes = require './routes'
app.get '/', routes.index(config)
callback(server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.