Merge pull request #83 from taigaio/config-gulp-i18n-refactor

New config and i18n modules.
stable
Jesús Espino 2014-10-08 12:59:56 +02:00
commit 9e698e40c5
14 changed files with 286 additions and 282 deletions

2
.gitignore vendored
View File

@ -8,4 +8,6 @@ app/coffee/modules/locales/locale*.coffee
*.swp *.swp
*.swo *.swo
tags tags
tmp/
conf/
app/config/main.coffee app/config/main.coffee

View File

@ -193,14 +193,10 @@ init = ($log, $i18n, $config, $rootscope, $auth, $events) ->
if $auth.isAuthenticated() if $auth.isAuthenticated()
$events.setupConnection() $events.setupConnection()
# Default Value for taiga local config module.
angular.module("taigaLocalConfig", []).value("localconfig", {})
modules = [ modules = [
# Main Global Modules # Main Global Modules
"taigaBase", "taigaBase",
"taigaCommon", "taigaCommon",
"taigaConfig",
"taigaResources", "taigaResources",
"taigaLocales", "taigaLocales",
"taigaAuth", "taigaAuth",

View File

@ -16,35 +16,20 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# File: config.coffee # File: modules/base/conf.coffee
### ###
taiga = @.taiga defaults = {
api: "http://localhost:8000/api/v1/"
debug: true
lang: "en"
}
class ConfigService extends taiga.Service class ConfigurationService
defaults: { @.$inject = ["localconf"]
host: "localhost:8000"
scheme: "http"
debug: false constructor: (localconf) ->
@.config = _.merge(_.clone(defaults, true), localconf)
defaultLanguage: "en"
languageOptions: {
"es": "Spanish"
"en": "English"
}
publicRegisterEnabled: false
termsOfServiceUrl: null
privacyPolicyUrl: null
feedbackEnabled: true
}
initialize: (localconfig) ->
defaults = _.clone(@.defaults, true)
@.config = _.merge(defaults, localconfig)
get: (key, defaultValue=null) -> get: (key, defaultValue=null) ->
if _.has(@.config, key) if _.has(@.config, key)
@ -52,12 +37,7 @@ class ConfigService extends taiga.Service
return defaultValue return defaultValue
# Initialize config loading local configuration. module = angular.module("taigaBase")
init = ($log, localconfig, config) -> module.service("$tgConfig", ConfigurationService)
$log.debug("Initializing configuration", localconfig) module.value("localconf", null)
config.initialize(localconfig)
module = angular.module("taigaConfig", ["taigaLocalConfig"])
module.service("$tgConfig", ConfigService)
module.run(["$log", "localconfig", "$tgConfig", init])

View File

@ -26,51 +26,50 @@ defaults = {
ns: "app" ns: "app"
fallbackLng: "en" fallbackLng: "en"
async: false async: false
lng: "en"
} }
class I18nService extends taiga.Service class I18nService extends taiga.Service
constructor: (@rootscope, @localeEn) -> constructor: (@rootscope, localesEn) ->
@.options = _.clone(defaults, true)
@.options.resStore = {
en: { app: localesEn }
}
setLanguage: (language) -> setLanguage: (language) ->
options = _.clone(defaults, true) i18n.setLng(language)
i18n.setLng(language, options)
@rootscope.currentLang = language @rootscope.currentLang = language
@rootscope.$broadcast("i18n:changeLang", language) @rootscope.$broadcast("i18n:changeLang", language)
initialize: (defaultLang="en") -> initialize: ->
options = _.clone(defaults, true) i18n.init(@.options)
options.lng = defaultLang
options.resStore = {
en: { app: @localeEn }
}
i18n.init(options)
@rootscope.t = i18n.t @rootscope.t = i18n.t
I18nDirective = ($rootscope, $i18n) -> I18nDirective = ($rootscope, $i18n) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
values = $attrs.tgI18n.split(",") values = $attrs.tr.split(",")
options = $attrs.tgI18nOptions or '{}' options = $attrs.trOpts or '{}'
applyTranslation = -> applyTranslation = ->
opts = $scope.$eval(options) opts = $scope.$eval(options)
for v in values for v in values
if v.indexOf(":") == -1 if v.indexOf(":") == -1
$el.html($scope.t(v, opts)) $el.html(_.escape($scope.t(v, opts)))
else else
[ns, v] = v.split(":") [ns, v] = v.split(":")
$el.attr(ns, $scope.t(v, opts)) $el.attr(ns, _.escape($scope.t(v, opts)))
bindOnce($scope, "t", applyTranslation) bindOnce($scope, "t", applyTranslation)
$scope.$on("i18n:changeLang", applyTranslation) $scope.$on("i18n:changeLang", applyTranslation)
return {link: link} return {
link: link
restrict: "A"
scope: false
}
module = angular.module("taigaBase") module = angular.module("taigaBase")
module.service("$tgI18n", ["$rootScope", "localesEnglish", I18nService]) module.service("$tgI18n", ["$rootScope", "localesEn", I18nService])
module.directive("tgI18n", ["$rootScope", "$tgI18n", I18nDirective]) module.directive("tr", ["$rootScope", "$tgI18n", I18nDirective])

View File

@ -30,8 +30,7 @@ class UrlsService extends taiga.Service
constructor: (@config) -> constructor: (@config) ->
@.urls = {} @.urls = {}
@.host = config.get("host") @.mainUrl = config.get("api")
@.scheme = config.get("scheme")
update: (urls) -> update: (urls) ->
@.urls = _.merge(@.urls, urls) @.urls = _.merge(@.urls, urls)
@ -44,7 +43,11 @@ class UrlsService extends taiga.Service
name = args.slice(0, 1)[0] name = args.slice(0, 1)[0]
url = format(@.urls[name], args.slice(1)) url = format(@.urls[name], args.slice(1))
return format("%s://%s%s", [@.scheme, @.host, url])
return format("%s/%s", [
_.str.rtrim(@.mainUrl, "/"),
_.str.ltrim(url, "/")
])
module = angular.module("taigaBase") module = angular.module("taigaBase")

View File

@ -24,79 +24,79 @@ taiga = @.taiga
class ResourcesService extends taiga.Service class ResourcesService extends taiga.Service
urls = { urls = {
"auth": "/api/v1/auth" "auth": "/auth"
"auth-register": "/api/v1/auth/register" "auth-register": "/auth/register"
"invitations": "/api/v1/invitations" "invitations": "/invitations"
"permissions": "/api/v1/permissions" "permissions": "/permissions"
"roles": "/api/v1/roles" "roles": "/roles"
"projects": "/api/v1/projects" "projects": "/projects"
"memberships": "/api/v1/memberships" "memberships": "/memberships"
"notify-policies": "/api/v1/notify-policies" "notify-policies": "/notify-policies"
"bulk-create-memberships": "/api/v1/memberships/bulk_create" "bulk-create-memberships": "/memberships/bulk_create"
"milestones": "/api/v1/milestones" "milestones": "/milestones"
"userstories": "/api/v1/userstories" "userstories": "/userstories"
"bulk-create-us": "/api/v1/userstories/bulk_create" "bulk-create-us": "/userstories/bulk_create"
"bulk-update-us-backlog-order": "/api/v1/userstories/bulk_update_backlog_order" "bulk-update-us-backlog-order": "/userstories/bulk_update_backlog_order"
"bulk-update-us-sprint-order": "/api/v1/userstories/bulk_update_sprint_order" "bulk-update-us-sprint-order": "/userstories/bulk_update_sprint_order"
"bulk-update-us-kanban-order": "/api/v1/userstories/bulk_update_kanban_order" "bulk-update-us-kanban-order": "/userstories/bulk_update_kanban_order"
"userstories-restore": "/api/v1/userstories/%s/restore" "userstories-restore": "/userstories/%s/restore"
"tasks": "/api/v1/tasks" "tasks": "/tasks"
"bulk-create-tasks": "/api/v1/tasks/bulk_create" "bulk-create-tasks": "/tasks/bulk_create"
"tasks-restore": "/api/v1/tasks/%s/restore" "tasks-restore": "/tasks/%s/restore"
"issues": "/api/v1/issues" "issues": "/issues"
"bulk-create-issues": "/api/v1/issues/bulk_create" "bulk-create-issues": "/issues/bulk_create"
"issues-restore": "/api/v1/issues/%s/restore" "issues-restore": "/issues/%s/restore"
"wiki": "/api/v1/wiki" "wiki": "/wiki"
"wiki-restore": "/api/v1/wiki/%s/restore" "wiki-restore": "/wiki/%s/restore"
"wiki-links": "/api/v1/wiki-links" "wiki-links": "/wiki-links"
"choices/userstory-statuses": "/api/v1/userstory-statuses" "choices/userstory-statuses": "/userstory-statuses"
"choices/userstory-statuses/bulk-update-order": "/api/v1/userstory-statuses/bulk_update_order" "choices/userstory-statuses/bulk-update-order": "/userstory-statuses/bulk_update_order"
"choices/points": "/api/v1/points" "choices/points": "/points"
"choices/points/bulk-update-order": "/api/v1/points/bulk_update_order" "choices/points/bulk-update-order": "/points/bulk_update_order"
"choices/task-statuses": "/api/v1/task-statuses" "choices/task-statuses": "/task-statuses"
"choices/task-statuses/bulk-update-order": "/api/v1/task-statuses/bulk_update_order" "choices/task-statuses/bulk-update-order": "/task-statuses/bulk_update_order"
"choices/issue-statuses": "/api/v1/issue-statuses" "choices/issue-statuses": "/issue-statuses"
"choices/issue-statuses/bulk-update-order": "/api/v1/issue-statuses/bulk_update_order" "choices/issue-statuses/bulk-update-order": "/issue-statuses/bulk_update_order"
"choices/issue-types": "/api/v1/issue-types" "choices/issue-types": "/issue-types"
"choices/issue-types/bulk-update-order": "/api/v1/issue-types/bulk_update_order" "choices/issue-types/bulk-update-order": "/issue-types/bulk_update_order"
"choices/priorities": "/api/v1/priorities" "choices/priorities": "/priorities"
"choices/priorities/bulk-update-order": "/api/v1/priorities/bulk_update_order" "choices/priorities/bulk-update-order": "/priorities/bulk_update_order"
"choices/severities": "/api/v1/severities" "choices/severities": "/severities"
"choices/severities/bulk-update-order": "/api/v1/severities/bulk_update_order" "choices/severities/bulk-update-order": "/severities/bulk_update_order"
"search": "/api/v1/search" "search": "/search"
"sites": "/api/v1/sites" "sites": "/sites"
"project-templates": "/api/v1/project-templates" "project-templates": "/project-templates"
"site-members": "/api/v1/site-members" "site-members": "/site-members"
"site-projects": "/api/v1/site-projects" "site-projects": "/site-projects"
"users": "/api/v1/users" "users": "/users"
"users-password-recovery": "/api/v1/users/password_recovery" "users-password-recovery": "/users/password_recovery"
"users-change-password-from-recovery": "/api/v1/users/change_password_from_recovery" "users-change-password-from-recovery": "/users/change_password_from_recovery"
"users-change-password": "/api/v1/users/change_password" "users-change-password": "/users/change_password"
"users-change-email": "/api/v1/users/change_email" "users-change-email": "/users/change_email"
"user-storage": "/api/v1/user-storage" "user-storage": "/user-storage"
"resolver": "/api/v1/resolver" "resolver": "/resolver"
"userstory-statuses": "/api/v1/userstory-statuses" "userstory-statuses": "/userstory-statuses"
"points": "/api/v1/points" "points": "/points"
"task-statuses": "/api/v1/task-statuses" "task-statuses": "/task-statuses"
"issue-statuses": "/api/v1/issue-statuses" "issue-statuses": "/issue-statuses"
"issue-types": "/api/v1/issue-types" "issue-types": "/issue-types"
"priorities": "/api/v1/priorities" "priorities": "/priorities"
"severities": "/api/v1/severities" "severities": "/severities"
# History # History
"history/us": "/api/v1/history/userstory" "history/us": "/history/userstory"
"history/issue": "/api/v1/history/issue" "history/issue": "/history/issue"
"history/task": "/api/v1/history/task" "history/task": "/history/task"
"history/wiki": "/api/v1/history/wiki" "history/wiki": "/history/wiki"
# Attachments # Attachments
"attachments/us": "/api/v1/userstories/attachments" "attachments/us": "/userstories/attachments"
"attachments/issue": "/api/v1/issues/attachments" "attachments/issue": "/issues/attachments"
"attachments/task": "/api/v1/tasks/attachments" "attachments/task": "/tasks/attachments"
"attachments/wiki_page": "/api/v1/wiki/attachments" "attachments/wiki_page": "/wiki/attachments"
# Feedback # Feedback
"feedback": "/api/v1/feedback" "feedback": "/feedback"
} }
# Initialize api urls service # Initialize api urls service

View File

@ -1,19 +0,0 @@
config = {
host: "localhost:8000"
scheme: "http"
debug: true
defaultLanguage: "en"
languageOptions: {
"en": "English"
}
publicRegisterEnabled: true
privacyPolicyUrl: null
termsOfServiceUrl: null
feedbackEnabled: true
}
angular.module("taigaLocalConfig", []).value("localconfig", config)

View File

@ -1,8 +1,8 @@
a.close(href="", title="close") a.close(href="", title="close")
span.icon.icon-delete span.icon.icon-delete
form form
h2.title(tg-i18n="common.new-bulk") h2.title(tr="common.new-bulk")
fieldset fieldset
textarea(cols="200", wrap="off", tg-limit-line-length, tg-i18n="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200") textarea(cols="200", wrap="off", tg-limit-line-length, tr="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200")
a.button.button-green(href="", tg-i18n="title:common.save") a.button.button-green(href="", tr="title:common.save")
span(tg-i18n="common.save") span(tr="common.save")

View File

@ -1,8 +1,8 @@
a.close(href="", title="close") a.close(href="", title="close")
span.icon.icon-delete span.icon.icon-delete
form form
h2.title(tg-i18n="common.new-bulk") h2.title(tr="common.new-bulk")
fieldset fieldset
textarea(cols="200", wrap="off", tg-limit-line-length, tg-i18n="placeholder:common.one-item-line", ng-model="form.data", data-required="true") textarea(cols="200", wrap="off", tg-limit-line-length, tr="placeholder:common.one-item-line", ng-model="form.data", data-required="true")
a.button.button-green(href="", tg-i18n="title:common.save") a.button.button-green(href="", tr="title:common.save")
span(tg-i18n="common.save") span(tr="common.save")

View File

@ -1,7 +1,7 @@
a.close(href="", title="close") a.close(href="", title="close")
span.icon.icon-delete span.icon.icon-delete
form form
h2.title(tg-i18n="task.title-new") h2.title(tr="task.title-new")
fieldset fieldset
input(type="text", ng-model="task.subject", placeholder="A task subject", input(type="text", ng-model="task.subject", placeholder="A task subject",
data-required="true", data-maxlength="500") data-required="true", data-maxlength="500")
@ -30,7 +30,7 @@ form
fieldset.blocking-flag fieldset.blocking-flag
input(type="checkbox", ng-model="task.is_blocked", name="blocked-task", id="blocked-task", ng-value="true") input(type="checkbox", ng-model="task.is_blocked", name="blocked-task", id="blocked-task", ng-value="true")
label.blocked(for="blocked-task", tg-i18n="common.blocked") label.blocked(for="blocked-task", tr="common.blocked")
tg-blocking-message-input(watch="task.is_blocked", ng-model="task.blocked_note") tg-blocking-message-input(watch="task.is_blocked", ng-model="task.blocked_note")

View File

@ -1,8 +1,8 @@
a.close(href="", title="close") a.close(href="", title="close")
span.icon.icon-delete span.icon.icon-delete
form form
h2.title(tg-i18n="common.new-bulk") h2.title(tr="common.new-bulk")
fieldset fieldset
textarea(cols="200", wrap="off", tg-limit-line-length, tg-i18n="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200") textarea(cols="200", wrap="off", tg-limit-line-length, tr="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200")
a.button.button-green(href="", tg-i18n="title:common.save") a.button.button-green(href="", tr="title:common.save")
span(tg-i18n="common.save") span(tr="common.save")

View File

@ -1,9 +1,9 @@
a.close(href="", title="close") a.close(href="", title="close")
span.icon.icon-delete span.icon.icon-delete
form form
h2.title(tg-i18n="us.title-new") h2.title(tr="us.title-new")
fieldset fieldset
input(type="text", name="subject", ng-model="us.subject", tg-i18n="placeholder:common.subject", input(type="text", name="subject", ng-model="us.subject", tr="placeholder:common.subject",
data-required="true", data-maxlength="500") data-required="true", data-maxlength="500")
fieldset.estimation fieldset.estimation
@ -12,7 +12,7 @@ form
fieldset fieldset
select(name="status", ng-model="us.status", ng-options="s.id as s.name for s in usStatusList", select(name="status", ng-model="us.status", ng-options="s.id as s.name for s in usStatusList",
tg-i18n="placeholder:common.status") tr="placeholder:common.status")
fieldset fieldset
div(tg-tag-line, editable="true", ng-model="us.tags") div(tg-tag-line, editable="true", ng-model="us.tags")
@ -24,16 +24,16 @@ form
fieldset.team-requirement fieldset.team-requirement
input(type="checkbox", name="team_requirement", ng-model="us.team_requirement", input(type="checkbox", name="team_requirement", ng-model="us.team_requirement",
id="team-requirement", ng-value="true") id="team-requirement", ng-value="true")
label.requirement(for="team-requirement", tg-i18n="us.team-requirement") label.requirement(for="team-requirement", tr="us.team-requirement")
fieldset.client-requirement fieldset.client-requirement
input(type="checkbox", name="client_requirement", ng-model="us.client_requirement", input(type="checkbox", name="client_requirement", ng-model="us.client_requirement",
id="client-requirement", ng-value="true") id="client-requirement", ng-value="true")
label.requirement(for="client-requirement", tg-i18n="us.client-requirement") label.requirement(for="client-requirement", tr="us.client-requirement")
fieldset.blocking-flag fieldset.blocking-flag
input(type="checkbox", name="is_blocked", ng-model="us.is_blocked", id="blocked-us" ng-value="true") input(type="checkbox", name="is_blocked", ng-model="us.is_blocked", id="blocked-us" ng-value="true")
label.blocked(for="blocked-us", tg-i18n="common.blocked") label.blocked(for="blocked-us", tr="common.blocked")
tg-blocking-message-input(watch="us.is_blocked", ng-model="us.blocked_note") tg-blocking-message-input(watch="us.is_blocked", ng-model="us.blocked_note")

8
conf/main.example.json Normal file
View File

@ -0,0 +1,8 @@
{
"api": "http://localhost:8000/api/v1/",
"eventsUrl": "ws://localhost:8888/events",
"debug": "true",
"publicRegisterEnabled": true,
"privacyPolicyUrl": null,
"termsOfServiceUrl": null
}

View File

@ -19,66 +19,72 @@ newer = require("gulp-newer")
cache = require("gulp-cached") cache = require("gulp-cached")
jadeInheritance = require('gulp-jade-inheritance') jadeInheritance = require('gulp-jade-inheritance')
paths = { paths = {}
app: "app" paths.app = "app/"
dist: "dist" paths.dist = "dist/"
html: "app/*.html" paths.tmp = "tmp/"
jade: ["app/index.jade", "app/partials/**/*.jade"]
scssStyles: "app/styles/**/*.scss" paths.jade = [
distStylesPath: "dist/styles" paths.app + "index.jade",
distStyles: ["dist/styles/vendor.css", paths.app + "partials/**/*.jade"
"dist/styles/app.css"] ]
sassStylesMain: "app/styles/main.scss"
css: "app/styles/vendor/*.css" paths.images = paths.app + "images/**/*"
images: "app/images/**/*" paths.svg = paths.app + "svg/**/*"
svg: "app/svg/**/*" paths.css = paths.app + "app/styles/vendor/*.css"
locales: "app/locales/**/*.json" paths.locales = paths.app + "locales/**/*.json"
coffee: ["app/coffee/app.coffee", paths.sass = [
"app/config/*.coffee", paths.app + "styles/**/*.scss"
"app/coffee/*.coffee", "!#{paths.app}/styles/bourbon/**/*.scss"
"app/coffee/modules/controllerMixins.coffee", ]
"app/coffee/modules/*.coffee",
"app/coffee/modules/common/*.coffee", paths.coffee = [
"app/coffee/modules/backlog/*.coffee", paths.app + "coffee/app.coffee",
"app/coffee/modules/taskboard/*.coffee", paths.app + "coffee/*.coffee",
"app/coffee/modules/kanban/*.coffee", paths.app + "coffee/modules/controllerMixins.coffee",
"app/coffee/modules/issues/*.coffee", paths.app + "coffee/modules/*.coffee",
"app/coffee/modules/userstories/*.coffee", paths.app + "coffee/modules/common/*.coffee",
"app/coffee/modules/tasks/*.coffee", paths.app + "coffee/modules/backlog/*.coffee",
"app/coffee/modules/wiki/*.coffee", paths.app + "coffee/modules/taskboard/*.coffee",
"app/coffee/modules/admin/*.coffee", paths.app + "coffee/modules/kanban/*.coffee",
"app/coffee/modules/projects/*.coffee", paths.app + "coffee/modules/issues/*.coffee",
"app/coffee/modules/locales/*.coffee", paths.app + "coffee/modules/userstories/*.coffee",
"app/coffee/modules/base/*.coffee", paths.app + "coffee/modules/tasks/*.coffee",
"app/coffee/modules/resources/*.coffee", paths.app + "coffee/modules/wiki/*.coffee",
"app/coffee/modules/user-settings/*.coffee" paths.app + "coffee/modules/admin/*.coffee",
"app/plugins/**/*.coffee"] paths.app + "coffee/modules/projects/*.coffee",
vendorJsLibs: [ paths.app + "coffee/modules/locales/*.coffee",
"app/vendor/jquery/dist/jquery.js", paths.app + "coffee/modules/base/*.coffee",
"app/vendor/lodash/dist/lodash.js", paths.app + "coffee/modules/resources/*.coffee",
"app/vendor/emoticons/lib/emoticons.js", paths.app + "coffee/modules/user-settings/*.coffee"
"app/vendor/underscore.string/lib/underscore.string.js", paths.app + "plugins/**/*.coffee"
"app/vendor/angular/angular.js", ]
"app/vendor/angular-route/angular-route.js",
"app/vendor/angular-sanitize/angular-sanitize.js", paths.js = [
"app/vendor/angular-animate/angular-animate.js", paths.app + "vendor/jquery/dist/jquery.js",
"app/vendor/i18next/i18next.js", paths.app + "vendor/lodash/dist/lodash.js",
"app/vendor/moment/min/moment-with-langs.js", paths.app + "vendor/emoticons/lib/emoticons.js",
"app/vendor/checksley/checksley.js", paths.app + "vendor/underscore.string/lib/underscore.string.js",
"app/vendor/pikaday/pikaday.js", paths.app + "vendor/angular/angular.js",
"app/vendor/jquery-flot/jquery.flot.js", paths.app + "vendor/angular-route/angular-route.js",
"app/vendor/jquery-flot/jquery.flot.pie.js", paths.app + "vendor/angular-sanitize/angular-sanitize.js",
"app/vendor/jquery-flot/jquery.flot.time.js", paths.app + "vendor/angular-animate/angular-animate.js",
"app/vendor/jquery-flot/jquery.flot.time.js", paths.app + "vendor/i18next/i18next.js",
"app/vendor/flot-axislabels/jquery.flot.axislabels.js", paths.app + "vendor/moment/min/moment-with-langs.js",
"app/vendor/jquery-textcomplete/jquery.textcomplete.js", paths.app + "vendor/checksley/checksley.js",
"app/vendor/markitup/markitup/jquery.markitup.js", paths.app + "vendor/pikaday/pikaday.js",
"app/vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js", paths.app + "vendor/jquery-flot/jquery.flot.js",
"app/js/jquery.ui.git.js", paths.app + "vendor/jquery-flot/jquery.flot.pie.js",
"app/js/sha1.js", paths.app + "vendor/jquery-flot/jquery.flot.time.js",
"app/plugins/**/*.js" paths.app + "vendor/jquery-flot/jquery.flot.time.js",
] paths.app + "vendor/flot-axislabels/jquery.flot.axislabels.js",
} paths.app + "vendor/jquery-textcomplete/jquery.textcomplete.js",
paths.app + "vendor/markitup/markitup/jquery.markitup.js",
paths.app + "vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js",
paths.app + "js/jquery.ui.git.js",
paths.app + "js/sha1.js",
paths.app + "plugins/**/*.js"
]
############################################################################ ############################################################################
# Layout/CSS Related tasks # Layout/CSS Related tasks
@ -89,125 +95,153 @@ gulp.task "jade-deploy", ->
.pipe(plumber()) .pipe(plumber())
.pipe(cache("jade")) .pipe(cache("jade"))
.pipe(jade({pretty: false})) .pipe(jade({pretty: false}))
.pipe(gulp.dest("#{paths.dist}/partials")) .pipe(gulp.dest(paths.dist + "partials/"))
gulp.task "jade-watch", -> gulp.task "jade-watch", ->
gulp.src(paths.jade) gulp.src(paths.jade)
.pipe(plumber()) .pipe(plumber())
.pipe(cache("jade")) .pipe(cache("jade"))
.pipe(jadeInheritance({basedir: './app'})) .pipe(jadeInheritance({basedir: "./app"}))
.pipe(jade({pretty: true})) .pipe(jade({pretty: true}))
.pipe(gulp.dest("#{paths.dist}")) .pipe(gulp.dest(paths.dist))
gulp.task "template", -> gulp.task "templates", ->
gulp.src("#{paths.app}/index.jade") gulp.src(paths.app + "index.jade")
.pipe(plumber()) .pipe(plumber())
.pipe(jade({pretty: true, locals:{v:(new Date()).getTime()}})) .pipe(jade({pretty: true, locals:{v:(new Date()).getTime()}}))
.pipe(gulp.dest("#{paths.dist}")) .pipe(gulp.dest(paths.dist))
gulp.task "sass-lint", -> gulp.task "sass-lint", ->
gulp.src([paths.scssStyles, '!app/styles/bourbon/**/*.scss']) gulp.src(paths.sass)
.pipe(cache("sasslint")) .pipe(cache("sasslint"))
.pipe(scsslint({config: "scsslint.yml"})) .pipe(scsslint({config: "scsslint.yml"}))
gulp.task "sass-watch", ["sass-lint"], -> gulp.task "sass-watch", ["sass-lint"], ->
gulp.src(paths.sassStylesMain) gulp.src(paths.app + "styles/main.scss")
.pipe(plumber()) .pipe(plumber())
.pipe(sass()) .pipe(sass())
.pipe(rename("app.css")) .pipe(rename("app.css"))
.pipe(gulp.dest(paths.distStylesPath)) .pipe(gulp.dest(paths.tmp))
gulp.task "sass-deploy", -> gulp.task "sass-deploy", ->
gulp.src(paths.sassStylesMain) gulp.src(paths.app + "styles/main.scss")
.pipe(plumber()) .pipe(plumber())
.pipe(sass()) .pipe(sass())
.pipe(rename("app.css")) .pipe(rename("app.css"))
.pipe(gulp.dest(paths.distStylesPath)) .pipe(gulp.dest(paths.tmp))
gulp.task "css-vendor", -> gulp.task "css-vendor", ->
gulp.src(paths.css) gulp.src(paths.css)
.pipe(concat("vendor.css")) .pipe(concat("vendor.css"))
.pipe(gulp.dest(paths.distStylesPath)) .pipe(gulp.dest(paths.tmp))
gulp.task "css-lint-app", ["sass-watch"], -> gulp.task "css-lint-app", ["sass-watch"], ->
gulp.src(paths.distStylesPath + "/app.css") gulp.src(paths.tmp + "app.css")
.pipe(csslint("csslintrc.json")) .pipe(csslint("csslintrc.json"))
.pipe(csslint.reporter()) .pipe(csslint.reporter())
gulp.task "styles-watch", ["sass-watch", "css-vendor", "css-lint-app"], -> gulp.task "styles-watch", ["sass-watch", "css-vendor", "css-lint-app"], ->
gulp.src(paths.distStyles) _paths = [
paths.tmp + "vendor.css",
paths.tmp + "app.css"
]
gulp.src(_paths)
.pipe(concat("main.css")) .pipe(concat("main.css"))
.pipe(gulp.dest(paths.distStylesPath)) .pipe(gulp.dest(paths.dist + "styles/"))
gulp.task "styles-deploy", ["sass-deploy", "css-vendor"], -> gulp.task "styles-deploy", ["sass-deploy", "css-vendor"], ->
gulp.src(paths.distStyles) _paths = [
paths.tmp + "vendor.css",
paths.tmp + "app.css"
]
gulp.src(_paths)
.pipe(concat("main.css")) .pipe(concat("main.css"))
.pipe(minifyCSS()) .pipe(minifyCSS())
.pipe(gulp.dest(paths.distStylesPath)) .pipe(gulp.dest(paths.dist + "styles/"))
############################################################################## ##############################################################################
# JS Related tasks # JS Related tasks
############################################################################## ##############################################################################
gulp.task "conf", ->
gulp.src("conf/main.json")
.pipe(wrap("angular.module('taigaBase').value('localconf', <%= contents %>);"))
.pipe(concat("conf.js"))
.pipe(gulp.dest(paths.tmp));
gulp.task "locales", -> gulp.task "locales", ->
gulp.src("app/locales/en/app.json") gulp.src("app/locales/en/app.json")
.pipe(wrap("angular.module('taigaLocales').constant('localesEnglish', <%= contents %>);")) .pipe(wrap("angular.module('taigaBase').value('localesEn', <%= contents %>);"))
.pipe(rename("localeEnglish.coffee")) .pipe(rename("locales.en.js"))
.pipe(gulp.dest("app/coffee/modules/locales")) .pipe(gulp.dest(paths.tmp))
# gulp.src("app/locales/es/app.json") gulp.task "coffee", ->
# .pipe(wrap("angular.module('locales.es', []).constant('locales.es', <%= contents %>);"))
# .pipe(rename("locale.es.coffee"))
# .pipe(gulp.dest("app/coffee/"))
gulp.task "coffee-watch", ["locales"], ->
gulp.src(paths.coffee) gulp.src(paths.coffee)
.pipe(plumber()) .pipe(plumber())
.pipe(coffee()) .pipe(coffee())
.pipe(concat("app.js")) .pipe(concat("app.js"))
.pipe(gulp.dest("dist/js/")) .pipe(gulp.dest(paths.tmp))
gulp.task "coffee-deploy", ["locales"], ->
gulp.src(paths.coffee)
.pipe(plumber())
.pipe(coffee())
.pipe(concat("app.js"))
.pipe(uglify({mangle:false, preserveComments: false}))
.pipe(gulp.dest("dist/js/"))
gulp.task "jslibs-watch", -> gulp.task "jslibs-watch", ->
gulp.src(paths.vendorJsLibs) gulp.src(paths.js)
.pipe(plumber()) .pipe(plumber())
.pipe(concat("libs.js")) .pipe(concat("libs.js"))
.pipe(gulp.dest("dist/js/")) .pipe(gulp.dest("dist/js/"))
gulp.task "jslibs-deploy", -> gulp.task "jslibs-deploy", ->
gulp.src(paths.vendorJsLibs) gulp.src(paths.js)
.pipe(plumber()) .pipe(plumber())
.pipe(concat("libs.js")) .pipe(concat("libs.js"))
.pipe(uglify({mangle:false, preserveComments: false})) .pipe(uglify({mangle:false, preserveComments: false}))
.pipe(gulp.dest("dist/js/")) .pipe(gulp.dest("dist/js/"))
gulp.task "app-watch", ["coffee", "conf", "locales"], ->
_paths = [
paths.tmp + "app.js",
paths.tmp + "conf.js",
paths.tmp + "locales.en.js"
]
gulp.src(_paths)
.pipe(concat("app.js"))
.pipe(gulp.dest(paths.dist + "js/"));
gulp.task "app-deploy", ["coffee", "conf", "locales"], ->
_paths = [
paths.tmp + "app.js",
paths.tmp + "conf.js",
paths.tmp + "locales.en.js"
]
gulp.src(_paths)
.pipe(concat("app.js"))
.pipe(uglify({mangle:false, preserveComments: false}))
.pipe(gulp.dest(paths.dist + "js/"));
############################################################################## ##############################################################################
# Common tasks # Common tasks
############################################################################## ##############################################################################
# SVG # SVG
gulp.task "svg", -> gulp.task "copy-svg", ->
gulp.src("#{paths.app}/svg/**/*") gulp.src("#{paths.app}/svg/**/*")
.pipe(gulp.dest("#{paths.dist}/svg/")) .pipe(gulp.dest("#{paths.dist}/svg/"))
# Copy Files gulp.task "copy-fonts", ->
gulp.task "copy", ->
gulp.src("#{paths.app}/fonts/*") gulp.src("#{paths.app}/fonts/*")
.pipe(gulp.dest("#{paths.dist}/fonts/")) .pipe(gulp.dest("#{paths.dist}/fonts/"))
gulp.task "copy-images", ->
gulp.src("#{paths.app}/images/**/*") gulp.src("#{paths.app}/images/**/*")
.pipe(gulp.dest("#{paths.dist}/images/")) .pipe(gulp.dest("#{paths.dist}/images/"))
gulp.task "copy-plugin-templates", ->
gulp.src("#{paths.app}/plugins/**/templates/*") gulp.src("#{paths.app}/plugins/**/templates/*")
.pipe(gulp.dest("#{paths.dist}/plugins/")) .pipe(gulp.dest("#{paths.dist}/plugins/"))
gulp.task "copy", ["copy-fonts", "copy-images", "copy-plugin-templates", "copy-svg"]
gulp.task "express", -> gulp.task "express", ->
express = require("express") express = require("express")
@ -230,32 +264,33 @@ gulp.task "express", ->
# Rerun the task when a file changes # Rerun the task when a file changes
gulp.task "watch", -> gulp.task "watch", ->
gulp.watch(paths.jade, ["jade-watch"]) gulp.watch(paths.jade, ["jade-watch"])
gulp.watch("#{paths.app}/index.jade", ["template"]) gulp.watch(paths.app + "index.jade", ["templates"])
gulp.watch(paths.scssStyles, ["styles-watch"]) gulp.watch(paths.sass, ["styles-watch"])
gulp.watch(paths.svg, ["svg"]) gulp.watch(paths.svg, ["copy-svg"])
gulp.watch(paths.coffee, ["coffee-watch"]) gulp.watch(paths.coffee, ["app-watch"])
gulp.watch(paths.vendorJsLibs, ["jslibs-watch"]) gulp.watch(paths.js, ["jslibs-watch"])
gulp.watch(paths.locales, ["coffee-watch"]) gulp.watch(paths.locales, ["app-watch"])
gulp.watch(paths.images, ["copy-images"])
gulp.watch(paths.fonts, ["copy-fonts"])
gulp.task "deploy", [ gulp.task "deploy", [
"jade-deploy", "templates",
"template",
"copy", "copy",
"svg", "jade-deploy",
"coffee-deploy", "app-deploy",
"jslibs-deploy", "jslibs-deploy",
"styles-deploy" "styles-deploy"
] ]
# The default task (called when you run gulp from cli) # The default task (called when you run gulp from cli)
gulp.task "default", [ gulp.task "default", [
"jade-deploy",
"template",
"styles-watch",
"svg",
"copy", "copy",
"coffee-watch", "templates",
"styles-watch",
"app-watch",
"jslibs-watch", "jslibs-watch",
"jade-deploy",
"express", "express",
"watch" "watch"
] ]