diff --git a/services/web/.gitignore b/services/web/.gitignore index b03b4ad35d..f9bcc5cd9b 100644 --- a/services/web/.gitignore +++ b/services/web/.gitignore @@ -67,3 +67,5 @@ Gemfile.lock .DS_Store app/views/external + +modules diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index 75a8bc4c02..83caa02d2c 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -10,7 +10,7 @@ module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-execute' grunt.loadNpmTasks 'grunt-bunyan' - grunt.initConfig + config = execute: app: src: "app.js" @@ -27,10 +27,6 @@ module.exports = (grunt) -> app: src: 'app.coffee' dest: 'app.js' - - BackgroundJobsWorker: - src: 'BackgroundJobsWorker.coffee' - dest: 'BackgroundJobsWorker.js' sharejs: options: @@ -163,6 +159,46 @@ module.exports = (grunt) -> "help" ] + moduleCompileServerTasks = [] + moduleCompileUnitTestTasks = [] + moduleUnitTestTasks = [] + for module in fs.readdirSync "./modules" + config.coffee["module_#{module}_server"] = { + expand: true, + flatten: false, + cwd: "modules/#{module}/app/coffee", + src: ['**/*.coffee'], + dest: "modules/#{module}/app/js", + ext: '.js' + } + config.coffee["module_#{module}_index"] = { + src: "modules/#{module}/index.coffee", + dest: "modules/#{module}/index.js" + } + + moduleCompileServerTasks.push "coffee:module_#{module}_server" + moduleCompileServerTasks.push "coffee:module_#{module}_index" + + config.coffee["module_#{module}_unit_tests"] = { + expand: true, + flatten: false, + cwd: "modules/#{module}/test/unit/coffee", + src: ['**/*.coffee'], + dest: "modules/#{module}/test/unit/js", + ext: '.js' + } + config.mochaTest["module_#{module}_unit"] = { + src: ["modules/#{module}/test/unit/js/*.js"] + options: + reporter: grunt.option('reporter') or 'spec' + grep: grunt.option("grep") + } + + moduleCompileUnitTestTasks.push "coffee:module_#{module}_unit_tests" + moduleUnitTestTasks.push "mochaTest:module_#{module}_unit" + + grunt.initConfig config + grunt.registerTask 'wrap_sharejs', 'Wrap the compiled ShareJS code for AMD module loading', () -> content = fs.readFileSync "public/js/libs/sharejs.js" fs.writeFileSync "public/js/libs/sharejs.js", """ @@ -174,7 +210,9 @@ module.exports = (grunt) -> grunt.registerTask 'help', 'Display this help list', 'availabletasks' - grunt.registerTask 'compile:server', 'Compile the server side coffee script', ['clean:app', 'coffee:app', 'coffee:app_dir'] + grunt.registerTask 'compile:modules:server', 'Compile all the modules', moduleCompileServerTasks + grunt.registerTask 'compile:modules:unit_tests', 'Compile all the modules unit tests', moduleCompileUnitTestTasks + grunt.registerTask 'compile:server', 'Compile the server side coffee script', ['clean:app', 'coffee:app', 'coffee:app_dir', 'compile:modules:server'] grunt.registerTask 'compile:client', 'Compile the client side coffee script', ['coffee:client', 'coffee:sharejs', 'wrap_sharejs'] grunt.registerTask 'compile:css', 'Compile the less files to css', ['less'] grunt.registerTask 'compile:minify', 'Concat and minify the client side js', ['requirejs'] @@ -187,6 +225,8 @@ module.exports = (grunt) -> grunt.registerTask 'test:unit', 'Run the unit tests (use --grep= or --feature= for individual tests)', ['compile:server', 'compile:unit_tests', 'mochaTest:unit'] grunt.registerTask 'test:smoke', 'Run the smoke tests', ['compile:smoke_tests', 'mochaTest:smoke'] + + grunt.registerTask 'test:modules:unit', 'Run the unit tests for the modules', ['compile:modules:server', 'compile:modules:unit_tests'].concat(moduleUnitTestTasks) grunt.registerTask 'run', "Compile and run the web-sharelatex server", ['compile', 'bunyan', 'execute'] grunt.registerTask 'default', 'run' diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index f078c31cb0..8019b6fb80 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -39,6 +39,7 @@ WikiController = require("./Features/Wiki/WikiController") ConnectedUsersController = require("./Features/ConnectedUsers/ConnectedUsersController") DropboxRouter = require "./Features/Dropbox/DropboxRouter" dropboxHandler = require "./Features/Dropbox/DropboxHandler" +Modules = require "./infrastructure/Modules" logger = require("logger-sharelatex") _ = require("underscore") @@ -67,6 +68,8 @@ module.exports = class Router StaticPagesRouter.apply(app) TemplatesRouter.apply(app) DropboxRouter.apply(app) + + Modules.applyRouter(app) app.get '/blog', BlogController.getIndexPage app.get '/blog/*', BlogController.getPage diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index b987d2fb7f..bdd6ac773d 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -88,6 +88,8 @@ module.exports = url: "http://localhost:3013" templates: url: "http://localhost:3007" + githubSync: + url: "http://localhost:3022" recurly: privateKey: "" apiKey: "" diff --git a/services/web/package.json b/services/web/package.json index 528f40e075..3210b72ab0 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -3,44 +3,44 @@ "version": "0.1.0", "description": "The HTTP front end for ShareLaTeX", "repository": { - "type": "git", + "type": "git", "url": "https://github.com/sharelatex/web-sharelatex.git" }, "directories": { "public": "./public" }, "dependencies": { - "express": "3.3.4", - "mongoose": "3.8.8", - "mongojs": "0.10.1", - "underscore": "1.6.0", - "rimraf": "2.2.6", - "connect-redis": "1.4.5", - "redis": "0.10.1", - "request": "2.34.0", - "xml2js": "0.2.0", - "dateformat": "1.0.4-1.2.3", - "optimist": "0.6.1", + "archiver": "0.9.0", "async": "0.6.2", - "lynx": "0.1.1", - "session.socket.io": "0.1.4", - "socket.io": "0.9.16", - "mimelib": "0.2.14", + "bcrypt": "0.7.5", "bufferedstream": "1.6.0", - "settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0", - "logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0", - "metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.0.0", - "translations-sharelatex": "git+https://github.com/sharelatex/translations-sharelatex.git#master", - "soa-req-id": "git+https://github.com/sharelatex/soa-req-id.git#v1.0.0", + "connect-redis": "1.4.5", + "dateformat": "1.0.4-1.2.3", + "express": "3.3.4", "fairy": "0.0.2", + "jade": "~1.3.1", + "logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0", + "lynx": "0.1.1", + "metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.0.0", + "mimelib": "0.2.14", + "mocha": "1.17.1", + "mongojs": "0.10.1", + "mongoose": "3.8.8", "node-uuid": "1.4.1", "nodemailer": "0.6.1", - "bcrypt": "0.7.5", - "archiver": "0.9.0", - "mocha": "1.17.1", + "optimist": "0.6.1", "redback": "0.4.0", + "redis": "0.10.1", + "request": "2.34.0", + "rimraf": "2.2.6", "sanitizer": "0.1.1", - "jade": "~1.3.1" + "session.socket.io": "0.1.4", + "settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0", + "soa-req-id": "git+https://github.com/sharelatex/soa-req-id.git#v1.0.0", + "socket.io": "0.9.16", + "translations-sharelatex": "git+https://github.com/sharelatex/translations-sharelatex.git#master", + "underscore": "1.6.0", + "xml2js": "0.2.0" }, "devDependencies": { "chai": "",