Improve plugin and config loading

stable
Jesús Espino 2015-01-21 16:53:25 +01:00
parent c1fb4f6d9e
commit 00c9fdd362
7 changed files with 50 additions and 23 deletions

View File

@ -0,0 +1,27 @@
version = ___VERSION___
window.taigaConfig = {
"api": "http://localhost:8000/api/v1/",
"eventsUrl": null,
"debug": true,
"publicRegisterEnabled": true,
"feedbackEnabled": true,
"privacyPolicyUrl": null,
"termsOfServiceUrl": null,
"maxUploadFileSize": null,
"gitHubClientId": null,
"contribPlugins": []
}
promise = $.getJSON "/js/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}?v=#{version}")
ljs.load plugins, ->
ljs.load "/js/app.js?v=#{version}", ->
angular.bootstrap(document, ['taiga'])
else
ljs.load "/js/app.js?v=#{version}", ->
angular.bootstrap(document, ['taiga'])

View File

@ -19,17 +19,9 @@
# File: modules/base/conf.coffee # File: modules/base/conf.coffee
### ###
defaults = {
api: "http://localhost:8000/api/v1/"
debug: true
lang: "en"
}
class ConfigurationService class ConfigurationService
@.$inject = ["localconf"] constructor: () ->
@.config = window.taigaConfig
constructor: (localconf) ->
@.config = _.merge(_.clone(defaults, true), localconf)
get: (key, defaultValue=null) -> get: (key, defaultValue=null) ->
if _.has(@.config, key) if _.has(@.config, key)
@ -39,4 +31,3 @@ class ConfigurationService
module = angular.module("taigaBase") module = angular.module("taigaBase")
module.service("$tgConfig", ConfigurationService) module.service("$tgConfig", ConfigurationService)
module.value("localconf", null)

View File

@ -1,5 +1,5 @@
doctype html doctype html
html(lang="en", ng-app="taiga") html(lang="en")
head head
meta(charset="utf-8") meta(charset="utf-8")
title Taiga title Taiga
@ -37,5 +37,4 @@ html(lang="en", ng-app="taiga")
include partials/views/modules/loader include partials/views/modules/loader
script(src="/js/libs.js?v=#{v}") script(src="/js/libs.js?v=#{v}")
script(src="/js/app.js?v=#{v}") script(src="/js/app-loader.js?v=#{v}")
script(src="/js/conf.js?v=#{v}")

View File

@ -73,7 +73,8 @@
"Sortable": "~0.1.8", "Sortable": "~0.1.8",
"pikaday": "~1.2.0", "pikaday": "~1.2.0",
"malihu-custom-scrollbar-plugin": "~3.0.4", "malihu-custom-scrollbar-plugin": "~3.0.4",
"raven-js": "~1.1.16" "raven-js": "~1.1.16",
"l.js": "~0.1.0"
}, },
"resolutions": { "resolutions": {
"lodash": "~2.4.1", "lodash": "~2.4.1",

View File

@ -1,4 +1,4 @@
angular.module('taigaBase').value('localconf', { {
"api": "http://localhost:8000/api/v1/", "api": "http://localhost:8000/api/v1/",
"eventsUrl": null, "eventsUrl": null,
"debug": true, "debug": true,
@ -7,5 +7,6 @@ angular.module('taigaBase').value('localconf', {
"privacyPolicyUrl": null, "privacyPolicyUrl": null,
"termsOfServiceUrl": null, "termsOfServiceUrl": null,
"maxUploadFileSize": null, "maxUploadFileSize": null,
"gitHubClientId": null "gitHubClientId": null,
}); "contribPlugins": []
}

View File

@ -9,6 +9,7 @@ wrap = require("gulp-wrap")
rename = require("gulp-rename") rename = require("gulp-rename")
flatten = require('gulp-flatten') flatten = require('gulp-flatten')
gulpif = require('gulp-if') gulpif = require('gulp-if')
replace = require("gulp-replace")
minifyHTML = require("gulp-minify-html") minifyHTML = require("gulp-minify-html")
sass = require("gulp-ruby-sass") sass = require("gulp-ruby-sass")
@ -102,6 +103,7 @@ paths.js = [
paths.app + "vendor/markitup-1x/markitup/jquery.markitup.js", paths.app + "vendor/markitup-1x/markitup/jquery.markitup.js",
paths.app + "vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js", paths.app + "vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js",
paths.app + "vendor/raven-js/dist/raven.js", paths.app + "vendor/raven-js/dist/raven.js",
paths.app + "vendor/l.js/l.js",
paths.app + "js/jquery.ui.git-custom.js", paths.app + "js/jquery.ui.git-custom.js",
paths.app + "js/jquery-ui.drag-multiple-custom.js", paths.app + "js/jquery-ui.drag-multiple-custom.js",
paths.app + "js/sha1-custom.js", paths.app + "js/sha1-custom.js",
@ -204,8 +206,13 @@ gulp.task "styles", ["delete-tmp-styles"], ->
############################################################################## ##############################################################################
gulp.task "conf", -> gulp.task "conf", ->
gulp.src("conf/conf.example.js") gulp.src(["conf/conf.example.json"])
.pipe(rename("conf.js")) .pipe(gulp.dest(paths.dist + "js/"))
gulp.task "app-loader", ->
gulp.src("app-loader/app-loader.coffee")
.pipe(replace("___VERSION___", (new Date()).getTime()))
.pipe(coffee())
.pipe(gulp.dest(paths.dist + "js/")) .pipe(gulp.dest(paths.dist + "js/"))
gulp.task "locales", -> gulp.task "locales", ->
@ -236,7 +243,7 @@ gulp.task "jslibs-deploy", ->
.pipe(sourcemaps.write('./')) .pipe(sourcemaps.write('./'))
.pipe(gulp.dest(paths.dist + "js/")) .pipe(gulp.dest(paths.dist + "js/"))
gulp.task "app-watch", ["coffee", "conf", "locales"], -> gulp.task "app-watch", ["coffee", "conf", "locales", "app-loader"], ->
_paths = [ _paths = [
paths.tmp + "app.js", paths.tmp + "app.js",
paths.tmp + "locales.en.js" paths.tmp + "locales.en.js"
@ -246,7 +253,7 @@ gulp.task "app-watch", ["coffee", "conf", "locales"], ->
.pipe(concat("app.js")) .pipe(concat("app.js"))
.pipe(gulp.dest(paths.dist + "js/")) .pipe(gulp.dest(paths.dist + "js/"))
gulp.task "app-deploy", ["coffee", "conf", "locales"], -> gulp.task "app-deploy", ["coffee", "conf", "locales", "app-loader"], ->
_paths = [ _paths = [
paths.tmp + "app.js", paths.tmp + "app.js",
paths.tmp + "locales.en.js" paths.tmp + "locales.en.js"

View File

@ -54,6 +54,7 @@
"readable-stream": "~1.0.31", "readable-stream": "~1.0.31",
"rimraf": "^2.2.8", "rimraf": "^2.2.8",
"run-sequence": "^1.0.1", "run-sequence": "^1.0.1",
"through2": "~0.6.1" "through2": "~0.6.1",
"gulp-replace": "^0.5.2"
} }
} }