Browse Source

Init

Nothing, but stock blueprint w/read-only access
master
sipp11 10 years ago
commit
416ed98563
  1. 10
      .editorconfig
  2. 118
      .gitignore
  3. 8
      .sailsrc
  4. 81
      Gruntfile.js
  5. 3
      README.md
  6. 0
      api/controllers/.gitkeep
  7. 11
      api/controllers/FlagController.js
  8. 11
      api/controllers/NationalityController.js
  9. 11
      api/controllers/PrefixController.js
  10. 0
      api/models/.gitkeep
  11. 14
      api/models/Flag.js
  12. 14
      api/models/Nationality.js
  13. 14
      api/models/Prefix.js
  14. 21
      api/policies/sessionAuth.js
  15. 64
      api/responses/badRequest.js
  16. 77
      api/responses/forbidden.js
  17. 82
      api/responses/notFound.js
  18. 48
      api/responses/ok.js
  19. 77
      api/responses/serverError.js
  20. 0
      api/services/.gitkeep
  21. 59
      app.js
  22. BIN
      assets/favicon.ico
  23. 0
      assets/images/.gitkeep
  24. 1033
      assets/js/dependencies/sails.io.js
  25. 8
      assets/robots.txt
  26. 30
      assets/styles/importer.less
  27. 0
      assets/templates/.gitkeep
  28. 162
      config/blueprints.js
  29. 17
      config/bootstrap.js
  30. 108
      config/connections.js
  31. 78
      config/cors.js
  32. 64
      config/csrf.js
  33. 24
      config/env/development.js
  34. 38
      config/env/production.js
  35. 63
      config/globals.js
  36. 87
      config/http.js
  37. 57
      config/i18n.js
  38. 28
      config/locales/_README.md
  39. 4
      config/locales/de.json
  40. 4
      config/locales/en.json
  41. 4
      config/locales/es.json
  42. 4
      config/locales/fr.json
  43. 29
      config/log.js
  44. 32
      config/models.js
  45. 66
      config/policies.js
  46. 49
      config/routes.js
  47. 91
      config/session.js
  48. 141
      config/sockets.js
  49. 95
      config/views.js
  50. 37
      package.json
  51. 54
      tasks/README.md
  52. 20
      tasks/config/clean.js
  53. 38
      tasks/config/coffee.js
  54. 27
      tasks/config/concat.js
  55. 38
      tasks/config/copy.js
  56. 21
      tasks/config/cssmin.js
  57. 41
      tasks/config/jst.js
  58. 28
      tasks/config/less.js
  59. 267
      tasks/config/sails-linker.js
  60. 27
      tasks/config/sync.js
  61. 22
      tasks/config/uglify.js
  62. 34
      tasks/config/watch.js
  63. 64
      tasks/pipeline.js
  64. 8
      tasks/register/build.js
  65. 11
      tasks/register/buildProd.js
  66. 9
      tasks/register/compileAssets.js
  67. 3
      tasks/register/default.js
  68. 10
      tasks/register/linkAssets.js
  69. 10
      tasks/register/linkAssetsBuild.js
  70. 10
      tasks/register/linkAssetsBuildProd.js
  71. 14
      tasks/register/prod.js
  72. 8
      tasks/register/syncAssets.js
  73. 76
      views/403.ejs
  74. 76
      views/404.ejs
  75. 81
      views/500.ejs
  76. 74
      views/homepage.ejs
  77. 91
      views/layout.ejs

10
.editorconfig

@ -0,0 +1,10 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

118
.gitignore vendored

@ -0,0 +1,118 @@
################################################
############### .gitignore ##################
################################################
#
# This file is only relevant if you are using git.
#
# Files which match the splat patterns below will
# be ignored by git. This keeps random crap and
# sensitive credentials from being uploaded to
# your repository. It allows you to configure your
# app for your machine without accidentally
# committing settings which will smash the local
# settings of other developers on your team.
#
# Some reasonable defaults are included below,
# but, of course, you should modify/extend/prune
# to fit your needs!
################################################
################################################
# Local Configuration
#
# Explicitly ignore files which contain:
#
# 1. Sensitive information you'd rather not push to
# your git repository.
# e.g., your personal API keys or passwords.
#
# 2. Environment-specific configuration
# Basically, anything that would be annoying
# to have to change every time you do a
# `git pull`
# e.g., your local development database, or
# the S3 bucket you're using for file uploads
# development.
#
################################################
config/local.js
################################################
# Dependencies
#
# When releasing a production app, you may
# consider including your node_modules and
# bower_components directory in your git repo,
# but during development, its best to exclude it,
# since different developers may be working on
# different kernels, where dependencies would
# need to be recompiled anyway.
#
# More on that here about node_modules dir:
# http://www.futurealoof.com/posts/nodemodules-in-git.html
# (credit Mikeal Rogers, @mikeal)
#
# About bower_components dir, you can see this:
# http://addyosmani.com/blog/checking-in-front-end-dependencies/
# (credit Addy Osmani, @addyosmani)
#
################################################
node_modules
bower_components
################################################
# Sails.js / Waterline / Grunt
#
# Files generated by Sails and Grunt, or related
# tasks and adapters.
################################################
.tmp
dump.rdb
################################################
# Node.js / NPM
#
# Common files generated by Node, NPM, and the
# related ecosystem.
################################################
lib-cov
*.seed
*.log
*.out
*.pid
npm-debug.log
################################################
# Miscellaneous
#
# Common files generated by text editors,
# operating systems, file systems, etc.
################################################
*~
*#
.DS_STORE
.netbeans
nbproject
.idea
.node_history

8
.sailsrc

@ -0,0 +1,8 @@
{
"generators": {
"modules": {}
},
"hooks": {
"grunt": false
}
}

81
Gruntfile.js

@ -0,0 +1,81 @@
/**
* Gruntfile
*
* This Node script is executed when you run `grunt` or `sails lift`.
* It's purpose is to load the Grunt tasks in your project's `tasks`
* folder, and allow you to add and remove tasks as you see fit.
* For more information on how this works, check out the `README.md`
* file that was generated in your `tasks` folder.
*
* WARNING:
* Unless you know what you're doing, you shouldn't change this file.
* Check out the `tasks` directory instead.
*/
module.exports = function(grunt) {
// Load the include-all library in order to require all of our grunt
// configurations and task registrations dynamically.
var includeAll;
try {
includeAll = require('include-all');
} catch (e0) {
try {
includeAll = require('sails/node_modules/include-all');
}
catch(e1) {
console.error('Could not find `include-all` module.');
console.error('Skipping grunt tasks...');
console.error('To fix this, please run:');
console.error('npm install include-all --save`');
console.error();
grunt.registerTask('default', []);
return;
}
}
/**
* Loads Grunt configuration modules from the specified
* relative path. These modules should export a function
* that, when run, should either load/configure or register
* a Grunt task.
*/
function loadTasks(relPath) {
return includeAll({
dirname: require('path').resolve(__dirname, relPath),
filter: /(.+)\.js$/
}) || {};
}
/**
* Invokes the function from a Grunt configuration module with
* a single argument - the `grunt` object.
*/
function invokeConfigFn(tasks) {
for (var taskName in tasks) {
if (tasks.hasOwnProperty(taskName)) {
tasks[taskName](grunt);
}
}
}
// Load task functions
var taskConfigurations = loadTasks('./tasks/config'),
registerDefinitions = loadTasks('./tasks/register');
// (ensure that a default task exists)
if (!registerDefinitions.default) {
registerDefinitions.default = function (grunt) { grunt.registerTask('default', []); };
}
// Run task functions to configure Grunt.
invokeConfigFn(taskConfigurations);
invokeConfigFn(registerDefinitions);
};

3
README.md

