diff --git a/.gitignore b/.gitignore index a62e5faa..11136d4c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist/ node_modules/ app/vendor +config/main.coffee \ No newline at end of file diff --git a/app/coffee/config.coffee b/app/coffee/config.coffee new file mode 100644 index 00000000..5e569821 --- /dev/null +++ b/app/coffee/config.coffee @@ -0,0 +1,44 @@ +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino Garcia +# Copyright (C) 2014 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +class ConfigService + defaults: { + host: "localhost:8000" + scheme: "http" + defaultLanguage: "en" + debug: false + languageOptions: { + "es": "Spanish" + "en": "English" + } + } + + initialize: (localconfig) -> + defaults = _.clone(@.defaults, true) + @.config = _.merge(defaults, localconfig) + + get: (key, defaultValue=null) -> + return @.config[key] || defaultValue + + +init = ($log, localconfig, config) -> + $log.debug("Initializing configuration") + config.initialize(localconfig) + +module = angular.module("taigaConfig", ["taigaLocalConfig"]) +module.service("$tgConfig", ConfigService) +module.run(["$log", "localconfig", "$tgConfig", init]) diff --git a/app/coffee/app.coffee b/app/coffee/taiga.coffee similarity index 94% rename from app/coffee/app.coffee rename to app/coffee/taiga.coffee index d007f18c..39997898 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/taiga.coffee @@ -43,17 +43,17 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $compil # $httpProvider.responseInterceptors.push('authHttpIntercept') -init = ($rootScope) -> - console.log "INIT" - +init = ($log, $rootScope) -> + $log.debug("Initialize application") configure.$inject = ["$routeProvider", "$locationProvider","$httpProvider"] -init.$inject = ["$rootScope"] +init.$inject = ["$log", "$rootScope"] modules = [ "ngRoute", "ngAnimate", + "taigaConfig" # Taiga specific modules # "taigaCommon" ] diff --git a/config/main.coffee.example b/config/main.coffee.example new file mode 100644 index 00000000..4b23249e --- /dev/null +++ b/config/main.coffee.example @@ -0,0 +1,7 @@ +config = { + host: "localhost:8000" + scheme: "http" + debug: true +} + +angular.module("taigaLocalConfig", []).value("localconfig", config) diff --git a/gulpfile.js b/gulpfile.js index bc453b2c..b8d783f7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,7 +32,9 @@ var paths = { sassMain: "app/styles/main.scss", css: "dist/styles/**/*.css", images: "app/images/**/*", - coffee: ["app/coffee/*.coffee", "app/coffee/**/*.coffee"] + coffee: ["app/coffee/*.coffee", + "config/main.coffee", + "app/coffee/**/*.coffee"] }; // Ordered list of vendor/external libraries.