Add configuration module and adapt layout for it.

stable
Andrey Antukh 2014-06-11 12:59:30 +02:00
parent 05f293e7ca
commit 86ed95ac49
5 changed files with 59 additions and 5 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
dist/ dist/
node_modules/ node_modules/
app/vendor app/vendor
config/main.coffee

44
app/coffee/config.coffee Normal file
View File

@ -0,0 +1,44 @@
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
#
# 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 <http://www.gnu.org/licenses/>.
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])

View File

@ -43,17 +43,17 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $compil
# $httpProvider.responseInterceptors.push('authHttpIntercept') # $httpProvider.responseInterceptors.push('authHttpIntercept')
init = ($rootScope) -> init = ($log, $rootScope) ->
console.log "INIT" $log.debug("Initialize application")
configure.$inject = ["$routeProvider", "$locationProvider","$httpProvider"] configure.$inject = ["$routeProvider", "$locationProvider","$httpProvider"]
init.$inject = ["$rootScope"] init.$inject = ["$log", "$rootScope"]
modules = [ modules = [
"ngRoute", "ngRoute",
"ngAnimate", "ngAnimate",
"taigaConfig"
# Taiga specific modules # Taiga specific modules
# "taigaCommon" # "taigaCommon"
] ]

View File

@ -0,0 +1,7 @@
config = {
host: "localhost:8000"
scheme: "http"
debug: true
}
angular.module("taigaLocalConfig", []).value("localconfig", config)

View File

@ -32,7 +32,9 @@ var paths = {
sassMain: "app/styles/main.scss", sassMain: "app/styles/main.scss",
css: "dist/styles/**/*.css", css: "dist/styles/**/*.css",
images: "app/images/**/*", 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. // Ordered list of vendor/external libraries.