@ -0,0 +1,3 @@
# bbSails
a [Sails](http://sailsjs.org) application

0
api/controllers/.gitkeep

11
api/controllers/FlagController.js

@ -0,0 +1,11 @@
/**
* FlagController
*
* @description :: Server-side logic for managing flags
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
};

11
api/controllers/NationalityController.js

@ -0,0 +1,11 @@
/**
* NationalityController
*
* @description :: Server-side logic for managing nationalities
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
};

11
api/controllers/PrefixController.js

@ -0,0 +1,11 @@
/**
* PrefixController
*
* @description :: Server-side logic for managing prefixes
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
};

0
api/models/.gitkeep

14
api/models/Flag.js

@ -0,0 +1,14 @@
/**
* Flag.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
attributes: {
}
};

14
api/models/Nationality.js

@ -0,0 +1,14 @@
/**
* Nationality.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
attributes: {
}
};

14
api/models/Prefix.js

@ -0,0 +1,14 @@
/**
* Prefix.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
attributes: {
}
};

21
api/policies/sessionAuth.js

@ -0,0 +1,21 @@
/**
* sessionAuth
*
* @module :: Policy
* @description :: Simple policy to allow any authenticated user
* Assumes that your login action in one of your controllers sets `req.session.authenticated = true;`
* @docs :: http://sailsjs.org/#!/documentation/concepts/Policies
*
*/
module.exports = function(req, res, next) {
// User is allowed, proceed to the next policy,
// or if this is the last policy, the controller
if (req.session.authenticated) {
return next();
}
// User is not allowed
// (default res.forbidden() behavior can be overridden in `config/403.js`)
return res.forbidden('You are not permitted to perform this action.');
};

64
api/responses/badRequest.js

@ -0,0 +1,64 @@
/**
* 400 (Bad Request) Handler
*
* Usage:
* return res.badRequest();
* return res.badRequest(data);
* return res.badRequest(data, 'some/specific/badRequest/view');
*
* e.g.:
* ```
* return res.badRequest(
* 'Please choose a valid `password` (6-12 characters)',
* 'trial/signup'
* );
* ```
*/
module.exports = function badRequest(data, options) {
// Get access to `req`, `res`, & `sails`
var req = this.req;
var res = this.res;
var sails = req._sails;
// Set status code
res.status(400);
// Log error to console
if (data !== undefined) {
sails.log.verbose('Sending 400 ("Bad Request") response: \n',data);
}
else sails.log.verbose('Sending 400 ("Bad Request") response');
// Only include errors in response if application environment
// is not set to 'production'. In production, we shouldn't
// send back any identifying information about errors.
if (sails.config.environment === 'production') {
data = undefined;
}
// If the user-agent wants JSON, always respond with JSON
if (req.wantsJSON) {
return res.jsonx(data);
}
// If second argument is a string, we take that to mean it refers to a view.
// If it was omitted, use an empty object (`{}`)
options = (typeof options === 'string') ? { view: options } : options || {};
// If a view was provided in options, serve it.
// Otherwise try to guess an appropriate view, or if that doesn't
// work, just send JSON.
if (options.view) {
return res.view(options.view, { data: data });
}
// If no second argument provided, try to serve the implied view,
// but fall back to sending JSON(P) if no view can be inferred.
else return res.guessView({ data: data }, function couldNotGuessView () {
return res.jsonx(data);
});
};

77
api/responses/forbidden.js

@ -0,0 +1,77 @@
/**
* 403 (Forbidden) Handler
*
* Usage:
* return res.forbidden();
* return res.forbidden(err);
* return res.forbidden(err, 'some/specific/forbidden/view');
*
* e.g.:
* ```
* return res.forbidden('Access denied.');
* ```
*/
module.exports = function forbidden (data, options) {
// Get access to `req`, `res`, & `sails`
var req = this.req;
var res = this.res;
var sails = req._sails;
// Set status code
res.status(403);
// Log error to console
if (data !== undefined) {
sails.log.verbose('Sending 403 ("Forbidden") response: \n',data);
}
else sails.log.verbose('Sending 403 ("Forbidden") response');
// Only include errors in response if application environment
// is not set to 'production'. In production, we shouldn't
// send back any identifying information about errors.
if (sails.config.environment === 'production') {
data = undefined;
}
// If the user-agent wants JSON, always respond with JSON
if (req.wantsJSON) {
return res.jsonx(data);
}
// If second argument is a string, we take that to mean it refers to a view.
// If it was omitted, use an empty object (`{}`)
options = (typeof options === 'string') ? { view: options } : options || {};
// If a view was provided in options, serve it.
// Otherwise try to guess an appropriate view, or if that doesn't
// work, just send JSON.
if (options.view) {
return res.view(options.view, { data: data });
}
// If no second argument provided, try to serve the default view,
// but fall back to sending JSON(P) if any errors occur.
else return res.view('403', { data: data }, function (err, html) {
// If a view error occured, fall back to JSON(P).
if (err) {
//
// Additionally:
// • If the view was missing, ignore the error but provide a verbose log.
if (err.code === 'E_VIEW_FAILED') {
sails.log.verbose('res.forbidden() :: Could not locate view for error page (sending JSON instead). Details: ',err);
}
// Otherwise, if this was a more serious error, log to the console with the details.
else {
sails.log.warn('res.forbidden() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
}
return res.jsonx(data);
}
return res.send(html);
});
};

82
api/responses/notFound.js

@ -0,0 +1,82 @@
/**
* 404 (Not Found) Handler
*
* Usage:
* return res.notFound();
* return res.notFound(err);
* return res.notFound(err, 'some/specific/notfound/view');
*
* e.g.:
* ```
* return res.notFound();
* ```
*
* NOTE:
* If a request doesn't match any explicit routes (i.e. `config/routes.js`)
* or route blueprints (i.e. "shadow routes", Sails will call `res.notFound()`
* automatically.
*/
module.exports = function notFound (data, options) {
// Get access to `req`, `res`, & `sails`
var req = this.req;
var res = this.res;
var sails = req._sails;
// Set status code
res.status(404);
// Log error to console
if (data !== undefined) {
sails.log.verbose('Sending 404 ("Not Found") response: \n',data);
}
else sails.log.verbose('Sending 404 ("Not Found") response');
// Only include errors in response if application environment
// is not set to 'production'. In production, we shouldn't
// send back any identifying information about errors.
if (sails.config.environment === 'production') {
data = undefined;
}
// If the user-agent wants JSON, always respond with JSON
if (req.wantsJSON) {
return res.jsonx(data);
}
// If second argument is a string, we take that to mean it refers to a view.
// If it was omitted, use an empty object (`{}`)
options = (typeof options === 'string') ? { view: options } : options || {};
// If a view was provided in options, serve it.
// Otherwise try to guess an appropriate view, or if that doesn't
// work, just send JSON.
if (options.view) {
return res.view(options.view, { data: data });
}
// If no second argument provided, try to serve the default view,
// but fall back to sending JSON(P) if any errors occur.
else return res.view('404', { data: data }, function (err, html) {
// If a view error occured, fall back to JSON(P).
if (err) {
//
// Additionally:
// • If the view was missing, ignore the error but provide a verbose log.
if (err.code === 'E_VIEW_FAILED') {
sails.log.verbose('res.notFound() :: Could not locate view for error page (sending JSON instead). Details: ',err);
}
// Otherwise, if this was a more serious error, log to the console with the details.
else {
sails.log.warn('res.notFound() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
}
return res.jsonx(data);
}
return res.send(html);
});
};

48
api/responses/ok.js

@ -0,0 +1,48 @@
/**
* 200 (OK) Response
*
* Usage:
* return res.ok();
* return res.ok(data);
* return res.ok(data, 'auth/login');
*
* @param {Object} data
* @param {String|Object} options
* - pass string to render specified view
*/
module.exports = function sendOK (data, options) {
// Get access to `req`, `res`, & `sails`
var req = this.req;
var res = this.res;
var sails = req._sails;
sails.log.silly('res.ok() :: Sending 200 ("OK") response');
// Set status code
res.status(200);
// If appropriate, serve data as JSON(P)
if (req.wantsJSON) {
return res.jsonx(data);
}
// If second argument is a string, we take that to mean it refers to a view.
// If it was omitted, use an empty object (`{}`)
options = (typeof options === 'string') ? { view: options } : options || {};
// If a view was provided in options, serve it.
// Otherwise try to guess an appropriate view, or if that doesn't
// work, just send JSON.
if (options.view) {
return res.view(options.view, { data: data });
}
// If no second argument provided, try to serve the implied view,
// but fall back to sending JSON(P) if no view can be inferred.
else return res.guessView({ data: data }, function couldNotGuessView () {
return res.jsonx(data);
});
};

77
api/responses/serverError.js

@ -0,0 +1,77 @@
/**
* 500 (Server Error) Response
*
* Usage:
* return res.serverError();
* return res.serverError(err);
* return res.serverError(err, 'some/specific/error/view');
*
* NOTE:
* If something throws in a policy or controller, or an internal
* error is encountered, Sails will call `res.serverError()`
* automatically.
*/
module.exports = function serverError (data, options) {
// Get access to `req`, `res`, & `sails`
var req = this.req;
var res = this.res;
var sails = req._sails;
// Set status code
res.status(500);
// Log error to console
if (data !== undefined) {
sails.log.error('Sending 500 ("Server Error") response: \n',data);
}
else sails.log.error('Sending empty 500 ("Server Error") response');
// Only include errors in response if application environment
// is not set to 'production'. In production, we shouldn't
// send back any identifying information about errors.
if (sails.config.environment === 'production') {
data = undefined;
}
// If the user-agent wants JSON, always respond with JSON
if (req.wantsJSON) {
return res.jsonx(data);
}
// If second argument is a string, we take that to mean it refers to a view.
// If it was omitted, use an empty object (`{}`)
options = (typeof options === 'string') ? { view: options } : options || {};
// If a view was provided in options, serve it.
// Otherwise try to guess an appropriate view, or if that doesn't
// work, just send JSON.
if (options.view) {
return res.view(options.view, { data: data });
}
// If no second argument provided, try to serve the default view,
// but fall back to sending JSON(P) if any errors occur.
else return res.view('500', { data: data }, function (err, html) {
// If a view error occured, fall back to JSON(P).
if (err) {
//
// Additionally:
// • If the view was missing, ignore the error but provide a verbose log.
if (err.code === 'E_VIEW_FAILED') {
sails.log.verbose('res.serverError() :: Could not locate view for error page (sending JSON instead). Details: ',err);
}
// Otherwise, if this was a more serious error, log to the console with the details.
else {
sails.log.warn('res.serverError() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
}
return res.jsonx(data);
}
return res.send(html);
});
};

0
api/services/.gitkeep

59
app.js

@ -0,0 +1,59 @@
/**
* app.js
*
* Use `app.js` to run your app without `sails lift`.
* To start the server, run: `node app.js`.
*
* This is handy in situations where the sails CLI is not relevant or useful.
*
* For example:
* => `node app.js`
* => `forever start app.js`
* => `node debug app.js`
* => `modulus deploy`
* => `heroku scale`
*
*
* The same command-line arguments are supported, e.g.:
* `node app.js --silent --port=80 --prod`
*/
// Ensure we're in the project directory, so relative paths work as expected
// no matter where we actually lift from.
process.chdir(__dirname);
// Ensure a "sails" can be located:
(function() {
var sails;
try {
sails = require('sails');
} catch (e) {
console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.');
console.error('To do that, run `npm install sails`');
console.error('');
console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.');
console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,');
console.error('but if it doesn\'t, the app will run with the global sails instead!');
return;
}
// Try to get `rc` dependency
var rc;
try {
rc = require('rc');
} catch (e0) {
try {
rc = require('sails/node_modules/rc');
} catch (e1) {
console.error('Could not find dependency: `rc`.');
console.error('Your `.sailsrc` file(s) will be ignored.');
console.error('To resolve this, run:');
console.error('npm install rc --save');
rc = function () { return {}; };
}
}
// Start server
sails.lift(rc('sails'));
})();

BIN
assets/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

0
assets/images/.gitkeep

1033
assets/js/dependencies/sails.io.js

File diff suppressed because one or more lines are too long

8
assets/robots.txt

@ -0,0 +1,8 @@
# The robots.txt file is used to control how search engines index your live URLs.
# See http://www.robotstxt.org/wc/norobots.html for more information.
# To prevent search engines from seeing the site altogether, uncomment the next two lines:
# User-Agent: *
# Disallow: /

30
assets/styles/importer.less

@ -0,0 +1,30 @@
/**
* importer.less
*
* By default, new Sails projects are configured to compile this file
* from LESS to CSS. Unlike CSS files, LESS files are not compiled and
* included automatically unless they are imported below.
*
* The LESS files imported below are compiled and included in the order
* they are listed. Mixins, variables, etc. should be imported first
* so that they can be accessed by subsequent LESS stylesheets.
*
* (Just like the rest of the asset pipeline bundled in Sails, you can
* always omit, customize, or replace this behavior with SASS, SCSS,
* or any other Grunt tasks you like.)
*/
// For example:
//
// @import 'variables/colors.less';
// @import 'mixins/foo.less';
// @import 'mixins/bar.less';
// @import 'mixins/baz.less';
//
// @import 'styleguide.less';
// @import 'pages/login.less';
// @import 'pages/signup.less';
//
// etc.

0
assets/templates/.gitkeep

162
config/blueprints.js

@ -0,0 +1,162 @@
/**
* Blueprint API Configuration
* (sails.config.blueprints)
*
* These settings are for the global configuration of blueprint routes and
* request options (which impact the behavior of blueprint actions).
*
* You may also override any of these settings on a per-controller basis
* by defining a '_config' key in your controller defintion, and assigning it
* a configuration object with overrides for the settings in this file.
* A lot of the configuration options below affect so-called "CRUD methods",
* or your controllers' `find`, `create`, `update`, and `destroy` actions.
*
* It's important to realize that, even if you haven't defined these yourself, as long as
* a model exists with the same name as the controller, Sails will respond with built-in CRUD
* logic in the form of a JSON API, including support for sort, pagination, and filtering.
*
* For more information on the blueprint API, check out:
* http://sailsjs.org/#!/documentation/reference/blueprint-api
*
* For more information on the settings in this file, see:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.blueprints.html
*
*/
module.exports.blueprints = {
/***************************************************************************
* *
* Action routes speed up the backend development workflow by *
* eliminating the need to manually bind routes. When enabled, GET, POST, *
* PUT, and DELETE routes will be generated for every one of a controller's *
* actions. *
* *
* If an `index` action exists, additional naked routes will be created for *
* it. Finally, all `actions` blueprints support an optional path *
* parameter, `id`, for convenience. *
* *
* `actions` are enabled by default, and can be OK for production-- *
* however, if you'd like to continue to use controller/action autorouting *
* in a production deployment, you must take great care not to *
* inadvertently expose unsafe/unintentional controller logic to GET *
* requests. *
* *
***************************************************************************/
// actions: true,
/***************************************************************************
* *
* RESTful routes (`sails.config.blueprints.rest`) *
* *
* REST blueprints are the automatically generated routes Sails uses to *
* expose a conventional REST API on top of a controller's `find`, *
* `create`, `update`, and `destroy` actions. *
* *
* For example, a BoatController with `rest` enabled generates the *
* following routes: *
* ::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
* GET /boat -> BoatController.find *
* GET /boat/:id -> BoatController.findOne *
* POST /boat -> BoatController.create *
* PUT /boat/:id -> BoatController.update *
* DELETE /boat/:id -> BoatController.destroy *
* *
* `rest` blueprint routes are enabled by default, and are suitable for use *
* in a production scenario, as long you take standard security precautions *
* (combine w/ policies, etc.) *
* *
***************************************************************************/
// rest: true,
/***************************************************************************
* *
* Shortcut routes are simple helpers to provide access to a *
* controller's CRUD methods from your browser's URL bar. When enabled, *
* GET, POST, PUT, and DELETE routes will be generated for the *
* controller's`find`, `create`, `update`, and `destroy` actions. *
* *
* `shortcuts` are enabled by default, but should be disabled in *
* production. *
* *
***************************************************************************/
// shortcuts: true,
/***************************************************************************
* *
* An optional mount path for all blueprint routes on a controller, *
* including `rest`, `actions`, and `shortcuts`. This allows you to take *
* advantage of blueprint routing, even if you need to namespace your API *
* methods. *
* *
* (NOTE: This only applies to blueprint autoroutes, not manual routes from *
* `sails.config.routes`) *
* *
***************************************************************************/
// prefix: '',
/***************************************************************************
* *
* An optional mount path for all REST blueprint routes on a controller. *
* And it do not include `actions` and `shortcuts` routes. *
* This allows you to take advantage of REST blueprint routing, *
* even if you need to namespace your RESTful API methods *
* *
***************************************************************************/
// restPrefix: '',
/***************************************************************************
* *
* Whether to pluralize controller names in blueprint routes. *
* *
* (NOTE: This only applies to blueprint autoroutes, not manual routes from *
* `sails.config.routes`) *
* *
* For example, REST blueprints for `FooController` with `pluralize` *
* enabled: *
* GET /foos/:id? *
* POST /foos *
* PUT /foos/:id? *
* DELETE /foos/:id? *
* *
***************************************************************************/
// pluralize: false,
/***************************************************************************
* *
* Whether the blueprint controllers should populate model fetches with *
* data from other models which are linked by associations *
* *
* If you have a lot of data in one-to-many associations, leaving this on *
* may result in very heavy api calls *
* *
***************************************************************************/
// populate: true,
/****************************************************************************
* *
* Whether to run Model.watch() in the find and findOne blueprint actions. *
* Can be overridden on a per-model basis. *
* *
****************************************************************************/
// autoWatch: true,
/****************************************************************************
* *
* The default number of records to show in the response from a "find" *
* action. Doubles as the default size of populated arrays if populate is *
* true. *
* *
****************************************************************************/
defaultLimit: 10
};

17
config/bootstrap.js vendored

@ -0,0 +1,17 @@
/**
* Bootstrap
* (sails.config.bootstrap)
*
* An asynchronous bootstrap function that runs before your Sails app gets lifted.
* This gives you an opportunity to set up your data model, run jobs, or perform some special logic.
*
* For more information on bootstrapping your app, check out:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.bootstrap.html
*/
module.exports.bootstrap = function(cb) {
// It's very important to trigger this callback method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
cb();
};

108
config/connections.js

@ -0,0 +1,108 @@
/**
* Connections
* (sails.config.connections)
*
* `Connections` are like "saved settings" for your adapters. What's the difference between
* a connection and an adapter, you might ask? An adapter (e.g. `sails-mysql`) is generic--
* it needs some additional information to work (e.g. your database host, password, user, etc.)
* A `connection` is that additional information.
*
* Each model must have a `connection` property (a string) which is references the name of one
* of these connections. If it doesn't, the default `connection` configured in `config/models.js`
* will be applied. Of course, a connection can (and usually is) shared by multiple models.
* .
* Note: If you're using version control, you should put your passwords/api keys
* in `config/local.js`, environment variables, or use another strategy.
* (this is to prevent you inadvertently sensitive credentials up to your repository.)
*
* For more information on configuration, check out:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.connections.html
*/
module.exports.connections = {
/***************************************************************************
* *
* Local disk storage for DEVELOPMENT ONLY *
* *
* Installed by default. *
* *
***************************************************************************/
localDiskDb: {
adapter: 'sails-disk'
},
/***************************************************************************
* *
* MySQL is the world's most popular relational database. *
* http://en.wikipedia.org/wiki/MySQL *
* *
* Run: npm install sails-mysql *
* *
***************************************************************************/
someMysqlServer: {
adapter: 'sails-mysql',
host: 'YOUR_MYSQL_SERVER_HOSTNAME_OR_IP_ADDRESS',
user: 'YOUR_MYSQL_USER',
password: 'YOUR_MYSQL_PASSWORD',
database: 'YOUR_MYSQL_DB'
},
/***************************************************************************
* *
* MongoDB is the leading NoSQL database. *
* http://en.wikipedia.org/wiki/MongoDB *
* *
* Run: npm install sails-mongo *
* *
***************************************************************************/
someMongodbServer: {
adapter: 'sails-mongo',
host: '10hackintosh',
port: 27017,
// user: 'username',
// password: 'password',
// database: 'your_mongo_db_name_here'
},
hackintoshMongo: {
adapter: 'sails-mongo',
host: '10hackintosh.vnll',
port: 27017,
// user: 'username',
// password: 'password',
database: 'feeder',
},
nj2mongo: {
adapter: 'sails-mongo',
host: 'nj2',
port: 27017,
// user: 'username',
// password: 'password',
database: 'bbSailer',
},
/***************************************************************************
* *
* PostgreSQL is another officially supported relational database. *
* http://en.wikipedia.org/wiki/PostgreSQL *
* *
* Run: npm install sails-postgresql *
* *
* *
***************************************************************************/
somePostgresqlServer: {
adapter: 'sails-postgresql',
host: 'YOUR_POSTGRES_SERVER_HOSTNAME_OR_IP_ADDRESS',
user: 'YOUR_POSTGRES_USER',
password: 'YOUR_POSTGRES_PASSWORD',
database: 'YOUR_POSTGRES_DB'
}
/***************************************************************************
* *
* More adapters: https://github.com/balderdashy/sails *
* *
***************************************************************************/
};

78
config/cors.js

@ -0,0 +1,78 @@
/**
* Cross-Origin Resource Sharing (CORS) Settings
* (sails.config.cors)
*
* CORS is like a more modern version of JSONP-- it allows your server/API
* to successfully respond to requests from client-side JavaScript code
* running on some other domain (e.g. google.com)
* Unlike JSONP, it works with POST, PUT, and DELETE requests
*
* For more information on CORS, check out:
* http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
*
* Note that any of these settings (besides 'allRoutes') can be changed on a per-route basis
* by adding a "cors" object to the route configuration:
*
* '/get foo': {
* controller: 'foo',
* action: 'bar',
* cors: {
* origin: 'http://foobar.com,https://owlhoot.com'
* }
* }
*
* For more information on this configuration file, see:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.cors.html
*
*/
module.exports.cors = {
/***************************************************************************
* *
* Allow CORS on all routes by default? If not, you must enable CORS on a *
* per-route basis by either adding a "cors" configuration object to the *
* route config, or setting "cors:true" in the route config to use the *
* default settings below. *
* *
***************************************************************************/
// allRoutes: false,
/***************************************************************************
* *
* Which domains which are allowed CORS access? This can be a *
* comma-delimited list of hosts (beginning with http:// or https://) or *
* "*" to allow all domains CORS access. *
* *
***************************************************************************/
// origin: '*',
/***************************************************************************
* *
* Allow cookies to be shared for CORS requests? *
* *
***************************************************************************/
// credentials: true,
/***************************************************************************
* *
* Which methods should be allowed for CORS requests? This is only used in *
* response to preflight requests (see article linked above for more info) *
* *
***************************************************************************/
// methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
/***************************************************************************
* *
* Which headers should be allowed for CORS requests? This is only used in *
* response to preflight requests. *
* *
***************************************************************************/
// headers: 'content-type'
};

64
config/csrf.js

@ -0,0 +1,64 @@
/**
* Cross-Site Request Forgery Protection Settings
* (sails.config.csrf)
*
* CSRF tokens are like a tracking chip. While a session tells the server that a user
* "is who they say they are", a csrf token tells the server "you are where you say you are".
*
* When enabled, all non-GET requests to the Sails server must be accompanied by
* a special token, identified as the '_csrf' parameter.
*
* This option protects your Sails app against cross-site request forgery (or CSRF) attacks.
* A would-be attacker needs not only a user's session cookie, but also this timestamped,
* secret CSRF token, which is refreshed/granted when the user visits a URL on your app's domain.
*
* This allows us to have certainty that our users' requests haven't been hijacked,
* and that the requests they're making are intentional and legitimate.
*
* This token has a short-lived expiration timeline, and must be acquired by either:
*
* (a) For traditional view-driven web apps:
* Fetching it from one of your views, where it may be accessed as
* a local variable, e.g.:
* <form>
* <input type="hidden" name="_csrf" value="<%= _csrf %>" />
* </form>
*
* or (b) For AJAX/Socket-heavy and/or single-page apps:
* Sending a GET request to the `/csrfToken` route, where it will be returned
* as JSON, e.g.:
* { _csrf: 'ajg4JD(JGdajhLJALHDa' }
*
*
* Enabling this option requires managing the token in your front-end app.
* For traditional web apps, it's as easy as passing the data from a view into a form action.
* In AJAX/Socket-heavy apps, just send a GET request to the /csrfToken route to get a valid token.
*
* For more information on CSRF, check out:
* http://en.wikipedia.org/wiki/Cross-site_request_forgery
*
* For more information on this configuration file, including info on CSRF + CORS, see:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.csrf.html
*
*/
/****************************************************************************
* *
* Enabled CSRF protection for your site? *
* *
****************************************************************************/
// module.exports.csrf = false;
/****************************************************************************
* *
* You may also specify more fine-grained settings for CSRF, including the *
* domains which are allowed to request the CSRF token via AJAX. These *
* settings override the general CORS settings in your config/cors.js file. *
* *
****************************************************************************/
// module.exports.csrf = {
// grantTokenViaAjax: true,
// origin: ''
// }

24
config/env/development.js vendored

@ -0,0 +1,24 @@
/**
* Development environment settings
*
* This file can include shared settings for a development team,
* such as API keys or remote database passwords. If you're using
* a version control solution for your Sails app, this file will
* be committed to your repository unless you add it to your .gitignore
* file. If your repository will be publicly viewable, don't add
* any private information to this file!
*
*/
module.exports = {
/***************************************************************************
* Set the default database connection for models in the development *
* environment (see config/connections.js and config/models.js ) *
***************************************************************************/
// models: {
// connection: 'someMongodbServer'
// }
};

38
config/env/production.js vendored

@ -0,0 +1,38 @@
/**
* Production environment settings
*
* This file can include shared settings for a production environment,
* such as API keys or remote database passwords. If you're using
* a version control solution for your Sails app, this file will
* be committed to your repository unless you add it to your .gitignore
* file. If your repository will be publicly viewable, don't add
* any private information to this file!
*
*/
module.exports = {
/***************************************************************************
* Set the default database connection for models in the production *
* environment (see config/connections.js and config/models.js ) *
***************************************************************************/
models: {
connection: 'nj2mongo'
},
/***************************************************************************
* Set the port in the production environment to 80 *
***************************************************************************/
port: 8010,
/***************************************************************************
* Set the log level in production environment to "silent" *
***************************************************************************/
log: {
level: "silent"
}
};

63
config/globals.js

@ -0,0 +1,63 @@
/**
* Global Variable Configuration
* (sails.config.globals)
*
* Configure which global variables which will be exposed
* automatically by Sails.
*
* For more information on configuration, check out:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.globals.html
*/
module.exports.globals = {
/****************************************************************************
* *
* Expose the lodash installed in Sails core as a global variable. If this *
* is disabled, like any other node module you can always run npm install *
* lodash --save, then var _ = require('lodash') at the top of any file. *
* *
****************************************************************************/
// _: true,
/****************************************************************************
* *
* Expose the async installed in Sails core as a global variable. If this is *
* disabled, like any other node module you can always run npm install async *
* --save, then var async = require('async') at the top of any file. *
* *
****************************************************************************/
// async: true,
/****************************************************************************
* *
* Expose the sails instance representing your app. If this is disabled, you *
* can still get access via req._sails. *
* *
****************************************************************************/
// sails: true,
/****************************************************************************
* *
* Expose each of your app's services as global variables (using their *
* "globalId"). E.g. a service defined in api/models/NaturalLanguage.js *
* would have a globalId of NaturalLanguage by default. If this is disabled, *
* you can still access your services via sails.services.* *
* *
****************************************************************************/
// services: true,
/****************************************************************************
* *
* Expose each of your app's models as global variables (using their *
* "globalId"). E.g. a model defined in api/models/User.js would have a *
* globalId of User by default. If this is disabled, you can still access *
* your models via sails.models.*. *
* *
****************************************************************************/
// models: true
};

87
config/http.js

@ -0,0 +1,87 @@
/**
* HTTP Server Settings
* (sails.config.http)
*
* Configuration for the underlying HTTP server in Sails.
* Only applies to HTTP requests (not WebSockets)
*
* For more information on configuration, check out:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.http.html
*/
module.exports.http = {
/****************************************************************************
* *
* Express middleware to use for every Sails request. To add custom *
* middleware to the mix, add a function to the middleware config object and *
* add its key to the "order" array. The $custom key is reserved for *
* backwards-compatibility with Sails v0.9.x apps that use the *
* `customMiddleware` config option. *
* *
****************************************************************************/
// middleware: {
/***************************************************************************
* *
* The order in which middleware should be run for HTTP request. (the Sails *
* router is invoked by the "router" middleware below.) *
* *
***************************************************************************/
// order: [
// 'startRequestTimer',
// 'cookieParser',
// 'session',
// 'myRequestLogger',
// 'bodyParser',
// 'handleBodyParserError',
// 'compress',
// 'methodOverride',
// 'poweredBy',
// '$custom',
// 'router',
// 'www',
// 'favicon',
// '404',
// '500'
// ],
/****************************************************************************
* *
* Example custom middleware; logs each request to the console. *
* *
****************************************************************************/
// myRequestLogger: function (req, res, next) {
// console.log("Requested :: ", req.method, req.url);
// return next();
// }
/***************************************************************************
* *
* The body parser that will handle incoming multipart HTTP requests. By *
* default as of v0.10, Sails uses *
* [skipper](http://github.com/balderdashy/skipper). See *
* http://www.senchalabs.org/connect/multipart.html for other options. *
* *
***************************************************************************/
// bodyParser: require('skipper')
// },
/***************************************************************************
* *
* The number of seconds to cache flat files on disk being served by *
* Express static middleware (by default, these files are in `.tmp/public`) *
* *
* The HTTP static cache is only active in a 'production' environment, *
* since that's the only time Express will cache flat-files. *
* *
***************************************************************************/
// cache: 31557600000
};

57
config/i18n.js

@ -0,0 +1,57 @@
/**
* Internationalization / Localization Settings
* (sails.config.i18n)
*
* If your app will touch people from all over the world, i18n (or internationalization)
* may be an important part of your international strategy.
*
*
* For more informationom i18n in Sails, check out:
* http://sailsjs.org/#!/documentation/concepts/Internationalization
*
* For a complete list of i18n options, see:
* https://github.com/mashpie/i18n-node#list-of-configuration-options
*
*
*/
module.exports.i18n = {
/***************************************************************************
* *
* Which locales are supported? *
* *
***************************************************************************/
// locales: ['en', 'es', 'fr', 'de'],
/****************************************************************************
* *
* What is the default locale for the site? Note that this setting will be *
* overridden for any request that sends an "Accept-Language" header (i.e. *
* most browsers), but it's still useful if you need to localize the *
* response for requests made by non-browser clients (e.g. cURL). *
* *
****************************************************************************/
// defaultLocale: 'en',
/****************************************************************************
* *
* Automatically add new keys to locale (translation) files when they are *
* encountered during a request? *
* *
****************************************************************************/
// updateFiles: false,
/****************************************************************************
* *
* Path (relative to app root) of directory to store locale (translation) *
* files in. *
* *
****************************************************************************/
// localesDirectory: '/config/locales'
};

28
config/locales/_README.md

@ -0,0 +1,28 @@
# Internationalization / Localization Settings
> Also see the official docs on internationalization/localization:
> http://links.sailsjs.org/docs/config/locales
## Locales
All locale files live under `config/locales`. Here is where you can add translations
as JSON key-value pairs. The name of the file should match the language that you are supporting, which allows for automatic language detection based on request headers.
Here is an example locale stringfile for the Spanish language (`config/locales/es.json`):
```json
{
"Hello!": "Hola!",
"Hello %s, how are you today?": "ÂżHola %s, como estas?",
}
```
## Usage
Locales can be accessed in controllers/policies through `res.i18n()`, or in views through the `__(key)` or `i18n(key)` functions.
Remember that the keys are case sensitive and require exact key matches, e.g.
```ejs
<h1> <%= __('Welcome to PencilPals!') %> </h1>
<h2> <%= i18n('Hello %s, how are you today?', 'Pencil Maven') %> </h2>
<p> <%= i18n('That\'s right-- you can use either i18n() or __()') %> </p>
```
## Configuration
Localization/internationalization config can be found in `config/i18n.js`, from where you can set your supported locales.

4
config/locales/de.json

@ -0,0 +1,4 @@
{
"Welcome": "Willkommen",
"A brand new app.": "Eine neue App."
}

4
config/locales/en.json

@ -0,0 +1,4 @@
{
"Welcome": "Welcome",
"A brand new app.": "A brand new app."
}

4
config/locales/es.json

@ -0,0 +1,4 @@
{
"Welcome": "Bienvenido",
"A brand new app.": "Una aplicaciĂłn de la nueva marca."
}

4
config/locales/fr.json

@ -0,0 +1,4 @@
{
"Welcome": "Bienvenue",
"A brand new app.": "Une toute nouvelle application."
}

29
config/log.js

@ -0,0 +1,29 @@
/**
* Built-in Log Configuration
* (sails.config.log)
*
* Configure the log level for your app, as well as the transport
* (Underneath the covers, Sails uses Winston for logging, which
* allows for some pretty neat custom transports/adapters for log messages)
*
* For more information on the Sails logger, check out:
* http://sailsjs.org/#!/documentation/concepts/Logging
*/
module.exports.log = {
/***************************************************************************
* *
* Valid `level` configs: i.e. the minimum log level to capture with *
* sails.log.*() *
* *
* The order of precedence for log levels from lowest to highest is: *
* silly, verbose, info, debug, warn, error *
* *
* You may also set the level to "silent" to suppress all logs. *
* *
***************************************************************************/
// level: 'info'
};

32
config/models.js

@ -0,0 +1,32 @@
/**
* Default model configuration
* (sails.config.models)
*
* Unless you override them, the following properties will be included
* in each of your models.
*
* For more info on Sails models, see:
* http://sailsjs.org/#!/documentation/concepts/ORM
*/
module.exports.models = {
/***************************************************************************
* *
* Your app's default connection. i.e. the name of one of your app's *
* connections (see `config/connections.js`) *
* *
***************************************************************************/
connection: 'hackintoshMongo',
/***************************************************************************
* *
* How and whether Sails will attempt to automatically rebuild the *
* tables/collections/etc. in your schema. *
* *
* See http://sailsjs.org/#!/documentation/concepts/ORM/model-settings.html *
* *
***************************************************************************/
migrate: 'alter'
};

66
config/policies.js

@ -0,0 +1,66 @@
/**
* Policy Mappings
* (sails.config.policies)
*
* Policies are simple functions which run **before** your controllers.
* You can apply one or more policies to a given controller, or protect
* its actions individually.
*
* Any policy file (e.g. `api/policies/authenticated.js`) can be accessed
* below by its filename, minus the extension, (e.g. "authenticated")
*
* For more information on how policies work, see:
* http://sailsjs.org/#!/documentation/concepts/Policies
*
* For more information on configuring policies, check out:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.policies.html
*/
module.exports.policies = {
/***************************************************************************
* *
* Default policy for all controllers and actions (`true` allows public *
* access) *
* *
***************************************************************************/
'*': true,
'nationality': {
'*': 'sessionAuth',
'index': true,
'find': true,
},
'prefix': {
'*': 'sessionAuth',
'index': true,
'find': true,
},
'flag': {
'*': 'sessionAuth',
'index': true,
'find': true,
},
/***************************************************************************
* *
* Here's an example of mapping some policies to run before a controller *
* and its actions *
* *
***************************************************************************/
// RabbitController: {
// Apply the `false` policy as the default for all of RabbitController's actions
// (`false` prevents all access, which ensures that nothing bad happens to our rabbits)
// '*': false,
// For the action `nurture`, apply the 'isRabbitMother' policy
// (this overrides `false` above)
// nurture : 'isRabbitMother',
// Apply the `isNiceToAnimals` AND `hasRabbitFood` policies
// before letting any users feed our rabbits
// feed : ['isNiceToAnimals', 'hasRabbitFood']
// }
};

49
config/routes.js

@ -0,0 +1,49 @@
/**
* Route Mappings
* (sails.config.routes)
*
* Your routes map URLs to views and controllers.
*
* If Sails receives a URL that doesn't match any of the routes below,
* it will check for matching files (images, scripts, stylesheets, etc.)
* in your assets directory. e.g. `http://localhost:1337/images/foo.jpg`
* might match an image file: `/assets/images/foo.jpg`
*
* Finally, if those don't match either, the default 404 handler is triggered.
* See `api/responses/notFound.js` to adjust your app's 404 logic.
*
* Note: Sails doesn't ACTUALLY serve stuff from `assets`-- the default Gruntfile in Sails copies
* flat files from `assets` to `.tmp/public`. This allows you to do things like compile LESS or
* CoffeeScript for the front-end.
*
* For more information on configuring custom routes, check out:
* http://sailsjs.org/#!/documentation/concepts/Routes/RouteTargetSyntax.html
*/
module.exports.routes = {
/***************************************************************************
* *
* Make the view located at `views/homepage.ejs` (or `views/homepage.jade`, *
* etc. depending on your default view engine) your home page. *
* *
* (Alternatively, remove this and add an `index.html` file in your *
* `assets` directory) *
* *
***************************************************************************/
'/': {
view: 'homepage'
}
/***************************************************************************
* *
* Custom routes here... *
* *
* If a request to a URL doesn't match any of the custom routes above, it *
* is matched against Sails route blueprints. See `config/blueprints.js` *
* for configuration options and examples. *
* *
***************************************************************************/
};

91
config/session.js

@ -0,0 +1,91 @@
/**
* Session Configuration
* (sails.config.session)
*
* Sails session integration leans heavily on the great work already done by
* Express, but also unifies Socket.io with the Connect session store. It uses
* Connect's cookie parser to normalize configuration differences between Express
* and Socket.io and hooks into Sails' middleware interpreter to allow you to access
* and auto-save to `req.session` with Socket.io the same way you would with Express.
*
* For more information on configuring the session, check out:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.session.html
*/
module.exports.session = {
/***************************************************************************
* *
* Session secret is automatically generated when your new app is created *
* Replace at your own risk in production-- you will invalidate the cookies *
* of your users, forcing them to log in again. *
* *
***************************************************************************/
secret: 'ea302abd3c90643b26dcff7494388238',
/***************************************************************************
* *
* Set the session cookie expire time The maxAge is set by milliseconds, *
* the example below is for 24 hours *
* *
***************************************************************************/
// cookie: {
// maxAge: 24 * 60 * 60 * 1000
// },
/***************************************************************************
* *
* In production, uncomment the following lines to set up a shared redis *
* session store that can be shared across multiple Sails.js servers *
***************************************************************************/
// adapter: 'redis',
/***************************************************************************
* *
* The following values are optional, if no options are set a redis *
* instance running on localhost is expected. Read more about options at: *
* https://github.com/visionmedia/connect-redis *
* *
* *
***************************************************************************/
// host: 'localhost',
// port: 6379,
// ttl: <redis session TTL in seconds>,
// db: 0,
// pass: <redis auth password>,
// prefix: 'sess:',
/***************************************************************************
* *
* Uncomment the following lines to use your Mongo adapter as a session *
* store *
* *
***************************************************************************/
// adapter: 'mongo',
// host: 'localhost',
// port: 27017,
// db: 'sails',
// collection: 'sessions',
/***************************************************************************
* *
* Optional Values: *
* *
* # Note: url will override other connection settings url: *
* 'mongodb://user:pass@host:port/database/collection', *
* *
***************************************************************************/
// username: '',
// password: '',
// auto_reconnect: false,
// ssl: false,
// stringify: true
};

141
config/sockets.js

@ -0,0 +1,141 @@
/**
* WebSocket Server Settings
* (sails.config.sockets)
*
* These settings provide transparent access to the options for Sails'
* encapsulated WebSocket server, as well as some additional Sails-specific
* configuration layered on top.
*
* For more information on sockets configuration, including advanced config options, see:
* http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.sockets.html
*/
module.exports.sockets = {
/***************************************************************************
* *
* Node.js (and consequently Sails.js) apps scale horizontally. It's a *
* powerful, efficient approach, but it involves a tiny bit of planning. At *
* scale, you'll want to be able to copy your app onto multiple Sails.js *
* servers and throw them behind a load balancer. *
* *
* One of the big challenges of scaling an application is that these sorts *
* of clustered deployments cannot share memory, since they are on *
* physically different machines. On top of that, there is no guarantee *
* that a user will "stick" with the same server between requests (whether *
* HTTP or sockets), since the load balancer will route each request to the *
* Sails server with the most available resources. However that means that *
* all room/pubsub/socket processing and shared memory has to be offloaded *
* to a shared, remote messaging queue (usually Redis) *
* *
* Luckily, Socket.io (and consequently Sails.js) apps support Redis for *
* sockets by default. To enable a remote redis pubsub server, uncomment *
* the config below. *
* *
* Worth mentioning is that, if `adapter` config is `redis`, but host/port *
* is left unset, Sails will try to connect to redis running on localhost *
* via port 6379 *
* *
***************************************************************************/
// adapter: 'memory',
//
// -OR-
//
// adapter: 'redis',
// host: '127.0.0.1',
// port: 6379,
// db: 'sails',
// pass: '<redis auth password>',
/***************************************************************************
* *
* Whether to expose a 'get /__getcookie' route with CORS support that sets *
* a cookie (this is used by the sails.io.js socket client to get access to *
* a 3rd party cookie and to enable sessions). *
* *
* Warning: Currently in this scenario, CORS settings apply to interpreted *
* requests sent via a socket.io connection that used this cookie to *
* connect, even for non-browser clients! (e.g. iOS apps, toasters, node.js *
* unit tests) *
* *
***************************************************************************/
// grant3rdPartyCookie: true,
/***************************************************************************
* *
* `beforeConnect` *
* *
* This custom beforeConnect function will be run each time BEFORE a new *
* socket is allowed to connect, when the initial socket.io handshake is *
* performed with the server. *
* *
* By default, when a socket tries to connect, Sails allows it, every time. *
* (much in the same way any HTTP request is allowed to reach your routes. *
* If no valid cookie was sent, a temporary session will be created for the *
* connecting socket. *
* *
* If the cookie sent as part of the connection request doesn't match any *
* known user session, a new user session is created for it. *
* *
* In most cases, the user would already have a cookie since they loaded *
* the socket.io client and the initial HTML page you're building. *
* *
* However, in the case of cross-domain requests, it is possible to receive *
* a connection upgrade request WITHOUT A COOKIE (for certain transports) *
* In this case, there is no way to keep track of the requesting user *
* between requests, since there is no identifying information to link *
* him/her with a session. The sails.io.js client solves this by connecting *
* to a CORS/jsonp endpoint first to get a 3rd party cookie(fortunately this*
* works, even in Safari), then opening the connection. *
* *
* You can also pass along a ?cookie query parameter to the upgrade url, *
* which Sails will use in the absence of a proper cookie e.g. (when *
* connecting from the client): *
* io.sails.connect('http://localhost:1337?cookie=smokeybear') *
* *
* Finally note that the user's cookie is NOT (and will never be) accessible*
* from client-side javascript. Using HTTP-only cookies is crucial for your *
* app's security. *
* *
***************************************************************************/
// beforeConnect: function(handshake, cb) {
// // `true` allows the connection
// return cb(null, true);
//
// // (`false` would reject the connection)
// },
/***************************************************************************
* *
* `afterDisconnect` *
* *
* This custom afterDisconnect function will be run each time a socket *
* disconnects *
* *
***************************************************************************/
// afterDisconnect: function(session, socket, cb) {
// // By default: do nothing.
// return cb();
// },
/***************************************************************************
* *
* `transports` *
* *
* A array of allowed transport methods which the clients will try to use. *
* On server environments that don't support sticky sessions, the "polling" *
* transport should be disabled. *
* *
***************************************************************************/
// transports: ["polling", "websocket"]
};

95
config/views.js

@ -0,0 +1,95 @@
/**
* View Engine Configuration
* (sails.config.views)
*
* Server-sent views are a classic and effective way to get your app up
* and running. Views are normally served from controllers. Below, you can
* configure your templating language/framework of choice and configure
* Sails' layout support.
*
* For more information on views and layouts, check out:
* http://sailsjs.org/#!/documentation/concepts/Views
*/
module.exports.views = {
/****************************************************************************
* *
* View engine (aka template language) to use for your app's *server-side* *
* views *
* *
* Sails+Express supports all view engines which implement TJ Holowaychuk's *
* `consolidate.js`, including, but not limited to: *
* *
* ejs, jade, handlebars, mustache underscore, hogan, haml, haml-coffee, *
* dust atpl, eco, ect, jazz, jqtpl, JUST, liquor, QEJS, swig, templayed, *
* toffee, walrus, & whiskers *
* *
* For more options, check out the docs: *
* https://github.com/balderdashy/sails-wiki/blob/0.9/config.views.md#engine *
* *
****************************************************************************/
engine: 'ejs',
/****************************************************************************
* *
* Layouts are simply top-level HTML templates you can use as wrappers for *
* your server-side views. If you're using ejs or jade, you can take *
* advantage of Sails' built-in `layout` support. *
* *
* When using a layout, when one of your views is served, it is injected *
* into the `body` partial defined in the layout. This lets you reuse header *
* and footer logic between views. *
* *
* NOTE: Layout support is only implemented for the `ejs` view engine! *
* For most other engines, it is not necessary, since they implement *
* partials/layouts themselves. In those cases, this config will be *
* silently ignored. *
* *
* The `layout` setting may be set to one of the following: *
* *
* If `false`, layouts will be disabled. Otherwise, if a string is *
* specified, it will be interpreted as the relative path to your layout *
* file from `views/` folder. (the file extension, ".ejs", should be *
* omitted) *
* *
****************************************************************************/
/****************************************************************************
* *
* Using Multiple Layouts *
* *
* If you're using the default `ejs` or `handlebars` Sails supports the use *
* of multiple `layout` files. To take advantage of this, before rendering a *
* view, override the `layout` local in your controller by setting *
* `res.locals.layout`. (this is handy if you parts of your app's UI look *
* completely different from each other) *
* *
* e.g. your default might be *
* layout: 'layouts/public' *
* *
* But you might override that in some of your controllers with: *
* layout: 'layouts/internal' *
* *
****************************************************************************/
layout: 'layout',
/****************************************************************************
* *
* Partials are simply top-level snippets you can leverage to reuse template *
* for your server-side views. If you're using handlebars, you can take *
* advantage of Sails' built-in `partials` support. *
* *
* If `false` or empty partials will be located in the same folder as views. *
* Otherwise, if a string is specified, it will be interpreted as the *
* relative path to your partial files from `views/` folder. *
* *
****************************************************************************/
partials: false
};

37
package.json

@ -0,0 +1,37 @@
{
"name": "bbSails",
"private": true,
"version": "0.0.0",
"description": "a Sails application",
"keywords": [],
"dependencies": {
"ejs": "~0.8.4",
"grunt": "0.4.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.10.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-jst": "~0.6.0",
"grunt-contrib-less": "0.11.1",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-sails-linker": "~0.9.5",
"grunt-sync": "~0.0.4",
"include-all": "~0.1.3",
"rc": "~0.5.0",
"sails": "~0.11.0",
"sails-disk": "~0.10.0"
},
"scripts": {
"debug": "node debug app.js",
"start": "node app.js"
},
"main": "app.js",
"repository": {
"type": "git",
"url": "git://github.com/sipp11/bbSails.git"
},
"author": "sipp11",
"license": ""
}

54
tasks/README.md

@ -0,0 +1,54 @@
# About the `tasks` folder
The `tasks` directory is a suite of Grunt tasks and their configurations, bundled for your convenience. The Grunt integration is mainly useful for bundling front-end assets, (like stylesheets, scripts, & markup templates) but it can also be used to run all kinds of development tasks, from browserify compilation to database migrations.
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, read on!
### How does this work?
The asset pipeline bundled in Sails is a set of Grunt tasks configured with conventional defaults designed to make your project more consistent and productive.
The entire front-end asset workflow in Sails is completely customizable-- while it provides some suggestions out of the box, Sails makes no pretense that it can anticipate all of the needs you'll encounter building the browser-based/front-end portion of your application. Who's to say you're even building an app for a browser?
### What tasks does Sails run automatically?
Sails runs some of these tasks (the ones in the `tasks/register` folder) automatically when you run certain commands.
###### `sails lift`
Runs the `default` task (`tasks/register/default.js`).
###### `sails lift --prod`
Runs the `prod` task (`tasks/register/prod.js`).
###### `sails www`
Runs the `build` task (`tasks/register/build.js`).
###### `sails www --prod` (production)
Runs the `buildProd` task (`tasks/register/buildProd.js`).
### Can I customize this for SASS, Angular, client-side Jade templates, etc?
You can modify, omit, or replace any of these Grunt tasks to fit your requirements. You can also add your own Grunt tasks- just add a `someTask.js` file in the `grunt/config` directory to configure the new task, then register it with the appropriate parent task(s) (see files in `grunt/register/*.js`).
### Do I have to use Grunt?
Nope! To disable Grunt integration in Sails, just delete your Gruntfile or disable the Grunt hook.
### What if I'm not building a web frontend?
That's ok! A core tenant of Sails is client-agnosticism-- it's especially designed for building APIs used by all sorts of clients; native Android/iOS/Cordova, serverside SDKs, etc.
You can completely disable Grunt by following the instructions above.
If you still want to use Grunt for other purposes, but don't want any of the default web front-end stuff, just delete your project's `assets` folder and remove the front-end oriented tasks from the `grunt/register` and `grunt/config` folders. You can also run `sails new myCoolApi --no-frontend` to omit the `assets` folder and front-end-oriented Grunt tasks for future projects. You can also replace your `sails-generate-frontend` module with alternative community generators, or create your own. This allows `sails new` to create the boilerplate for native iOS apps, Android apps, Cordova apps, SteroidsJS apps, etc.

20
tasks/config/clean.js

@ -0,0 +1,20 @@
/**
* Clean files and folders.
*
* ---------------------------------------------------------------
*
* This grunt task is configured to clean out the contents in the .tmp/public of your
* sails project.
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-clean
*/
module.exports = function(grunt) {
grunt.config.set('clean', {
dev: ['.tmp/public/**'],
build: ['www']
});
grunt.loadNpmTasks('grunt-contrib-clean');
};

38
tasks/config/coffee.js

@ -0,0 +1,38 @@
/**
* Compile CoffeeScript files to JavaScript.
*
* ---------------------------------------------------------------
*
* Compiles coffeeScript files from `assest/js` into Javascript and places them into
* `.tmp/public/js` directory.
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-coffee
*/
module.exports = function(grunt) {
grunt.config.set('coffee', {
dev: {
options: {
bare: true,
sourceMap: true,
sourceRoot: './'
},
files: [{
expand: true,
cwd: 'assets/js/',
src: ['**/*.coffee'],
dest: '.tmp/public/js/',
ext: '.js'
}, {
expand: true,
cwd: 'assets/js/',
src: ['**/*.coffee'],
dest: '.tmp/public/js/',
ext: '.js'
}]
}
});
grunt.loadNpmTasks('grunt-contrib-coffee');
};

27
tasks/config/concat.js

@ -0,0 +1,27 @@
/**
* Concatenate files.
*
* ---------------------------------------------------------------
*
* Concatenates files javascript and css from a defined array. Creates concatenated files in
* .tmp/public/contact directory
* [concat](https://github.com/gruntjs/grunt-contrib-concat)
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-concat
*/
module.exports = function(grunt) {
grunt.config.set('concat', {
js: {
src: require('../pipeline').jsFilesToInject,
dest: '.tmp/public/concat/production.js'
},
css: {
src: require('../pipeline').cssFilesToInject,
dest: '.tmp/public/concat/production.css'
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
};

38
tasks/config/copy.js

@ -0,0 +1,38 @@
/**
* Copy files and folders.
*
* ---------------------------------------------------------------
*
* # dev task config
* Copies all directories and files, exept coffescript and less fiels, from the sails
* assets folder into the .tmp/public directory.
*
* # build task config
* Copies all directories nd files from the .tmp/public directory into a www directory.
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-copy
*/
module.exports = function(grunt) {
grunt.config.set('copy', {
dev: {
files: [{
expand: true,
cwd: './assets',
src: ['**/*.!(coffee|less)'],
dest: '.tmp/public'
}]
},
build: {
files: [{
expand: true,
cwd: '.tmp/public',
src: ['**/*'],
dest: 'www'
}]
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
};

21
tasks/config/cssmin.js

@ -0,0 +1,21 @@
/**
* Compress CSS files.
*
* ---------------------------------------------------------------
*
* Minifies css files and places them into .tmp/public/min directory.
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-cssmin
*/
module.exports = function(grunt) {
grunt.config.set('cssmin', {
dist: {
src: ['.tmp/public/concat/production.css'],
dest: '.tmp/public/min/production.min.css'
}
});
grunt.loadNpmTasks('grunt-contrib-cssmin');
};

41
tasks/config/jst.js

@ -0,0 +1,41 @@
/**
* Precompiles Underscore templates to a `.jst` file.
*
* ---------------------------------------------------------------
*
* (i.e. basically it takes HTML files and turns them into tiny little
* javascript functions that you pass data to and return HTML. This can
* speed up template rendering on the client, and reduce bandwidth usage.)
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-jst
*
*/
module.exports = function(grunt) {
grunt.config.set('jst', {
dev: {
// To use other sorts of templates, specify a regexp like the example below:
// options: {
// templateSettings: {
// interpolate: /\{\{(.+?)\}\}/g
// }
// },
// Note that the interpolate setting above is simply an example of overwriting lodash's
// default interpolation. If you want to parse templates with the default _.template behavior
// (i.e. using <div></div>), there's no need to overwrite `templateSettings.interpolate`.
files: {
// e.g.
// 'relative/path/from/gruntfile/to/compiled/template/destination' : ['relative/path/to/sourcefiles/**/*.html']
'.tmp/public/jst.js': require('../pipeline').templateFilesToInject
}
}
});
grunt.loadNpmTasks('grunt-contrib-jst');
};

28
tasks/config/less.js

@ -0,0 +1,28 @@
/**
* Compiles LESS files into CSS.
*
* ---------------------------------------------------------------
*
* Only the `assets/styles/importer.less` is compiled.
* This allows you to control the ordering yourself, i.e. import your
* dependencies, mixins, variables, resets, etc. before other stylesheets)
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-less
*/
module.exports = function(grunt) {
grunt.config.set('less', {
dev: {
files: [{
expand: true,
cwd: 'assets/styles/',
src: ['importer.less'],
dest: '.tmp/public/styles/',
ext: '.css'
}]
}
});
grunt.loadNpmTasks('grunt-contrib-less');
};

267
tasks/config/sails-linker.js

@ -0,0 +1,267 @@
/**
* Autoinsert script tags (or other filebased tags) in an html file.
*
* ---------------------------------------------------------------
*
* Automatically inject <script> tags for javascript files and <link> tags
* for css files. Also automatically links an output file containing precompiled
* templates using a <script> tag.
*
* For usage docs see:
* https://github.com/Zolmeister/grunt-sails-linker
*
*/
module.exports = function(grunt) {
grunt.config.set('sails-linker', {
devJs: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.ejs': require('../pipeline').jsFilesToInject
}
},
devJsRelative: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public',
relative: true
},
files: {
'.tmp/public/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.html': require('../pipeline').jsFilesToInject,
'views/**/*.ejs': require('../pipeline').jsFilesToInject
}
},
prodJs: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/**/*.html': ['.tmp/public/min/production.min.js'],
'views/**/*.html': ['.tmp/public/min/production.min.js'],
'views/**/*.ejs': ['.tmp/public/min/production.min.js']
}
},
prodJsRelative: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: '.tmp/public',
relative: true
},
files: {
'.tmp/public/**/*.html': ['.tmp/public/min/production.min.js'],
'views/**/*.html': ['.tmp/public/min/production.min.js'],
'views/**/*.ejs': ['.tmp/public/min/production.min.js']
}
},
devStyles: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.ejs': require('../pipeline').cssFilesToInject
}
},
devStylesRelative: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public',
relative: true
},
files: {
'.tmp/public/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.html': require('../pipeline').cssFilesToInject,
'views/**/*.ejs': require('../pipeline').cssFilesToInject
}
},
prodStyles: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/index.html': ['.tmp/public/min/production.min.css'],
'views/**/*.html': ['.tmp/public/min/production.min.css'],
'views/**/*.ejs': ['.tmp/public/min/production.min.css']
}
},
prodStylesRelative: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: '.tmp/public',
relative: true
},
files: {
'.tmp/public/index.html': ['.tmp/public/min/production.min.css'],
'views/**/*.html': ['.tmp/public/min/production.min.css'],
'views/**/*.ejs': ['.tmp/public/min/production.min.css']
}
},
// Bring in JST template object
devTpl: {
options: {
startTag: '<!--TEMPLATES-->',
endTag: '<!--TEMPLATES END-->',
fileTmpl: '<script type="text/javascript" src="%s"></script>',
appRoot: '.tmp/public'
},
files: {
'.tmp/public/index.html': ['.tmp/public/jst.js'],
'views/**/*.html': ['.tmp/public/jst.js'],
'views/**/*.ejs': ['.tmp/public/jst.js']
}
},
devJsJade: {
options: {
startTag: '// SCRIPTS',
endTag: '// SCRIPTS END',
fileTmpl: 'script(src="%s")',
appRoot: '.tmp/public'
},
files: {
'views/**/*.jade': require('../pipeline').jsFilesToInject
}
},
devJsRelativeJade: {
options: {
startTag: '// SCRIPTS',
endTag: '// SCRIPTS END',
fileTmpl: 'script(src="%s")',
appRoot: '.tmp/public',
relative: true
},
files: {
'views/**/*.jade': require('../pipeline').jsFilesToInject
}
},
prodJsJade: {
options: {
startTag: '// SCRIPTS',
endTag: '// SCRIPTS END',
fileTmpl: 'script(src="%s")',
appRoot: '.tmp/public'
},
files: {
'views/**/*.jade': ['.tmp/public/min/production.min.js']
}
},
prodJsRelativeJade: {
options: {
startTag: '// SCRIPTS',
endTag: '// SCRIPTS END',
fileTmpl: 'script(src="%s")',
appRoot: '.tmp/public',
relative: true
},
files: {
'views/**/*.jade': ['.tmp/public/min/production.min.js']
}
},
devStylesJade: {
options: {
startTag: '// STYLES',
endTag: '// STYLES END',
fileTmpl: 'link(rel="stylesheet", href="%s")',
appRoot: '.tmp/public'
},
files: {
'views/**/*.jade': require('../pipeline').cssFilesToInject
}
},
devStylesRelativeJade: {
options: {
startTag: '// STYLES',
endTag: '// STYLES END',
fileTmpl: 'link(rel="stylesheet", href="%s")',
appRoot: '.tmp/public',
relative: true
},
files: {
'views/**/*.jade': require('../pipeline').cssFilesToInject
}
},
prodStylesJade: {
options: {
startTag: '// STYLES',
endTag: '// STYLES END',
fileTmpl: 'link(rel="stylesheet", href="%s")',
appRoot: '.tmp/public'
},
files: {
'views/**/*.jade': ['.tmp/public/min/production.min.css']
}
},
prodStylesRelativeJade: {
options: {
startTag: '// STYLES',
endTag: '// STYLES END',
fileTmpl: 'link(rel="stylesheet", href="%s")',
appRoot: '.tmp/public',
relative: true
},
files: {
'views/**/*.jade': ['.tmp/public/min/production.min.css']
}
},
// Bring in JST template object
devTplJade: {
options: {
startTag: '// TEMPLATES',
endTag: '// TEMPLATES END',
fileTmpl: 'script(type="text/javascript", src="%s")',
appRoot: '.tmp/public'
},
files: {
'views/**/*.jade': ['.tmp/public/jst.js']
}
}
});
grunt.loadNpmTasks('grunt-sails-linker');
};

