From d2d429e211f2bdbba6508dd1c3600ba6e6335e24 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Fri, 27 Nov 2015 14:50:36 +0100 Subject: [PATCH] New plugin system --- CHANGELOG.md | 3 ++- app-loader/app-loader.coffee | 25 +++++++++++++++++-- .../modules/plugins.coffee} | 0 app/modules/services/theme.service.coffee | 2 +- app/plugins/.gitignore | 3 --- gulpfile.js | 15 ++--------- 6 files changed, 28 insertions(+), 20 deletions(-) rename app/{plugins/main.coffee => coffee/modules/plugins.coffee} (100%) delete mode 100644 app/plugins/.gitignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 46fc9699..ba4bc13f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.9.1 Taiga Tribe (unreleased) - [118n] Now taiga plugins can be translatable. +- New Taiga plugins system. ### Misc - Statics folder hash to prevent cache problems when a new version is released. @@ -10,7 +11,7 @@ - Lots of small and not so small bugfixes. -## 1.9.0 Abies Siberica (2015-11-XX) +## 1.9.0 Abies Siberica (2015-11-02) ### Features - Ability to create single-line or multi-line custom fields. (thanks to [@artlepool](https://github.com/artlepool)). diff --git a/app-loader/app-loader.coffee b/app-loader/app-loader.coffee index e8801f63..9ddbf62b 100644 --- a/app-loader/app-loader.coffee +++ b/app-loader/app-loader.coffee @@ -16,14 +16,35 @@ window.taigaConfig = { "contribPlugins": [] } +loadStylesheet = (path) -> + $('head').append('') + +loadPlugin = (pluginPath) -> + return new Promise (resolve, reject) -> + $.getJSON(pluginPath).then (plugin) -> + if plugin.css + loadStylesheet(plugin.css) + + #dont' wait for css + if plugin.js + ljs.load(plugin.js, resolve) + else + resolve() + +loadPlugins = (plugins) -> + promises = [] + _.map plugins, (pluginPath) -> + promises.push(loadPlugin(pluginPath)) + + return Promise.all(promises) + promise = $.getJSON "/conf.json" promise.done (data) -> window.taigaConfig = _.extend({}, window.taigaConfig, data) promise.always -> if window.taigaConfig.contribPlugins.length > 0 - plugins = _.map(window.taigaConfig.contribPlugins, (plugin) -> "#{plugin}") - ljs.load plugins, -> + loadPlugins(window.taigaConfig.contribPlugins).then () -> ljs.load "/#{window._version}/js/app.js", -> angular.bootstrap(document, ['taiga']) else diff --git a/app/plugins/main.coffee b/app/coffee/modules/plugins.coffee similarity index 100% rename from app/plugins/main.coffee rename to app/coffee/modules/plugins.coffee diff --git a/app/modules/services/theme.service.coffee b/app/modules/services/theme.service.coffee index ae4c7b17..6a15a58f 100644 --- a/app/modules/services/theme.service.coffee +++ b/app/modules/services/theme.service.coffee @@ -22,7 +22,7 @@ taiga = @.taiga class ThemeService extends taiga.Service = -> use: (themeName) -> - stylesheetEl = $("link[rel='stylesheet']") + stylesheetEl = $("link[rel='stylesheet']:first") if stylesheetEl.length == 0 stylesheetEl = $("") diff --git a/app/plugins/.gitignore b/app/plugins/.gitignore deleted file mode 100644 index 61d16771..00000000 --- a/app/plugins/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore -!main.coffee diff --git a/gulpfile.js b/gulpfile.js index e61692dc..bb1848e8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -56,7 +56,6 @@ paths.jade = [ paths.htmlPartials = [ paths.tmp + "partials/**/*.html", paths.tmp + "modules/**/*.html", - paths.tmp + "plugins/**/*.html", "!" + paths.tmp + "partials/includes/**/*.html", "!" + paths.tmp + "/modules/**/includes/**/*.html" ]; @@ -86,8 +85,7 @@ paths.styles_dependencies = [ paths.css = [ paths.tmp + "styles/**/*.css", - paths.tmp + "modules/**/*.css", - paths.tmp + "plugins/**/*.css" + paths.tmp + "modules/**/*.css" ]; paths.css_order = [ @@ -103,7 +101,6 @@ paths.css_order = [ paths.tmp + "styles/modules/**/*.css", paths.tmp + "modules/**/*.css", paths.tmp + "styles/shame/*.css", - paths.tmp + "plugins/**/*.css", paths.tmp + "themes/**/*.css" ]; @@ -135,9 +132,7 @@ paths.coffee_order = [ paths.app + "coffee/modules/user-settings/*.coffee", paths.app + "coffee/modules/integrations/*.coffee", paths.app + "modules/**/*.module.coffee", - paths.app + "modules/**/*.coffee", - paths.app + "plugins/*.coffee", - paths.app + "plugins/**/*.coffee" + paths.app + "modules/**/*.coffee" ]; paths.libs = [ @@ -495,11 +490,6 @@ gulp.task("copy-theme-images", function() { .pipe(gulp.dest(paths.distVersion + "/images/" + themes.current.name)); }); -gulp.task("copy-plugins", function() { - return gulp.src(paths.app + "/plugins/**") - .pipe(gulp.dest(paths.dist + "/plugins/")); -}); - gulp.task("copy-extras", function() { return gulp.src(paths.extras + "/*") .pipe(gulp.dest(paths.dist + "/")); @@ -510,7 +500,6 @@ gulp.task("copy", [ "copy-theme-fonts", "copy-images", "copy-theme-images", - "copy-plugins", "copy-svg", "copy-theme-svg", "copy-extras"