Skip to content

Commit

Permalink
init sails
Browse files Browse the repository at this point in the history
  • Loading branch information
odykyi committed Jun 15, 2015
1 parent 5365e04 commit 1fca38f
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 55 deletions.
88 changes: 88 additions & 0 deletions api/controllers/VideoController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
module.exports = {

createVideo: function (req, res) {
Video.create(
{
en : {
title : req.param('title')
//description : req.param('description'),
//author : req.param('author'),
//keywords : req.param('keywords'),
//link : req.param('link')
},
ru : {
title : req.param('title')
//description : req.param('description'),
//author : req.param('author'),
//keywords : req.param('keywords'),
//link : req.param('link')
}
}
,
function (err, obj) {

if (err) console.error(err);


//return res.json({
// title: obj.title,
// description: obj.description
//
//});
}
);
},


/**
* `VideoController.show()`
*/
showVideoList: function (req, res){

},
showVideoItem: function (req, res){

var id = req.param("id");


Video.find( {


id : id


}, function(err, obj){

if (err) console.error(err);


console.log("showVideoItem/:id", obj);
return res.json({
sasa: obj
});
});

}


//,
///**
// * `VideoController.edit()`
// */
//edit: function (req, res) {
// return res.json({
// todo: 'edit() is not implemented yet!'
// });
//},
//
//
///**
// * `VideoController.delete()`
// */
//delete: function (req, res) {
// return res.json({
// todo: 'delete() is not implemented yet!'
// });
//}
};

24 changes: 24 additions & 0 deletions api/models/Video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
attributes: {
en: {
title : { type: 'string' }
//,
//description : { type: 'string' },
//author : { type: 'string' },
//keywords : { type: 'string' },
//link : { type: 'string' }
},
//en: {
// type: "object"
//},
ru: {
title : { type: 'string' }
//,
//description : { type: 'string' },
//author : { type: 'string' },
//keywords : { type: 'string' },
//link : { type: 'string' }
}
}
};

6 changes: 6 additions & 0 deletions api/policies/localize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(req, res, next) {

req.locale=req.param('ln');
next();

};
74 changes: 37 additions & 37 deletions config/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
module.exports.connections = {

/***************************************************************************
* *
* Local disk storage for DEVELOPMENT ONLY *
* *
* Installed by default. *
* *
***************************************************************************/
* *
* 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 *
* *
***************************************************************************/
* *
* 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',
Expand All @@ -49,31 +49,31 @@ module.exports.connections = {
},

/***************************************************************************
* *
* MongoDB is the leading NoSQL database. *
* http://en.wikipedia.org/wiki/MongoDB *
* *
* Run: npm install sails-mongo *
* *
***************************************************************************/
* *
* MongoDB is the leading NoSQL database. *
* http://en.wikipedia.org/wiki/MongoDB *
* *
* Run: npm install sails-mongo *
* *
***************************************************************************/
someMongodbServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017,
// user: 'username',
// password: 'password',
// database: 'your_mongo_db_name_here'
host: 'ds031631.mongolab.com',
port: 31631,
user: 'sails_prod',
password: 'sails_prod',
database: 'sails'
},

/***************************************************************************
* *
* PostgreSQL is another officially supported relational database. *
* http://en.wikipedia.org/wiki/PostgreSQL *
* *
* Run: npm install sails-postgresql *
* *
* *
***************************************************************************/
* *
* 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',
Expand All @@ -84,9 +84,9 @@ module.exports.connections = {


/***************************************************************************
* *
* More adapters: https://github.com/balderdashy/sails *
* *
***************************************************************************/
* *
* More adapters: https://github.com/balderdashy/sails *
* *
***************************************************************************/

};
9 changes: 5 additions & 4 deletions config/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports.i18n = {
* *
***************************************************************************/

// locales: ['en', 'es', 'fr', 'de'],
locales: ['en', 'ru'],

/****************************************************************************
* *
Expand All @@ -34,7 +34,7 @@ module.exports.i18n = {
* *
****************************************************************************/

// defaultLocale: 'en',
defaultLocale: 'ru',

/****************************************************************************
* *
Expand All @@ -43,7 +43,8 @@ module.exports.i18n = {
* *
****************************************************************************/

// updateFiles: false,
updateFiles: true,
//,

/****************************************************************************
* *
Expand All @@ -52,6 +53,6 @@ module.exports.i18n = {
* *
****************************************************************************/

// localesDirectory: '/config/locales'
localesDirectory: '/config/locales'

};
4 changes: 0 additions & 4 deletions config/locales/de.json

This file was deleted.

4 changes: 0 additions & 4 deletions config/locales/es.json

This file was deleted.

4 changes: 0 additions & 4 deletions config/locales/fr.json

This file was deleted.

4 changes: 4 additions & 0 deletions config/locales/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Welcome": "Привет",
"A brand new app.": "ПриветПриветПривет ."
}
2 changes: 1 addition & 1 deletion config/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports.models = {
* connections (see `config/connections.js`) *
* *
***************************************************************************/
// connection: 'localDiskDb',
connection: 'someMongodbServer'

/***************************************************************************
* *
Expand Down
1 change: 1 addition & 0 deletions config/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports.policies = {
* *
***************************************************************************/

'*' : 'localize'
// '*': true,

/***************************************************************************
Expand Down
7 changes: 6 additions & 1 deletion config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ module.exports.routes = {

'/': {
view: 'homepage'
}
},

'get /createVideo': 'VideoController.createVideo',
'post /createVideo': 'VideoController.createVideo',
'/:lang/showVideoList': 'VideoController.showVideoList',
'/:lang/showVideoItem/:id': 'VideoController.showVideoItem'

/***************************************************************************
* *
Expand Down

0 comments on commit 1fca38f

Please sign in to comment.