27
tasks/config/sync.js

@ -0,0 +1,27 @@
/**
* A grunt task to keep directories in sync. It is very similar to grunt-contrib-copy
* but tries to copy only those files that has actually changed.
*
* ---------------------------------------------------------------
*
* Synchronize files from the `assets` folder to `.tmp/public`,
* smashing anything that's already there.
*
* For usage docs see:
* https://github.com/tomusdrw/grunt-sync
*
*/
module.exports = function(grunt) {
grunt.config.set('sync', {
dev: {
files: [{
cwd: './assets',
src: ['**/*.!(coffee)'],
dest: '.tmp/public'
}]
}
});
grunt.loadNpmTasks('grunt-sync');
};

22
tasks/config/uglify.js

@ -0,0 +1,22 @@
/**
* Minify files with UglifyJS.
*
* ---------------------------------------------------------------
*
* Minifies client-side javascript `assets`.
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-uglify
*
*/
module.exports = function(grunt) {
grunt.config.set('uglify', {
dist: {
src: ['.tmp/public/concat/production.js'],
dest: '.tmp/public/min/production.min.js'
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
};

34
tasks/config/watch.js

@ -0,0 +1,34 @@
/**
* Run predefined tasks whenever watched file patterns are added, changed or deleted.
*
* ---------------------------------------------------------------
*
* Watch for changes on
* - files in the `assets` folder
* - the `tasks/pipeline.js` file
* and re-run the appropriate tasks.
*
* For usage docs see:
* https://github.com/gruntjs/grunt-contrib-watch
*
*/
module.exports = function(grunt) {
grunt.config.set('watch', {
api: {
// API files to watch:
files: ['api/**/*', '!**/node_modules/**']
},
assets: {
// Assets to watch:
files: ['assets/**/*', 'tasks/pipeline.js', '!**/node_modules/**'],
// When assets are changed:
tasks: ['syncAssets' , 'linkAssets']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
};

64
tasks/pipeline.js

@ -0,0 +1,64 @@
/**
* grunt/pipeline.js
*
* The order in which your css, javascript, and template files should be
* compiled and linked from your views and static HTML files.
*
* (Note that you can take advantage of Grunt-style wildcard/glob/splat expressions
* for matching multiple files.)
*/
// CSS files to inject in order
//
// (if you're using LESS with the built-in default config, you'll want
// to change `assets/styles/importer.less` instead.)
var cssFilesToInject = [
'styles/**/*.css'
];
// Client-side javascript files to inject in order
// (uses Grunt-style wildcard/glob/splat expressions)
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/**/*.js'
];
// Client-side HTML templates are injected using the sources below
// The ordering of these templates shouldn't matter.
// (uses Grunt-style wildcard/glob/splat expressions)
//
// By default, Sails uses JST templates and precompiles them into
// functions for you. If you want to use jade, handlebars, dust, etc.,
// with the linker, no problem-- you'll just want to make sure the precompiled
// templates get spit out to the same file. Be sure and check out `tasks/README.md`
// for information on customizing and installing new tasks.
var templateFilesToInject = [
'templates/**/*.html'
];
// Prefix relative paths to source files so they point to the proper locations
// (i.e. where the other Grunt tasks spit them out, or in some cases, where
// they reside in the first place)
module.exports.cssFilesToInject = cssFilesToInject.map(function(path) {
return '.tmp/public/' + path;
});
module.exports.jsFilesToInject = jsFilesToInject.map(function(path) {
return '.tmp/public/' + path;
});
module.exports.templateFilesToInject = templateFilesToInject.map(function(path) {
return 'assets/' + path;
});

8
tasks/register/build.js

@ -0,0 +1,8 @@
module.exports = function (grunt) {
grunt.registerTask('build', [
'compileAssets',
'linkAssetsBuild',
'clean:build',
'copy:build'
]);
};

11
tasks/register/buildProd.js

@ -0,0 +1,11 @@
module.exports = function (grunt) {
grunt.registerTask('buildProd', [
'compileAssets',
'concat',
'uglify',
'cssmin',
'linkAssetsBuildProd',
'clean:build',
'copy:build'
]);
};

9
tasks/register/compileAssets.js

@ -0,0 +1,9 @@
module.exports = function (grunt) {
grunt.registerTask('compileAssets', [
'clean:dev',
'jst:dev',
'less:dev',
'copy:dev',
'coffee:dev'
]);
};

3
tasks/register/default.js

@ -0,0 +1,3 @@
module.exports = function (grunt) {
grunt.registerTask('default', ['compileAssets', 'linkAssets', 'watch']);
};

10
tasks/register/linkAssets.js

@ -0,0 +1,10 @@
module.exports = function (grunt) {
grunt.registerTask('linkAssets', [
'sails-linker:devJs',
'sails-linker:devStyles',
'sails-linker:devTpl',
'sails-linker:devJsJade',
'sails-linker:devStylesJade',
'sails-linker:devTplJade'
]);
};

10
tasks/register/linkAssetsBuild.js

@ -0,0 +1,10 @@
module.exports = function (grunt) {
grunt.registerTask('linkAssetsBuild', [
'sails-linker:devJsRelative',
'sails-linker:devStylesRelative',
'sails-linker:devTpl',
'sails-linker:devJsRelativeJade',
'sails-linker:devStylesRelativeJade',
'sails-linker:devTplJade'
]);
};

10
tasks/register/linkAssetsBuildProd.js

@ -0,0 +1,10 @@
module.exports = function (grunt) {
grunt.registerTask('linkAssetsBuildProd', [
'sails-linker:prodJsRelative',
'sails-linker:prodStylesRelative',
'sails-linker:devTpl',
'sails-linker:prodJsRelativeJade',
'sails-linker:prodStylesRelativeJade',
'sails-linker:devTplJade'
]);
};

14
tasks/register/prod.js

@ -0,0 +1,14 @@
module.exports = function (grunt) {
grunt.registerTask('prod', [
'compileAssets',
'concat',
'uglify',
'cssmin',
'sails-linker:prodJs',
'sails-linker:prodStyles',
'sails-linker:devTpl',
'sails-linker:prodJsJade',
'sails-linker:prodStylesJade',
'sails-linker:devTplJade'
]);
};

8
tasks/register/syncAssets.js

@ -0,0 +1,8 @@
module.exports = function (grunt) {
grunt.registerTask('syncAssets', [
'jst:dev',
'less:dev',
'sync:dev',
'coffee:dev'
]);
};

76
views/403.ejs

@ -0,0 +1,76 @@
<!DOCTYPE html>
<!--
444444444 000000000 333333333333333
4::::::::4 00:::::::::00 3:::::::::::::::33
4:::::::::4 00:::::::::::::00 3::::::33333::::::3
4::::44::::4 0:::::::000:::::::03333333 3:::::3
4::::4 4::::4 0::::::0 0::::::0 3:::::3
4::::4 4::::4 0:::::0 0:::::0 3:::::3
4::::4 4::::4 0:::::0 0:::::0 33333333:::::3
4::::444444::::4440:::::0 000 0:::::0 3:::::::::::3
4::::::::::::::::40:::::0 000 0:::::0 33333333:::::3
4444444444:::::4440:::::0 0:::::0 3:::::3
4::::4 0:::::0 0:::::0 3:::::3
4::::4 0::::::0 0::::::0 3:::::3
4::::4 0:::::::000:::::::03333333 3:::::3
44::::::44 00:::::::::::::00 3::::::33333::::::3
4::::::::4 00:::::::::00 3:::::::::::::::33
4444444444 000000000 333333333333333
This is the default "403: Forbidden" page.
User agents that don't "Accept" HTML will see a JSON version instead.
You can customize the control logic for your needs in `config/403.js`
You can trigger this response from one of your controllers or policies with:
`return res.forbidden( msg );`
(where `msg` is an optional error message to include in the response)
-->
<html>
<head>
<title>Forbidden</title>
<link href='http://sailsjs.org/styles/fonts.css' rel='stylesheet'/>
<style>
/* Styles included inline since you'll probably be deleting or replacing this page anyway */
html,body{text-align:left;font-size:1em}html,body,img,form,textarea,input,fieldset,div,p,div,ul,li,ol,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,code{margin:0;padding:0}ul,li{list-style:none}img{display:block}a img{border:0}a{text-decoration:none;font-weight:normal;font-family:inherit}*:active,*:focus{outline:0;-moz-outline-style:none}h1,h2,h3,h4,h5,h6,h7{font-weight:normal;font-size:1em}.clearfix:after{clear:both;content:".";display:block;font-size:0;height:0;line-height:0;visibility:hidden}.page .ocean{background:url('http://sailsjs.com/images/waves.png') #0c8da0 no-repeat center 0;height:315px}.page .ocean img{margin-right:auto;margin-left:auto}.page .waves{display:block;padding-top:25px;margin-right:auto;margin-left:auto}.page .main{display:block;margin-top:90px}.page .logo{width:150px;margin-top:3.5em;margin-left:auto;margin-right:auto}.page .fishy{display:block;padding-top:100px}.page .help{padding-top:2em}.page h1{font-family:"Open Sans","Myriad Pro",Arial,sans-serif;font-weight:bold;font-size:1.7em;color:#001c20;text-align:center}.page h2{font-family:"Open Sans","Myriad Pro",Arial,sans-serif;font-weight:300;font-size:1.5em;color:#001c20;text-align:center}.page p{font-family:"Open Sans","Myriad Pro",Arial,sans-serif;font-size:1.25em;color:#001c20;text-align:center}.page a{color:#118798}.page a:hover{color:#b1eef7}
</style>
</head>
<body>
<div class="page">
<div class="ocean">
<img class="fishy" src="http://sailsjs.com/images/image_devInTub.png">
</div>
<div class="main">
<h1>
Forbidden
</h1>
<h2>
<% if (typeof error !== 'undefined') { %>
<%= error %>
<% } else { %>
You don't have permission to see the page you're trying to reach.
<% } %>
</h2>
<p class="help">
<a href="http://en.wikipedia.org/wiki/HTTP_403">Why</a> might this be happening?
</p>
</div>
<div class="logo">
<a href="http://sailsjs.org">
<img src="http://sailsjs.org/images/logo.png">
</a>
</div>
</div>
</body>
</html>

76
views/404.ejs

@ -0,0 +1,76 @@
<!DOCTYPE html>
<!--
444444444 000000000 444444444
4::::::::4 00:::::::::00 4::::::::4
4:::::::::4 00:::::::::::::00 4:::::::::4
4::::44::::4 0:::::::000:::::::0 4::::44::::4
4::::4 4::::4 0::::::0 0::::::0 4::::4 4::::4
4::::4 4::::4 0:::::0 0:::::0 4::::4 4::::4
4::::4 4::::4 0:::::0 0:::::0 4::::4 4::::4
4::::444444::::4440:::::0 000 0:::::04::::444444::::444
4::::::::::::::::40:::::0 000 0:::::04::::::::::::::::4
4444444444:::::4440:::::0 0:::::04444444444:::::444
4::::4 0:::::0 0:::::0 4::::4
4::::4 0::::::0 0::::::0 4::::4
4::::4 0:::::::000:::::::0 4::::4
44::::::44 00:::::::::::::00 44::::::44
4::::::::4 00:::::::::00 4::::::::4
4444444444 000000000 4444444444
This is the default "404: Not Found" page.
User agents that don't "Accept" HTML will see a JSON version instead.
You can customize the control logic for your needs in `config/404.js`
Sails considers a request to be in a "404: Not Found" state when a user
requests a URL which doesn't match any of your app's routes or blueprints.
You can also trigger this response from one of your controllers or policies with:
`return res.notFound();`
-->
<html>
<head>
<title>Page Not Found</title>
<link href='http://sailsjs.org/styles/fonts.css' rel='stylesheet'/>
<style>
/* Styles included inline since you'll probably be deleting this page anyway */
html,body{text-align:left;font-size:1em}html,body,img,form,textarea,input,fieldset,div,p,div,ul,li,ol,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,code{margin:0;padding:0}ul,li{list-style:none}img{display:block}a img{border:0}a{text-decoration:none;font-weight:normal;font-family:inherit}*:active,*:focus{outline:0;-moz-outline-style:none}h1,h2,h3,h4,h5,h6,h7{font-weight:normal;font-size:1em}.clearfix:after{clear:both;content:".";display:block;font-size:0;height:0;line-height:0;visibility:hidden}.fourohfour .ocean{background:url('http://sailsjs.com/images/waves.png') #0c8da0 no-repeat center 0;height:315px}.fourohfour .ocean img{margin-right:auto;margin-left:auto}.fourohfour .waves{display:block;padding-top:25px;margin-right:auto;margin-left:auto}.fourohfour .main{display:block;margin-top:90px}.fourohfour .logo{width:150px;margin-top:3.5em;margin-left:auto;margin-right:auto}.fourohfour .fishy{display:block;padding-top:27px}.fourohfour .help{padding-top:2em}.fourohfour h1{font-family:"Open Sans","Myriad Pro",Arial,sans-serif;font-weight:bold;font-size:1.7em;color:#001c20;text-align:center}.fourohfour h2{font-family:"Open Sans","Myriad Pro",Arial,sans-serif;font-weight:300;font-size:1.5em;color:#001c20;text-align:center}.fourohfour p{font-family:"Open Sans","Myriad Pro",Arial,sans-serif;font-size:1.25em;color:#001c20;text-align:center}.fourohfour a{color:#118798}.fourohfour a:hover{color:#b1eef7}
</style>
</head>
<body>
<div class="fourohfour">
<div class="ocean">
<img class="fishy" src="http://sailsjs.org/images/fishy4.png">
</div>
<div class="main">
<h1>
Something's fishy here.
</h1>
<h2>
<% if (typeof error!== 'undefined') { %>
<%= error %>
<% } else { %>
The page you were trying to reach doesn't exist.
<% } %>
</h2>
<p class="help">
<a href="http://en.wikipedia.org/wiki/HTTP_404">Why</a> might this be happening?
</p>
</div>
<div class="logo">
<a href="http://sailsjs.org">
<img src="http://sailsjs.org/images/logo.png">
</a>
</div>
</div>
</body>
</html>

81
views/500.ejs

File diff suppressed because one or more lines are too long

74
views/homepage.ejs

@ -0,0 +1,74 @@
<!-- Default home page -->
<link type="text/css" href='http://sailsjs.org/styles/fonts.css' rel='stylesheet'/>
<style>
/* Styles included inline since you'll probably be deleting this page anyway */
html,body{text-align:left;font-size:1em}html,body,img,form,textarea,input,fieldset,div,p,div,ul,li,ol,dl,dt,dd,h1,h2,h3,h4,h5,h6,pre,code{margin:0;padding:0}ul,li{list-style:none}img{display:block}a img{border:0}a{text-decoration:none;font-weight:normal;font-family:inherit}*:active,*:focus{outline:0;-moz-outline-style:none}h1,h2,h3,h4,h5,h6{font-weight:normal}div.clear{clear:both}.clearfix:after{clear:both;content:".";display:block;font-size:0;height:0;line-height:0;visibility:hidden}body{font-family:"Open Sans",Arial,sans-serif;font-weight:300;}.top-bar {width: 100%; background-color: #e4f0f1; padding: 15px 0;}.top-bar .container img {float: left;}.top-bar .container ul {float: right; padding-top: 25px;}.top-bar .container li {float: left; width: 125px; text-align: center; font-size: 15px; color:#000; font-weight: 600;}.top-bar .container a li:hover {color: #118798; -webkit-transition:color 200ms; -moz-transition:color 200ms; -o-transition:color 200ms;transition:color 200ms;}.container{width: 80%; max-width: 1200px; margin: auto;}div.header {-webkit-transition: 6s; -moz-transition: 6s; -o-transition: 6s;transition: 6s; background: rgba(4, 36, 41, 0.89) url(http://sailsjs.org/images/img_sailsShadow.png) no-repeat 42% bottom; padding: 100px 0 65px;}.header h1#main-title{color: #fff; font-weight: 300; font-size: 2.5em;}.header h3{color: #b1eef7; font-style: italic; font-weight: 300;}.header h3 code{font-style: normal!important; background-color: rgba(255,255,255,0.5); font-weight: 300; color:#0e6471; margin: 0px 5px;}div.main.container{padding: 50px 0;}h1 {color: #118798; font-weight: 300;}code {font-size: inherit; font-family: 'Consolas', 'Monaco', monospace; padding:4px 5px 1px; background-color: #f3f5f7}a{color: #118798; font-weight: 300; text-decoration: underline;}a:hover {color: #0e6471; -webkit-transition:color 200ms; -moz-transition:color 200ms; -o-transition:color 200ms;transition:color 200ms;}p{line-height: 1.5em;}blockquote{background-color: #e4f0f1; padding: 25px; line-height: 1.5em; margin: 15px 0;}blockquote span{font-weight: 600; padding-right: 5px;}ul.getting-started{padding: 25px 75px 25px 0; width: 70%; float: left; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;}ul.getting-started li{padding: 25px 0;}ul.getting-started li h3 {padding-bottom: 10px; font-size: 25px; font-weight: 300;}.sprite{background:url(http://sailsjs.org/images/newapp.sprite.png) no-repeat; position: absolute; left: 0; top:0;}.getting-started .sprite{margin-left:10px;padding-left:60px;height:42px;width:0; float: left;}.getting-started .one{background-position:0 0}.getting-started .two{background-position:0 -42px}.getting-started .three{background-position:0 -83px}div.step {position: relative; padding-left: 70px; opacity: 0.9;}div.step:hover{ opacity: 1;}div.links {float: left; width: 30%; max-width: 325px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; background-color: #f3f5f7; border: 1px solid #ebebeb; padding: 25px 45px 35px;}div.links h3 {color: #727272; text-align: center; font-size: 28px; font-weight: 300;}div.links h4 {color: #727272; font-size: 17px; font-weight: 600; padding: 15px 0 10px;}div.links .link-list a {text-decoration: none; font-weight: 400;}div.links .link-list a li {padding: 0px 0px 5px 10px;}div.default-page{min-width: 1200px;}.pocket{display:none;}
</style>
<script type="text/javascript">
setTimeout(function sunrise () {
document.getElementsByClassName('header')[0].style.backgroundColor = '#118798';
}, 0);
</script>
<div class="default-page">
<div class="header">
<h1 id="main-title" class="container"><%= __('A brand new app.') %></h1>
<h3 class="container">You're looking at: <code><%= view.pathFromApp + '.' +view.ext %></code></h3>
</div>
<div class="main container clearfix">
<!-- <h1>Getting started</h1>
<p>Don't worry, we've got your back.</p> -->
<ul class="getting-started">
<li class="clearfix">
<div class="step">
<div class="sprite one"></div>
<h3>Generate a REST API.</h3>
<p>
Run <code>sails generate api user</code>. This will create two files: a <a href="http://sailsjs.org/#!/documentation/concepts/ORM/Models.html">model</a> <code class="pocket">api/models/User.js</code> and a <a href="http://sailsjs.org/#!/documentation/concepts/Controllers">controller</a><code class="pocket">api/controllers/UserController.js</code>.
</p>
</div>
</li>
<li class="clearfix">
<div class="step">
<div class="sprite two"></div>
<h3>
Lift your app.
</h3>
<p>
Run <code>sails lift</code> to start up your app server. If you visit <a target="_blank" href="http://localhost:1337/user"><code>http://localhost:1337/user</code></a> in your browser, you'll see a <a href="http://sailsjs.org/#!/documentation/reference/blueprint-api">WebSocket-compatible</a> user API.
</p>
</div>
</li>
<li class="clearfix">
<div class="step">
<div class="sprite three"></div>
<h3>
Dive in.
</h3>
<p>Blueprints are just the beginning. You'll probably also want to learn how to customize your app's <a href="http://sailsjs.org/#!/documentation/concepts/Routes">routes</a>, set up <a href="http://sailsjs.org/#!/documentation/concepts/Policies">security policies</a>, configure your <a href="http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.connections.html">data sources</a>, and build custom <a target="_blank" href="http://sailsjs.org/#!/documentation/concepts/Controllers?q=actions">controller actions</a>. For more help getting started, check out the links on this page.</p>
</div>
</li>
</ul>
<div class="links">
<!-- <h3>Links</h3> -->
<ul class="link-list">
<h4>Docs</h4>
<a target="_blank" href="http://sailsjs.org/#!/documentation/anatomy/myApp"><li>App Structure</li></a>
<a target="_blank" href="http://sailsjs.org/#!/documentation/reference"><li>Reference</li></a>
<a target="_blank" href="http://sailsjs.org/#!/documentation/concepts/extending-sails/Adapters/adapterList.html"><li>Supported Databases</li></a>
<h4>Tutorials</h4>
<a target="_blank" href="https://github.com/sails101"><li>Sails 101</li></a>
<h4>Community</h4>
<a target="_blank" href="http://stackoverflow.com/search?q=sails.js"><li>StackOverFlow</li></a>
<a target="_blank" href="https://github.com/balderdashy/sails"><li>GitHub</li></a>
<a target="_blank" href="https://groups.google.com/forum/#!forum/sailsjs"><li>Google Group</li></a>
<a target="_blank" href="http://webchat.freenode.net/"><li>IRC (#sailsjs on freenode)</li></a>
</ul>
</div>
</div>
</div>

91
views/layout.ejs

@ -0,0 +1,91 @@
<!DOCTYPE html>
<html>
<head>
<title>New Sails App</title>
<!-- Viewport mobile tag for sensible mobile support -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--
Stylesheets and Preprocessors
==============================
You can always bring in CSS files manually with `<link>` tags, or asynchronously
using a solution like AMD (RequireJS). Or, if you like, you can take advantage
of Sails' conventional asset pipeline (boilerplate Gruntfile).
By default, stylesheets from your `assets/styles` folder are included
here automatically (between STYLES and STYLES END). Both CSS (.css) and LESS (.less)
are supported. In production, your styles will be minified and concatenated into
a single file.
To customize any part of the built-in behavior, just edit `tasks/pipeline.js`.
For example, here are a few things you could do:
+ Change the order of your CSS files
+ Import stylesheets from other directories
+ Use a different or additional preprocessor, like SASS, SCSS or Stylus
-->
<!--STYLES-->
<!--STYLES END-->
</head>
<body>
<%- body %>
<!--
Client-side Templates
========================
HTML templates are important prerequisites of modern, rich client applications.
To work their magic, frameworks like Backbone, Angular, Ember, and Knockout require
that you load these templates client-side.
By default, your Gruntfile is configured to automatically load and precompile
client-side JST templates in your `assets/templates` folder, then
include them here automatically (between TEMPLATES and TEMPLATES END).
To customize this behavior to fit your needs, just edit `tasks/pipeline.js`.
For example, here are a few things you could do:
+ Import templates from other directories
+ Use a different template engine (handlebars, jade, dust, etc.)
+ Internationalize your client-side templates using a server-side
stringfile before they're served.
-->
<!--TEMPLATES-->
<!--TEMPLATES END-->
<!--
Client-side Javascript
========================
You can always bring in JS files manually with `script` tags, or asynchronously
on the client using a solution like AMD (RequireJS). Or, if you like, you can
take advantage of Sails' conventional asset pipeline (boilerplate Gruntfile).
By default, files in your `assets/js` folder are included here
automatically (between SCRIPTS and SCRIPTS END). Both JavaScript (.js) and
CoffeeScript (.coffee) are supported. In production, your scripts will be minified
and concatenated into a single file.
To customize any part of the built-in behavior, just edit `tasks/pipeline.js`.
For example, here are a few things you could do:
+ Change the order of your scripts
+ Import scripts from other directories
+ Use a different preprocessor, like TypeScript
-->
<!--SCRIPTS-->
<!--SCRIPTS END-->
</body>
</html>
Loading…
Cancel
Save