From 10732d112d516ad4b2a407ca7751b39a6e2a657e Mon Sep 17 00:00:00 2001 From: James Allen Date: Fri, 3 Oct 2014 11:32:59 +0100 Subject: [PATCH] Hook module system into project list page --- services/web/Gruntfile.coffee | 18 ++++++++++++++++++ .../app/coffee/infrastructure/Modules.coffee | 2 +- .../web/app/views/project/list/side-bar.jade | 1 + services/web/public/coffee/main.coffee | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index 34bfcbbadb..213dc1ebb2 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -164,6 +164,7 @@ module.exports = (grunt) -> moduleUnitTestTasks = [] moduleCompileClientTasks = [] moduleIdeClientSideIncludes = [] + moduleMainClientSideIncludes = [] if fs.existsSync "./modules" for module in fs.readdirSync "./modules" if fs.existsSync "./modules/#{module}/index.coffee" @@ -201,6 +202,7 @@ module.exports = (grunt) -> moduleCompileUnitTestTasks.push "coffee:module_#{module}_unit_tests" moduleUnitTestTasks.push "mochaTest:module_#{module}_unit" + if fs.existsSync "./modules/#{module}/public/coffee/ide/index.coffee" config.coffee["module_#{module}_client_ide"] = { expand: true, flatten: false, @@ -211,6 +213,18 @@ module.exports = (grunt) -> } moduleCompileClientTasks.push "coffee:module_#{module}_client_ide" moduleIdeClientSideIncludes.push "ide/#{module}/index" + + if fs.existsSync "./modules/#{module}/public/coffee/main/index.coffee" + config.coffee["module_#{module}_client_main"] = { + expand: true, + flatten: false, + cwd: "modules/#{module}/public/coffee/main", + src: ['**/*.coffee'], + dest: "public/js/main/#{module}", + ext: '.js' + } + moduleCompileClientTasks.push "coffee:module_#{module}_client_main" + moduleMainClientSideIncludes.push "main/#{module}/index" grunt.initConfig config @@ -232,6 +246,10 @@ module.exports = (grunt) -> content = fs.readFileSync("public/js/ide.js").toString() content = content.replace(/"__IDE_CLIENTSIDE_INCLUDES__"/g, moduleIdeClientSideIncludes.map((i) -> "\"#{i}\"").join(", ")) fs.writeFileSync "public/js/ide.js", content + + content = fs.readFileSync("public/js/main.js").toString() + content = content.replace(/"__MAIN_CLIENTSIDE_INCLUDES__"/g, moduleMainClientSideIncludes.map((i) -> "\"#{i}\"").join(", ")) + fs.writeFileSync "public/js/main.js", content 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', "compile:modules:client", 'compile:modules:inject_clientside_includes'] diff --git a/services/web/app/coffee/infrastructure/Modules.coffee b/services/web/app/coffee/infrastructure/Modules.coffee index 664be5fa27..4c45e488e1 100644 --- a/services/web/app/coffee/infrastructure/Modules.coffee +++ b/services/web/app/coffee/infrastructure/Modules.coffee @@ -29,7 +29,7 @@ module.exports = Modules = partials = Modules.viewIncludes[view] or [] html = "" for partial in partials - compiler = jade.compile(partial) + compiler = jade.compile(partial, doctype: "html") html += compiler(locals) return html diff --git a/services/web/app/views/project/list/side-bar.jade b/services/web/app/views/project/list/side-bar.jade index 3da80de978..15fa928ddd 100644 --- a/services/web/app/views/project/list/side-bar.jade +++ b/services/web/app/views/project/list/side-bar.jade @@ -21,6 +21,7 @@ href, ng-click="openUploadProjectModal()" ) #{translate("upload_project")} + !{moduleIncludes("newProjectMenu", locals)} if (templates) li.divider li.dropdown-header #{translate("templates")} diff --git a/services/web/public/coffee/main.coffee b/services/web/public/coffee/main.coffee index 683fb23b4f..9998979a63 100644 --- a/services/web/public/coffee/main.coffee +++ b/services/web/public/coffee/main.coffee @@ -22,5 +22,6 @@ define [ "directives/selectAll" "directives/maxHeight" "filters/formatDate" + "__MAIN_CLIENTSIDE_INCLUDES__" ], () -> angular.bootstrap(document.body, ["SharelatexApp"])