diff --git a/api/controllers/VideoController.js b/api/controllers/VideoController.js new file mode 100644 index 0000000..bdc904c --- /dev/null +++ b/api/controllers/VideoController.js @@ -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!' +// }); +//} +}; + diff --git a/api/models/Video.js b/api/models/Video.js new file mode 100644 index 0000000..2583edf --- /dev/null +++ b/api/models/Video.js @@ -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' } + } + } +}; + diff --git a/api/policies/localize.js b/api/policies/localize.js new file mode 100644 index 0000000..732414c --- /dev/null +++ b/api/policies/localize.js @@ -0,0 +1,6 @@ +module.exports = function(req, res, next) { + + req.locale=req.param('ln'); + next(); + +}; \ No newline at end of file diff --git a/config/connections.js b/config/connections.js index 3a8eefc..933cc07 100644 --- a/config/connections.js +++ b/config/connections.js @@ -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', @@ -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', @@ -84,9 +84,9 @@ module.exports.connections = { /*************************************************************************** - * * - * More adapters: https://github.com/balderdashy/sails * - * * - ***************************************************************************/ + * * + * More adapters: https://github.com/balderdashy/sails * + * * + ***************************************************************************/ }; diff --git a/config/i18n.js b/config/i18n.js index facf707..86acf66 100644 --- a/config/i18n.js +++ b/config/i18n.js @@ -23,7 +23,7 @@ module.exports.i18n = { * * ***************************************************************************/ - // locales: ['en', 'es', 'fr', 'de'], + locales: ['en', 'ru'], /**************************************************************************** * * @@ -34,7 +34,7 @@ module.exports.i18n = { * * ****************************************************************************/ - // defaultLocale: 'en', + defaultLocale: 'ru', /**************************************************************************** * * @@ -43,7 +43,8 @@ module.exports.i18n = { * * ****************************************************************************/ - // updateFiles: false, + updateFiles: true, + //, /**************************************************************************** * * @@ -52,6 +53,6 @@ module.exports.i18n = { * * ****************************************************************************/ - // localesDirectory: '/config/locales' + localesDirectory: '/config/locales' }; diff --git a/config/locales/de.json b/config/locales/de.json deleted file mode 100644 index 12f23d9..0000000 --- a/config/locales/de.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Welcome": "Willkommen", - "A brand new app.": "Eine neue App." -} diff --git a/config/locales/es.json b/config/locales/es.json deleted file mode 100644 index 91f8248..0000000 --- a/config/locales/es.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Welcome": "Bienvenido", - "A brand new app.": "Una aplicación de la nueva marca." -} diff --git a/config/locales/fr.json b/config/locales/fr.json deleted file mode 100644 index 972935c..0000000 --- a/config/locales/fr.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Welcome": "Bienvenue", - "A brand new app.": "Une toute nouvelle application." -} diff --git a/config/locales/ru.json b/config/locales/ru.json new file mode 100644 index 0000000..6e4fc42 --- /dev/null +++ b/config/locales/ru.json @@ -0,0 +1,4 @@ +{ + "Welcome": "Привет", + "A brand new app.": "ПриветПриветПривет ." +} diff --git a/config/models.js b/config/models.js index 49ac9ee..5d395f9 100644 --- a/config/models.js +++ b/config/models.js @@ -17,7 +17,7 @@ module.exports.models = { * connections (see `config/connections.js`) * * * ***************************************************************************/ - // connection: 'localDiskDb', + connection: 'someMongodbServer' /*************************************************************************** * * diff --git a/config/policies.js b/config/policies.js index 1785d4e..2a2da2b 100644 --- a/config/policies.js +++ b/config/policies.js @@ -26,6 +26,7 @@ module.exports.policies = { * * ***************************************************************************/ + '*' : 'localize' // '*': true, /*************************************************************************** diff --git a/config/routes.js b/config/routes.js index 5d769d3..309d7ac 100644 --- a/config/routes.js +++ b/config/routes.js @@ -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' /*************************************************************************** * *