diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..9367914 --- /dev/null +++ b/.npmignore @@ -0,0 +1,15 @@ +*~ +.DS_Store + +.idea/ +.vagrant/ +node_modules/ +bower_components/ + +/package.box +/npm-debug.log + +/.remote-sync.json +/session.key +/config.coffee +/coverage-reporter.html diff --git a/app.coffee b/app.coffee old mode 100755 new mode 100644 diff --git a/bower.json b/bower.json index 3872bcc..7ff5f3f 100644 --- a/bower.json +++ b/bower.json @@ -7,7 +7,12 @@ "jquery": "~2.1.2", "backbone": "~1.1.2", "moment": "~2.9.0", - "jquery-tmpl": "vBeta1.0.0", + "jquery-tmpl": "git://github.com/jquery/jquery-tmpl.git#b504c8afba", "q": "~1.2.0" + }, + "overrides": { + "jquery-tmpl": { + "main": "jquery.tmpl.js" + } } } diff --git a/core/public/script/components.coffee b/core/public/script/components.coffee index 16dd50b..7cb1fe1 100644 --- a/core/public/script/components.coffee +++ b/core/public/script/components.coffee @@ -4,7 +4,7 @@ $ -> CompontentCollection = Backbone.Collection.extend model: Component - url: '/component/resource/' + url: '/components/' ListItemView = Backbone.View.extend tagName: 'tr' diff --git a/core/public/script/layout.coffee b/core/public/script/layout.coffee index 493e563..2af1c3b 100644 --- a/core/public/script/layout.coffee +++ b/core/public/script/layout.coffee @@ -1,9 +1,4 @@ $ -> - _.templateSettings = - evaluate: /\{%([\s\S]+?)%\}/g, - interpolate: /\{:([\s\S]+?)\}\}/g - escape: /\{\{([\s\S]+?)\}\}/g - _.extend window.RP, i18n_data: {} diff --git a/core/public/script/root.coffee b/core/public/script/root.coffee index 0134731..efcca0e 100644 --- a/core/public/script/root.coffee +++ b/core/public/script/root.coffee @@ -3,9 +3,17 @@ methods = ['get', 'post', 'delete', 'put', 'patch', 'head', 'options'] window.root = agent: {} + # Private: (name) -> String t: (name) -> return name + # Private: (selector) -> (view_data) -> String + tmpl: (selector) -> + cache = $(selector).template() + + return (view_data) -> + return $.tmpl cache, view_data + methods.forEach (method) -> root.agent[method] = (url, data, options = {}) -> unless method == 'get' diff --git a/core/public/script/ticket.coffee b/core/public/script/ticket.coffee index 4d8df67..fb0f140 100644 --- a/core/public/script/ticket.coffee +++ b/core/public/script/ticket.coffee @@ -1,4 +1,8 @@ $ -> + $.ajaxSetup + headers: + 'X-Token': $.cookie 'token' + color_mapping = closed: 'muted' open: 'primary' @@ -12,7 +16,7 @@ $ -> model: Reply Ticket = Backbone.Model.extend - urlRoot: '/ticket/rest/' + urlRoot: '/tickets' idAttribute: '_id' initialize: -> @@ -24,7 +28,7 @@ $ -> TicketCollection = Backbone.Collection.extend model: Ticket - url: '/ticket/rest/' + url: '/tickets' CreateView = Backbone.View.extend el: '#create-view' @@ -38,14 +42,14 @@ $ -> content: @$('[name=content]').val() ticket.save().success (ticket) -> - location.href = "/ticket/view/#{ticket._id}" + location.href = "/tickets/#{ticket._id}/view" ReplyView = Backbone.View.extend tagName: 'li' className: 'list-group-item clearfix' initialize: -> - @template = RP.tmpl '#reply-template' + @template = root.tmpl '#reply-template' @model.on 'change', @render.bind @ render: -> @@ -70,10 +74,10 @@ $ -> @model.fetch() - @templateContent = RP.tmpl '#content-template' - @templateActions = RP.tmpl '#actions-template' - @templateAccountInfo = RP.tmpl '#account-info-template' - @templateMembers = RP.tmpl '#members-template' + @templateContent = root.tmpl '#content-template' + @templateActions = root.tmpl '#actions-template' + @templateAccountInfo = root.tmpl '#account-info-template' + @templateMembers = root.tmpl '#members-template' render: -> view_data = @model.toJSON() @@ -108,7 +112,7 @@ $ -> tagName: 'tr' initialize: -> - @template = RP.tmpl '#list-item-template' + @template = root.tmpl '#list-item-template' render: -> view_data = @model.toJSON() @@ -132,9 +136,9 @@ $ -> TicketRouter = Backbone.Router.extend routes: - 'ticket/create(/)': 'create' - 'ticket/list(/)': 'list' - 'ticket/view/:id(/)': 'view' + 'tickets/create(/)': 'create' + 'tickets/list(/)': 'list' + 'tickets/:id/view(/)': 'view' create: -> new CreateView() list: -> new ListView() diff --git a/core/router/panel.coffee b/core/router/panel.coffee index 7ab209c..28060d8 100644 --- a/core/router/panel.coffee +++ b/core/router/panel.coffee @@ -16,6 +16,7 @@ router.use requireAuthenticate ### router.get '/financials', (req, res, next) -> Q.all([ + null Financials.getDepositLogs req.account, req: req, limit: 10 Financials.getBillingLogs req.account, limit: 10 ]).done ([payment_providers, deposit_logs, billing_logs]) -> diff --git a/core/test/account.register.test.coffee b/core/test/router/account.test.coffee similarity index 98% rename from core/test/account.register.test.coffee rename to core/test/router/account.test.coffee index 72a2559..795d5eb 100644 --- a/core/test/account.register.test.coffee +++ b/core/test/router/account.test.coffee @@ -1,4 +1,4 @@ -describe 'account.register', -> +describe 'router.account', -> agent = createAgent baseUrl: '/account' diff --git a/core/test/tickets.user.test.coffee b/core/test/router/tickets.test.coffee similarity index 96% rename from core/test/tickets.user.test.coffee rename to core/test/router/tickets.test.coffee index 3825bac..d8642d8 100644 --- a/core/test/tickets.user.test.coffee +++ b/core/test/router/tickets.test.coffee @@ -1,4 +1,4 @@ -describe 'tickets.user', -> +describe 'router.tickets', -> agent = createLoggedAgent baseUrl: '/tickets' diff --git a/core/view/panel/financials.jade b/core/view/panel/financials.jade index c4e4e22..3a8fb20 100644 --- a/core/view/panel/financials.jade +++ b/core/view/panel/financials.jade @@ -18,7 +18,7 @@ block main th= t('common.amount') th= t('view.financials.pay_method') tbody - for item in deposit_log + for item in deposit_logs tr td= moment(item.created_at).format('YYYY-MM-DD HH:mm:ss') td #{item.amount.toFixed(2)} #{t('plan.currency.' + config.billing.currency)} @@ -36,7 +36,7 @@ block main th= t('common.details') th= t('common.amount') tbody - for item in billing_log + for item in billing_logs tr td= moment(item.created_at).format('YYYY-MM-DD HH:mm:ss') td diff --git a/core/view/ticket/list.jade b/core/view/ticket/list.jade index 6f859a5..eb8cf5e 100644 --- a/core/view/ticket/list.jade +++ b/core/view/ticket/list.jade @@ -22,6 +22,6 @@ prepend sidebar append footer script(id='list-item-template', type='text/x-jquery-tmpl') td - a(href='/tickets/view/${_id}') ${title} + a(href='/tickets/${_id}/view') ${title} td - span(class='text-${color}') ${RP.t('ticket_status.' + status)} + span(class='text-${color}') ${root.t('ticket_status.' + status)} diff --git a/core/view/ticket/view.jade b/core/view/ticket/view.jade index 48fa36c..c2ed41f 100644 --- a/core/view/ticket/view.jade +++ b/core/view/ticket/view.jade @@ -24,7 +24,7 @@ append footer script(id='content-template', type='text/x-jquery-tmpl') header | ${title}   - span.small(class='text-${color}') ${RP.t('ticket_status.' + status)} + span.small(class='text-${color}') ${root.t('ticket_status.' + status)} p {{html content_html}} script(id='reply-template', type='text/x-jquery-tmpl') diff --git a/gulpfile.coffee b/gulpfile.coffee index 168b0e6..7ad642c 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -2,6 +2,7 @@ del = require 'del' gulp = require 'gulp' less = require 'gulp-less' shell = require 'gulp-shell' +debug = require 'gulp-debug' order = require 'gulp-order' rsync = require 'gulp-rsync' coffee = require 'gulp-coffee' @@ -34,7 +35,7 @@ gulp.task 'vendor:scripts', -> gulp.task 'vendor:fonts', -> gulp.src bowerFiles() - .pipe filter ['*.eot', '*.svg', '*.ttf', '*.woff'] + .pipe filter ['*.eot', '*.svg', '*.ttf', '*.woff', '*.woff2'] .pipe gulp.dest 'public/fonts' gulp.task 'build:vendor', -> @@ -51,7 +52,7 @@ gulp.task 'build:styles', -> gulp.src 'core/public/style/*.less' .pipe less() .pipe concat 'core.css' - .pipe minifyCss() + # .pipe minifyCss() .pipe gulp.dest 'public' gulp.task 'build:scripts', -> @@ -59,7 +60,7 @@ gulp.task 'build:scripts', -> .pipe coffee() .pipe order ['root.coffee', '*'] .pipe concat 'core.js' - .pipe uglify() + # .pipe uglify() .pipe gulp.dest 'public' gulp.task 'watch', -> diff --git a/package.json b/package.json index 4b44959..ccbfb8a 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,9 @@ ], "main": "core", "scripts": { + "prepushlish": "gulp build", "start": "coffee app.coffee", - "test": "mocha --compilers coffee:coffee-script/register --require test/env -- core/test/*.test.coffee", + "test": "mocha --compilers coffee:coffee-script/register --require test/env --recursive core/test", "docker-build": "docker build -t=jysperm/rootpanel .", "docker-create": "docker run --name rootpanel -P -v `pwd`:/rootpanel -i -t jysperm/rootpanel", "docker-start": "docker start -i -a rootpanel" @@ -67,6 +68,7 @@ "gulp": "^3.8.11", "gulp-coffee": "^2.3.1", "gulp-concat": "^2.5.2", + "gulp-debug": "^2.0.1", "gulp-filter": "^2.0.2", "gulp-less": "^3.0.3", "gulp-minify-css": "^1.1.0", diff --git a/test/snippet.coffee b/test/snippet.coffee index cab0b09..a8bdedf 100644 --- a/test/snippet.coffee +++ b/test/snippet.coffee @@ -101,6 +101,17 @@ createLoggedAgent = (options) -> return agent +_.extend global, { + utils + + ifEnabled + unlessTravis + randomAccount + + createAgent + createLoggedAgent +} + printHttpResponse = ({httpVersion, statusCode, statusMessage, headers, body}) -> message = """ Response: @@ -119,14 +130,3 @@ printHttpResponse = ({httpVersion, statusCode, statusMessage, headers, body}) -> message += "\n#{body}" return message - -_.extend global, { - utils - - ifEnabled - unlessTravis - randomAccount - - createAgent - createLoggedAgent -}