New plugin system

stable
Juanfran 2015-11-27 14:50:36 +01:00 committed by David Barragán Merino
parent 519197c037
commit d2d429e211
6 changed files with 28 additions and 20 deletions

View File

@ -3,6 +3,7 @@
## 1.9.1 Taiga Tribe (unreleased) ## 1.9.1 Taiga Tribe (unreleased)
- [118n] Now taiga plugins can be translatable. - [118n] Now taiga plugins can be translatable.
- New Taiga plugins system.
### Misc ### Misc
- Statics folder hash to prevent cache problems when a new version is released. - 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. - 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 ### Features
- Ability to create single-line or multi-line custom fields. (thanks to [@artlepool](https://github.com/artlepool)). - Ability to create single-line or multi-line custom fields. (thanks to [@artlepool](https://github.com/artlepool)).

View File

@ -16,14 +16,35 @@ window.taigaConfig = {
"contribPlugins": [] "contribPlugins": []
} }
loadStylesheet = (path) ->
$('head').append('<link rel="stylesheet" href="' + path + '" type="stylesheet" />')
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 = $.getJSON "/conf.json"
promise.done (data) -> promise.done (data) ->
window.taigaConfig = _.extend({}, window.taigaConfig, data) window.taigaConfig = _.extend({}, window.taigaConfig, data)
promise.always -> promise.always ->
if window.taigaConfig.contribPlugins.length > 0 if window.taigaConfig.contribPlugins.length > 0
plugins = _.map(window.taigaConfig.contribPlugins, (plugin) -> "#{plugin}") loadPlugins(window.taigaConfig.contribPlugins).then () ->
ljs.load plugins, ->
ljs.load "/#{window._version}/js/app.js", -> ljs.load "/#{window._version}/js/app.js", ->
angular.bootstrap(document, ['taiga']) angular.bootstrap(document, ['taiga'])
else else

View File

@ -22,7 +22,7 @@ taiga = @.taiga
class ThemeService extends taiga.Service = -> class ThemeService extends taiga.Service = ->
use: (themeName) -> use: (themeName) ->
stylesheetEl = $("link[rel='stylesheet']") stylesheetEl = $("link[rel='stylesheet']:first")
if stylesheetEl.length == 0 if stylesheetEl.length == 0
stylesheetEl = $("<link rel='stylesheet' href='' type='text/css'>") stylesheetEl = $("<link rel='stylesheet' href='' type='text/css'>")

View File

@ -1,3 +0,0 @@
*
!.gitignore
!main.coffee

View File

@ -56,7 +56,6 @@ paths.jade = [
paths.htmlPartials = [ paths.htmlPartials = [
paths.tmp + "partials/**/*.html", paths.tmp + "partials/**/*.html",
paths.tmp + "modules/**/*.html", paths.tmp + "modules/**/*.html",
paths.tmp + "plugins/**/*.html",
"!" + paths.tmp + "partials/includes/**/*.html", "!" + paths.tmp + "partials/includes/**/*.html",
"!" + paths.tmp + "/modules/**/includes/**/*.html" "!" + paths.tmp + "/modules/**/includes/**/*.html"
]; ];
@ -86,8 +85,7 @@ paths.styles_dependencies = [
paths.css = [ paths.css = [
paths.tmp + "styles/**/*.css", paths.tmp + "styles/**/*.css",
paths.tmp + "modules/**/*.css", paths.tmp + "modules/**/*.css"
paths.tmp + "plugins/**/*.css"
]; ];
paths.css_order = [ paths.css_order = [
@ -103,7 +101,6 @@ paths.css_order = [
paths.tmp + "styles/modules/**/*.css", paths.tmp + "styles/modules/**/*.css",
paths.tmp + "modules/**/*.css", paths.tmp + "modules/**/*.css",
paths.tmp + "styles/shame/*.css", paths.tmp + "styles/shame/*.css",
paths.tmp + "plugins/**/*.css",
paths.tmp + "themes/**/*.css" paths.tmp + "themes/**/*.css"
]; ];
@ -135,9 +132,7 @@ paths.coffee_order = [
paths.app + "coffee/modules/user-settings/*.coffee", paths.app + "coffee/modules/user-settings/*.coffee",
paths.app + "coffee/modules/integrations/*.coffee", paths.app + "coffee/modules/integrations/*.coffee",
paths.app + "modules/**/*.module.coffee", paths.app + "modules/**/*.module.coffee",
paths.app + "modules/**/*.coffee", paths.app + "modules/**/*.coffee"
paths.app + "plugins/*.coffee",
paths.app + "plugins/**/*.coffee"
]; ];
paths.libs = [ paths.libs = [
@ -495,11 +490,6 @@ gulp.task("copy-theme-images", function() {
.pipe(gulp.dest(paths.distVersion + "/images/" + themes.current.name)); .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() { gulp.task("copy-extras", function() {
return gulp.src(paths.extras + "/*") return gulp.src(paths.extras + "/*")
.pipe(gulp.dest(paths.dist + "/")); .pipe(gulp.dest(paths.dist + "/"));
@ -510,7 +500,6 @@ gulp.task("copy", [
"copy-theme-fonts", "copy-theme-fonts",
"copy-images", "copy-images",
"copy-theme-images", "copy-theme-images",
"copy-plugins",
"copy-svg", "copy-svg",
"copy-theme-svg", "copy-theme-svg",
"copy-extras" "copy-extras"