Commit 806255a3 authored by Tuan Tuan LE's avatar Tuan Tuan LE
Browse files

Bootstrap module

parents
{
"directory": "frontend/components"
}
\ No newline at end of file
{
"extends": "linagora-esn",
"rules": {
"arrow-parens": ["error", "as-needed"],
"no-console": ["error", { "allow": ["warn", "error"] }]
}
}
node_modules
frontend/components
.idea
*.log
package-lock.json
yarn.lock
8
\ No newline at end of file
'use strict';
/* eslint-disable no-process-env */
const timeGrunt = require('time-grunt');
module.exports = function(grunt) {
timeGrunt(grunt);
grunt.initConfig({
eslint: {
options: {
config: '.eslintrc'
},
quick: {
src: [],
options: {
quiet: true
}
},
all: {
src: ['*.js', 'tasks/**/*.js', 'test/**/*.js', 'test/**/**/*.js', 'backend/**/*.js', 'frontend/app/**/*.js']
}
},
lint_pattern: {
options: {
rules: [
{ pattern: /(describe|it)\.only/, message: 'Must not use .only in tests' }
]
},
all: {
src: ['<%= eslint.all.src %>']
},
css: {
options: {
rules: [
{ pattern: /important;(\s*$|(?=\s+[^\/]))/, message: 'CSS important rules only allowed with explanatory comment' }
]
},
src: [
'frontend/app/**/*.less'
]
},
quick: {
src: ['<%= eslint.quick.src %>']
}
},
i18n_checker: {
all: {
options: {
baseDir: __dirname,
dirs: [{
localeDir: 'backend/lib/i18n/locales',
templateSrc: [
'frontend/app/**/*.pug'
],
core: true
}],
verifyOptions: {
defaultLocale: 'en',
locales: ['en', 'fr', 'vi'],
rules: [
'all-keys-translated',
'all-locales-present',
'default-locale-translate',
'key-trimmed',
'no-duplicate-among-modules',
'no-duplicate-with-core',
'no-untranslated-key',
'valid-json-file'
]
}
}
}
},
puglint: {
all: {
options: {
config: {
disallowAttributeInterpolation: true,
disallowLegacyMixinCall: true,
validateExtensions: true,
validateIndentation: 2
}
},
src: [
'frontend/**/*.pug'
]
}
},
splitfiles: {
options: {
chunk: 1
},
midway: {
options: {
common: ['test/midway-backend/all.js'],
target: 'mochacli:midway'
},
files: {
src: ['test/midway-backend/**/*.js']
}
}
},
mochacli: {
options: {
require: ['chai', 'mockery'],
reporter: 'spec',
timeout: process.env.TEST_TIMEOUT || 5000
},
backend: {
options: {
files: ['test/unit-backend/all.js', grunt.option('test') || 'test/unit-backend/**/*.js']
}
}
},
karma: {
unit: {
configFile: './test/config/karma.conf.js',
browsers: ['PhantomJS']
}
}
});
grunt.loadTasks('tasks');
grunt.loadNpmTasks('@linagora/grunt-lint-pattern');
grunt.loadNpmTasks('@linagora/grunt-i18n-checker');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-mocha-cli');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-puglint');
grunt.registerTask('i18n', 'Check the translation files', ['i18n_checker']);
grunt.registerTask('pug-linter', 'Check the pug/jade files', ['puglint:all']);
grunt.registerTask('linters', 'Check code for lint', ['eslint:all', 'lint_pattern:all', 'lint_pattern:css', 'i18n', 'pug-linter']);
grunt.registerTask('linters-dev', 'Check changed files for lint', ['prepare-quick-lint', 'eslint:quick', 'lint_pattern:quick']);
grunt.registerTask('test-midway-backend', ['splitfiles:midway']);
grunt.registerTask('test-unit-backend', 'Test backend code', ['mochacli:backend']);
grunt.registerTask('test-unit-frontend', 'Test frontend code', ['karma:unit']);
grunt.registerTask('test', ['linters', 'test-unit-frontend', 'test-unit-backend', 'test-midway-backend']);
grunt.registerTask('default', ['test']);
};
# linagora.esn.most
Vietnam ministry of science and technology project
'use strict';
// arguments: dependencies
module.exports = function() {
// const model = require('./YOUR_MODEL')(dependencies);
return {
// model
};
};
'use strict';
module.exports = function(dependencies) {
const i18n = dependencies('i18n');
i18n.setDefaultConfiguration({ directory: __dirname + '/locales' });
return i18n;
};
{
"My sidebar" : "My sidebar"
}
{
"My sidebar" : "Ma barre latérale"
}
{
"My sidebar" : "Thanh bên của tôi"
}
'use strict';
module.exports = function(dependencies) {
const models = require('./db')(dependencies);
return {
models
};
};
'use strict';
module.exports = function(dependencies, lib, router) {
const authorizationMW = dependencies('authorizationMW');
const exampleController = require('../controllers/example')(dependencies, lib);
router.get('/example', authorizationMW.requiresAPILogin, exampleController.example);
};
'use strict';
const express = require('express');
module.exports = function(dependencies, lib) {
const router = express.Router();
require('./example')(dependencies, lib, router);
return router;
};
'use strict';
const express = require('express');
// This is you own express application
module.exports = function(dependencies) {
const application = express();
// Every express new configuration are appended here.
// This needs to be initialized before the body parser
require('./config/i18n')(dependencies, application);
require('./config/views')(dependencies, application);
return application;
};
'use strict';
module.exports = function(dependencies, application) {
var i18n = require('../../lib/i18n')(dependencies);
application.use(i18n.init);
};
'use strict';
const express = require('express');
const FRONTEND_PATH = require('../constants').FRONTEND_PATH;
const CORE_FRONTEND_PATH = require('../constants').CORE_FRONTEND_PATH;
module.exports = function(dependencies, application) {
application.use(express.static(FRONTEND_PATH));
application.set('views', FRONTEND_PATH + '/app');
application.get('/app/*', function(req, res) {
const templateName = req.params[0].replace(/\.html$/, '');
res.render(templateName, { basedir: CORE_FRONTEND_PATH + '/views' });
});
};
'use strict';
const path = require('path');
module.exports.FRONTEND_PATH = path.normalize(__dirname + '/../../frontend');
module.exports.CORE_FRONTEND_PATH = path.normalize(path.dirname(require.main.filename) + '/frontend');
'use strict';
// arguments: dependencies, lib
module.exports = function() {
function example(req, res) {
return res.status(200).json({ message: 'controller example' });
}
return {
example
};
};
'use strict';
module.exports = {
// define helpers that are shared by webserver file
// example:
// createErrorMessage: function(error, errDetail) {
// return {
// error: {
// code: 500,
// message: errDetail || 'Server Error',
// details: error.message
// }
// };
// }
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment