From 7310e42d9ec06a926fb26582294b84e83d72be26 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Wed, 12 Nov 2014 12:33:25 +0100 Subject: [PATCH 01/29] Do not specify Webpack loaders in requires Signed-off-by: Alex Coles --- app/assets/javascripts/angular/openproject-app.js | 4 ++-- webpack.config.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/angular/openproject-app.js b/app/assets/javascripts/angular/openproject-app.js index a051276f2b..8af314ba1f 100644 --- a/app/assets/javascripts/angular/openproject-app.js +++ b/app/assets/javascripts/angular/openproject-app.js @@ -28,8 +28,8 @@ var I18n = require('./vendor/i18n'); window.I18n = I18n; -I18n.translations.de = require("json!yaml!./../../../../config/locales/js-de.yml").de; -I18n.translations.en = require("json!yaml!./../../../../config/locales/js-en.yml").en; +I18n.translations.de = require("locales/js-de.yml").de; +I18n.translations.en = require("locales/js-en.yml").en; var angular = require('angular'); require('angular-animate'); diff --git a/webpack.config.js b/webpack.config.js index 08795ddd7f..7025fc5f04 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -13,7 +13,8 @@ module.exports = { module: { loaders: [ - { test: /[\/]angular\.js$/, loader: "exports?angular" } + { test: /[\/]angular\.js$/, loader: "exports?angular" }, + { test: /js-\w{2}\.yml$/, loader: 'json!yaml' } ] }, @@ -25,6 +26,8 @@ module.exports = { ], alias: { + locales: path.join(__dirname, 'config', 'locales'), + 'angular-ui-date': 'angular-ui-date/src/date', 'angular-truncate': 'angular-truncate/src/truncate', 'angular-feature-flags': 'angular-feature-flags/dist/featureFlags.js', From c416e73971665843bc0ace893e5025941122e46b Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Wed, 12 Nov 2014 12:39:59 +0100 Subject: [PATCH 02/29] Specify resolve.root, DRY paths in Webpack config Signed-off-by: Alex Coles --- webpack.config.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 7025fc5f04..bdbf77a61f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -19,14 +19,15 @@ module.exports = { }, resolve: { - //root: [path.join(__dirname, 'vendor', 'assets', 'components')] + root: __dirname, + modulesDirectories: [ - path.join(__dirname, 'node_modules'), - path.join(__dirname, 'vendor', 'assets', 'components') + 'node_modules', + 'vendor/assets/components' ], alias: { - locales: path.join(__dirname, 'config', 'locales'), + 'locales': 'config/locales', 'angular-ui-date': 'angular-ui-date/src/date', 'angular-truncate': 'angular-truncate/src/truncate', From 548a88bb92e76fc6c1ac27f28e6eabe3d3d7d894 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 13 Nov 2014 15:04:43 +0100 Subject: [PATCH 03/29] Expose I18n as global with Webpack expose-loader Signed-off-by: Alex Coles --- app/assets/javascripts/angular/openproject-app.js | 1 - package.json | 1 + webpack.config.js | 5 +++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/angular/openproject-app.js b/app/assets/javascripts/angular/openproject-app.js index 8af314ba1f..9114c6db46 100644 --- a/app/assets/javascripts/angular/openproject-app.js +++ b/app/assets/javascripts/angular/openproject-app.js @@ -27,7 +27,6 @@ //++ var I18n = require('./vendor/i18n'); -window.I18n = I18n; I18n.translations.de = require("locales/js-de.yml").de; I18n.translations.en = require("locales/js-en.yml").en; diff --git a/package.json b/package.json index f251a53c07..ec8904f9e0 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "URIjs": "^1.14.1", "bower": "~1.3.8", "exports-loader": "^0.6.2", + "expose-loader": "^0.6.0", "json-loader": "^0.5.1", "webpack": "^1.4.9", "yaml-loader": "^0.1.0" diff --git a/webpack.config.js b/webpack.config.js index bdbf77a61f..c83809cb4b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -13,8 +13,9 @@ module.exports = { module: { loaders: [ - { test: /[\/]angular\.js$/, loader: "exports?angular" }, - { test: /js-\w{2}\.yml$/, loader: 'json!yaml' } + { test: /[\/]angular\.js$/, loader: "exports?angular" }, + { test: /[\/]vendor[\/]i18n\.js$/, loader: "expose?I18n" }, + { test: /js-\w{2}\.yml$/, loader: 'json!yaml' }, ] }, From dbc840e1211afdb1d65b2a0446915099f138f0ce Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 13 Nov 2014 17:45:59 +0100 Subject: [PATCH 04/29] Add shelljs for synchronous command exec Signed-off-by: Alex Coles --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ec8904f9e0..49b439b65d 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "exports-loader": "^0.6.2", "expose-loader": "^0.6.0", "json-loader": "^0.5.1", + "shelljs": "^0.3.0", "webpack": "^1.4.9", "yaml-loader": "^0.1.0" }, From 1acafcaa269b3f82f47018f7286f14f64856e106 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 13 Nov 2014 19:02:44 +0100 Subject: [PATCH 05/29] Add helpers to make node translations-plugin aware Signed-off-by: Alex Coles --- config/rails-plugins.conf.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 config/rails-plugins.conf.js diff --git a/config/rails-plugins.conf.js b/config/rails-plugins.conf.js new file mode 100644 index 0000000000..f810d43d0c --- /dev/null +++ b/config/rails-plugins.conf.js @@ -0,0 +1,33 @@ +require('shelljs/global'); +var path = require('path'); + +function rubyBundler(subCmd) { + var fullCmd = exec('bundle ' + subCmd); + return fullCmd.code === 0 ? fullCmd.output : null; +} + +var TranslationsPlugin = { + envPath: function() { + if (env['OPENPROJECT_TRANSLATIONS_ROOT']) { + return path.resolve(__dirname, '..', env['OPENPROJECT_TRANSLATIONS_ROOT']); + } + }, + + findBundlerPath: function() { + return rubyBundler('show openproject-translations'); + }, + + findPluginPath: function() { + return this.envPath() || this.findBundlerPath() || ''; + }, + + findLocaleFiles: function() { + var localeFilePath = path.join(this.findPluginPath(), 'config', 'locales'); + return find(localeFilePath).filter(function(file) { + return file.match(/js-([\w|-]){2,5}\.yml$/); + }); + } +}; + +exports.translationsPluginLocales = TranslationsPlugin.findLocaleFiles(); +exports.translationsPluginPath = TranslationsPlugin.findPluginPath(); From 53c900fa3c6d812c5c7b3e917dfadafe40cf2763 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Wed, 12 Nov 2014 14:44:59 +0100 Subject: [PATCH 06/29] Teach Webpack to bundle translations plugin locales Bug # 14679 Signed-off-by: Alex Coles --- app/assets/javascripts/angular/openproject-app.js | 11 ++++++++++- webpack.config.js | 14 ++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/angular/openproject-app.js b/app/assets/javascripts/angular/openproject-app.js index 9114c6db46..1b68f5b6b7 100644 --- a/app/assets/javascripts/angular/openproject-app.js +++ b/app/assets/javascripts/angular/openproject-app.js @@ -27,8 +27,17 @@ //++ var I18n = require('./vendor/i18n'); -I18n.translations.de = require("locales/js-de.yml").de; + +// standard locales I18n.translations.en = require("locales/js-en.yml").en; +I18n.translations.de = require("locales/js-de.yml").de; + +// extra locales, automatically loaded +var requireExtraLocale = require.context('extra-locales', false, /js-[\w|-]{2,5}\.yml$/); +requireExtraLocale.keys().forEach(function(localeFile) { + var locale = localeFile.match(/js-([\w|-]{2,5})\.yml/)[1]; + I18n.translations[locale] = requireExtraLocale(localeFile)[locale]; +}); var angular = require('angular'); require('angular-animate'); diff --git a/webpack.config.js b/webpack.config.js index c83809cb4b..001e10f2c2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,6 @@ -var webpack = require('webpack'), - path = require('path'); +var webpack = require('webpack'), + path = require('path'), + pathConfig = require('./config/rails-plugins.conf'); module.exports = { context: __dirname + '/app/assets/javascripts/angular', @@ -15,7 +16,7 @@ module.exports = { loaders: [ { test: /[\/]angular\.js$/, loader: "exports?angular" }, { test: /[\/]vendor[\/]i18n\.js$/, loader: "expose?I18n" }, - { test: /js-\w{2}\.yml$/, loader: 'json!yaml' }, + { test: /js-[\w|-]{2,5}\.yml$/, loader: 'json!yaml' } ] }, @@ -28,7 +29,8 @@ module.exports = { ], alias: { - 'locales': 'config/locales', + 'locales': 'config/locales', + 'extra-locales': path.join(pathConfig.translationsPluginPath, 'config', 'locales'), 'angular-ui-date': 'angular-ui-date/src/date', 'angular-truncate': 'angular-truncate/src/truncate', @@ -40,6 +42,10 @@ module.exports = { } }, + resolveLoader: { + root: __dirname + '/node_modules' + }, + externals: { jquery: "jQuery" }, plugins: [ From b2ed2e24ee6eb14ffee95a31072f7421a8aea197 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 13 Nov 2014 20:35:37 +0100 Subject: [PATCH 07/29] Remove i18n-js (as gem dependency) Translations are now bundled by Webpack. Signed-off-by: Alex Coles --- Gemfile | 2 - Gemfile.lock | 3 -- app/assets/javascripts/application.js.erb | 1 - config/i18n-js.yml | 50 ------------------ config/initializers/i18n-js.rb | 64 ----------------------- 5 files changed, 120 deletions(-) delete mode 100644 config/i18n-js.yml delete mode 100644 config/initializers/i18n-js.rb diff --git a/Gemfile b/Gemfile index c3c332926e..b812412518 100644 --- a/Gemfile +++ b/Gemfile @@ -105,8 +105,6 @@ gem "prototype-rails" # replace those with :remote => true gem 'prototype_legacy_helper', '0.0.0', :git => 'https://github.com/rails/prototype_legacy_helper.git' -gem 'i18n-js', '~> 3.0.0.rc6' - # small wrapper around the command line gem 'cocaine' diff --git a/Gemfile.lock b/Gemfile.lock index 4e95ba0782..964311207a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -192,8 +192,6 @@ GEM hooks (0.3.3) htmldiff (0.0.1) i18n (0.6.11) - i18n-js (3.0.0.rc6) - i18n (~> 0.6) ice_nine (0.11.0) interception (0.3) iso8601 (0.8.2) @@ -441,7 +439,6 @@ DEPENDENCIES gravatar_image_tag (~> 1.2.0) htmldiff i18n (>= 0.6.8) - i18n-js (~> 3.0.0.rc6) jruby-openssl json_spec launchy (~> 2.3.0) diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 054312acb6..9bcc17470a 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -29,7 +29,6 @@ //= require effects //= require dragdrop //= require controls -//= require i18n/translations //= require lib/jquery.colorcontrast //= require lib/jquery.trap diff --git a/config/i18n-js.yml b/config/i18n-js.yml deleted file mode 100644 index 076d2a854c..0000000000 --- a/config/i18n-js.yml +++ /dev/null @@ -1,50 +0,0 @@ -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2014 the OpenProject Foundation (OPF) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See doc/COPYRIGHT.rdoc for more details. -#++ - -# Only export keys within the js scope, supporting two levels of nesting, -# e.g.: -# -# en: -# js: -# error_message: An error occurred. -# my_plugin_name: -# js: -# welcome_text: Welcome back. -# user: -# js: -# project_name: Project name: -# admin: -# js: -# delete_project: Delete Project! -# -translations: -- file: "public/javascripts/i18n/translations.js" - only: - - '*.js' - - '*.*.js' - - '*.*.*.js' diff --git a/config/initializers/i18n-js.rb b/config/initializers/i18n-js.rb deleted file mode 100644 index a24444a712..0000000000 --- a/config/initializers/i18n-js.rb +++ /dev/null @@ -1,64 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2014 the OpenProject Foundation (OPF) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See doc/COPYRIGHT.rdoc for more details. -#++ - -# Note: This monkey patch was written to enable configurations like: -# -# only: -# - '*.js' -# - '*.*.js' -# - '*.*.*.js' -# -# in combination with unevenly nested translations, i.e. -# en: -# foo: Foo -# js: -# foo: Foo -# bar: -# baz: Baz -# -# NB: On some levels, there are String _and_ Hash values. -# -# The original code only expected to see Hashes, while in the above setup, there -# might be other values as well. These may be ignored by `filter`, since these -# values will not contain the relevant translations. -# -# At the moment, we are not posting a pull request including the changes to the -# original author, since s/he is working on a rewrite of i18n-js and s/he does -# not seem to accept even the simplest pull request. We should try again, when -# the `rewrite` branch of i18n-js is released to master. -# -# Written against i18n-js rewrite branch -I18n::JS.module_eval do - class << self - def filter_with_uneven_nesting_fix(translations, scopes) - filter_without_uneven_nesting_fix(translations, scopes) if translations.is_a? Hash - end - alias_method_chain :filter, :uneven_nesting_fix - end -end From 35f2c7a978ddadbc20a6d60ed80968bb3dc51cf4 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Tue, 18 Nov 2014 19:16:43 +0100 Subject: [PATCH 08/29] Add lodash (as npm dependency) Signed-off-by: Alex Coles --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 49b439b65d..35b8845ef7 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "exports-loader": "^0.6.2", "expose-loader": "^0.6.0", "json-loader": "^0.5.1", + "lodash": "^2.4.1", "shelljs": "^0.3.0", "webpack": "^1.4.9", "yaml-loader": "^0.1.0" From 15ca1a0999c7b48709b0cfa531cd9c7c25ba01e9 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Tue, 18 Nov 2014 18:52:23 +0100 Subject: [PATCH 09/29] Flesh out helpers to support all OP(Rails) plugins This currently use a very native approach to determines if a gem is a OpenProject plugin - simply matching 'openproject-'. Signed-off-by: Alex Coles --- config/rails-plugins.conf.js | 41 ++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/config/rails-plugins.conf.js b/config/rails-plugins.conf.js index f810d43d0c..971a1e96ff 100644 --- a/config/rails-plugins.conf.js +++ b/config/rails-plugins.conf.js @@ -1,11 +1,41 @@ require('shelljs/global'); -var path = require('path'); +var path = require('path'), + _ = require('lodash'); function rubyBundler(subCmd) { - var fullCmd = exec('bundle ' + subCmd); + var fullCmd = exec('bundle ' + subCmd, { silent: true }); return fullCmd.code === 0 ? fullCmd.output : null; } +var OpenProjectPlugins = { + pluginPaths: _.memoize(function() { + var allPaths = (rubyBundler('list --paths') || '').split('\n'); + return allPaths.filter(function(name) { + // naive match + return name.match(/openproject-/); + }); + }), + + pluginNamesPaths: function() { + return this.pluginPaths().reduce(function(obj, pluginPath) { + var pluginName = path.basename(pluginPath).replace(/-[0-9a-fA-F]{12}$/, ''); + obj[pluginName] = pluginPath; + return obj; + }, {}); + }, + + findPluginPath: _.memoize(function(name) { + return this.pluginNamesPaths()[name]; + }, _.identity), + + pluginDirectories: function() { + return this.pluginPaths().reduce(function(dirList, pluginPath) { + var pluginDir = path.dirname(pluginPath); + return dirList.indexOf(pluginDir) === -1 ? dirList.concat(pluginDir) : dirList; + }, []); + } +}; + var TranslationsPlugin = { envPath: function() { if (env['OPENPROJECT_TRANSLATIONS_ROOT']) { @@ -13,12 +43,8 @@ var TranslationsPlugin = { } }, - findBundlerPath: function() { - return rubyBundler('show openproject-translations'); - }, - findPluginPath: function() { - return this.envPath() || this.findBundlerPath() || ''; + return this.envPath() || OpenProjectPlugins.findPluginPath('openproject-translations') || ''; }, findLocaleFiles: function() { @@ -29,5 +55,6 @@ var TranslationsPlugin = { } }; +exports.pluginDirectories = OpenProjectPlugins.pluginDirectories(); exports.translationsPluginLocales = TranslationsPlugin.findLocaleFiles(); exports.translationsPluginPath = TranslationsPlugin.findPluginPath(); From 29b60dfcaa63244ee0b1a4081c871ec152b1b966 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 20 Nov 2014 16:47:34 +0100 Subject: [PATCH 10/29] Filter out OP(Rails) plugins without package.json Signed-off-by: Alex Coles --- config/rails-plugins.conf.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/rails-plugins.conf.js b/config/rails-plugins.conf.js index 971a1e96ff..5632788a4c 100644 --- a/config/rails-plugins.conf.js +++ b/config/rails-plugins.conf.js @@ -19,7 +19,11 @@ var OpenProjectPlugins = { pluginNamesPaths: function() { return this.pluginPaths().reduce(function(obj, pluginPath) { var pluginName = path.basename(pluginPath).replace(/-[0-9a-fA-F]{12}$/, ''); - obj[pluginName] = pluginPath; + if (test('-e', path.join(pluginPath, 'package.json'))) { + obj[pluginName] = pluginPath; + } else { + console.info('INFO: plugin "%s" does not provide a package.json', pluginName); + } return obj; }, {}); }, From d243fd30dc91fffa0b40220ef215587d9011933b Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Tue, 18 Nov 2014 19:28:54 +0100 Subject: [PATCH 11/29] Add Rails plugin dirs to Webpack modulesDirectories This should allow Webpack to bundle assets from Rails plugins/gems, as if they were npm modules or Bower components, but without us having to add an entry to core's `package.json`/`bower.json`. Signed-off-by: Alex Coles --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 001e10f2c2..e810be13c2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -26,7 +26,7 @@ module.exports = { modulesDirectories: [ 'node_modules', 'vendor/assets/components' - ], + ].concat(pathConfig.pluginDirectories), alias: { 'locales': 'config/locales', From 04c285ae56e5390c9d1c89c27bbcf7fb163ac78e Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 20 Nov 2014 14:25:15 +0100 Subject: [PATCH 12/29] Add I18n function for plugins to add translations Signed-off-by: Alex Coles --- app/assets/javascripts/angular/openproject-app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/javascripts/angular/openproject-app.js b/app/assets/javascripts/angular/openproject-app.js index 1b68f5b6b7..31bd846e63 100644 --- a/app/assets/javascripts/angular/openproject-app.js +++ b/app/assets/javascripts/angular/openproject-app.js @@ -39,6 +39,11 @@ requireExtraLocale.keys().forEach(function(localeFile) { I18n.translations[locale] = requireExtraLocale(localeFile)[locale]; }); +I18n.addTranslations = function(locale, translations) { + I18n.translations[locale] = _.merge(I18n.translations[locale], translations); +}; + + var angular = require('angular'); require('angular-animate'); require('angular-modal'); From 3d34ff2eda73966d49dad2d781428260531f0755 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 20 Nov 2014 15:20:39 +0100 Subject: [PATCH 13/29] Create Webpack entry points for each plugin User Story # #5697 Signed-off-by: Alex Coles --- .gitignore | 2 +- app/assets/javascripts/application.js.erb | 3 ++- config/rails-plugins.conf.js | 1 + webpack.config.js | 14 +++++++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c882a30968..72e6c49ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,7 @@ /backup /.project /.loadpath -/app/assets/javascripts/openproject-app.bundle.js* +/app/assets/javascripts/bundles/*.js* /config/additional_environment.rb /config/configuration.yml /config/database.yml diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 9bcc17470a..fdd8086a03 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -54,7 +54,8 @@ //= require versions //= require_tree ./specific -//= require ./openproject-app.bundle +//= require ./bundles/openproject-app +//= require_tree ./bundles //source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse if (typeof []._reverse == 'undefined') { diff --git a/config/rails-plugins.conf.js b/config/rails-plugins.conf.js index 5632788a4c..538d55471d 100644 --- a/config/rails-plugins.conf.js +++ b/config/rails-plugins.conf.js @@ -59,6 +59,7 @@ var TranslationsPlugin = { } }; +exports.pluginNamesPaths = OpenProjectPlugins.pluginNamesPaths(); exports.pluginDirectories = OpenProjectPlugins.pluginDirectories(); exports.translationsPluginLocales = TranslationsPlugin.findLocaleFiles(); exports.translationsPluginPath = TranslationsPlugin.findPluginPath(); diff --git a/webpack.config.js b/webpack.config.js index e810be13c2..b3517cf9fe 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,15 +1,23 @@ var webpack = require('webpack'), path = require('path'), + _ = require('lodash'), pathConfig = require('./config/rails-plugins.conf'); +var pluginEntries = _.reduce(pathConfig.pluginNamesPaths, function(entries, path, name) { + entries[name.replace(/^openproject\-/, '')] = name; + return entries; +}, {}); + module.exports = { context: __dirname + '/app/assets/javascripts/angular', - entry: './openproject-app.js', + entry: _.merge({ + app: './openproject-app.js' + }, pluginEntries), output: { - filename: 'openproject-app.bundle.js', - path: path.join(__dirname, 'app', 'assets', 'javascripts') + filename: 'openproject-[name].js', + path: path.join(__dirname, 'app', 'assets', 'javascripts', 'bundles') }, module: { From 289b8f8cf131615b399070b4338b4e28fafeba6b Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 20 Nov 2014 18:15:31 +0100 Subject: [PATCH 14/29] Update paths in Protractor HTML file, gulp tasks Changed in previous commit 3d34ff2e. Signed-off-by: Alex Coles --- gulpfile.js | 2 +- protractor/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 4d746b0e97..22e9badc54 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -56,7 +56,7 @@ gulp.task('lint', function() { gulp.task('webpack', function() { return gulp.src('app/assets/javascripts/angular/openproject-app.js') .pipe(gulpWebpack(config)) - .pipe(gulp.dest('app/assets/javascripts/')); + .pipe(gulp.dest('app/assets/javascripts/bundles')); }); gulp.task('sass', function() { diff --git a/protractor/index.html b/protractor/index.html index 528eb543a8..49b4c9e132 100644 --- a/protractor/index.html +++ b/protractor/index.html @@ -40,7 +40,7 @@ - +