diff --git a/assets.json b/assets.json new file mode 100644 index 0000000..107853b --- /dev/null +++ b/assets.json @@ -0,0 +1,42 @@ +{ + "base": { + "css": [ + "main" + ], + + "js": [ + "async", "json2", "polyfill", + "JSONFormatter", "URLParse", "Cookie", + "handlebars.runtime", "template" + ] + }, + + "ui": { + "group": [ + "base" + ], + + "css": [ + "explorer" + ], + + "view": [ + "body", + "filters", "filter", "actions", + "request", "response", + "edit", "field", + + "explorer", + "column", + "column-links", + "column-collection", + "column-resource" + ], + + "js": [ + "HTMLApi", + "Explorer", + "init" + ] + } +} diff --git a/compile b/compile index ce77406..23025ee 100755 --- a/compile +++ b/compile @@ -2,7 +2,7 @@ var assets = require('gd-assets'); -var groups = assets.groups(__dirname+'/groups.json'); +var groups = assets.groups.load(__dirname+'/assets.json'); var pkg = require('./package.json'); var outputDir = __dirname+'/compiled'; diff --git a/groups.json b/groups.json deleted file mode 100644 index d87b699..0000000 --- a/groups.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "ui": { - "css": [ - "main.css", - "explorer.css" - ], - - "js": [ - "async.js", - "json2.js", - "polyfill.js", - "JSONFormatter.js", - "URLParse.js", - "Cookie.js", - "handlebars.runtime.js", - "template.js", - "view:body.hbs", - "view:filters.hbs", - "view:filter.hbs", - "view:actions.hbs", - "view:request.hbs", - "view:response.hbs", - "view:edit.hbs", - "view:field.hbs", - "view:explorer.hbs", - "view:column.hbs", - "view:column-links.hbs", - "view:column-collection.hbs", - "view:column-resource.hbs", - "init.js", - "HTMLApi.js", - "Explorer.js" - ] - } -} diff --git a/package.json b/package.json index 5f28d01..bcb70f6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gdapi-ui", - "version": "0.0.1", + "version": "1.1.1", "dependencies": { - "gd-assets": "0.0.x" + "gd-assets": "1.0.x" } } diff --git a/public/js/Explorer.js b/public/js/Explorer.js index 0fd26bc..c9df318 100644 --- a/public/js/Explorer.js +++ b/public/js/Explorer.js @@ -10,7 +10,7 @@ Explorer.prototype.show = function(cb) var tpl = { }; - document.body.innerHTML = Handlebars.templates['explorer.hbs'](tpl); + document.body.innerHTML = Handlebars.templates['explorer'](tpl); $('#explorer').css('top', $('#header')[0].offsetHeight + 'px'); this.rootColumn(); @@ -79,7 +79,7 @@ Explorer.prototype.addPlaceholder = function() num: this._columns.length + 1 }; - var html = Handlebars.templates['column.hbs'](tpl); + var html = Handlebars.templates['column'](tpl); $('#explorer').append(html); var elem = $('#column_'+ id); @@ -134,7 +134,7 @@ Explorer.prototype.populateColumn = function(idOrElem, obj) links: links, }; - var html = Handlebars.templates['column-collection.hbs'](tpl); + var html = Handlebars.templates['column-collection'](tpl); col.html(html); col.on('click', $.proxy(this.followLink, this)); @@ -152,7 +152,7 @@ Explorer.prototype.populateColumn = function(idOrElem, obj) links: links, }; - var html = Handlebars.templates['column-resource.hbs'](tpl); + var html = Handlebars.templates['column-resource'](tpl); col.html(html); $('.column-links',col).on('click', $.proxy(this.followLink, this)); diff --git a/public/js/HTMLApi.js b/public/js/HTMLApi.js index 62eecfe..eef2c2e 100644 --- a/public/js/HTMLApi.js +++ b/public/js/HTMLApi.js @@ -208,7 +208,7 @@ HTMLApi.prototype.render = function(cb) docs: this._docs }; - document.body.innerHTML = Handlebars.templates['body.hbs'](tpl); + document.body.innerHTML = Handlebars.templates['body'](tpl); $('#json').html(jsonHtml); this._addCollapsers(); @@ -330,7 +330,7 @@ HTMLApi.prototype.actionInit = function(cb) if ( !data.actions ) return async.nextTick(cb); - var html = Handlebars.templates['actions.hbs']({ + var html = Handlebars.templates['actions']({ actions: data.actions }); $('#actions').html(html); @@ -385,7 +385,7 @@ HTMLApi.prototype.actionLoad = function(name, obj, body) self.actionLoad(name, obj); } - var html = Handlebars.templates['edit.hbs'](tpl); + var html = Handlebars.templates['edit'](tpl); var popinActions = [ {id: 'ok', text: 'Show Request', /*on_enter: true, */ onClick: function() { self.showRequest('POST',actionInput,retry,url); }.bind(self) }, {id: 'cancel', text: 'Cancel', cancel: true } @@ -437,7 +437,7 @@ HTMLApi.prototype.filterInit = function(cb) } } - var html = Handlebars.templates['filters.hbs']({ + var html = Handlebars.templates['filters']({ canFilter: canFilter, hasFilters: (filters.length > 0) }); @@ -447,7 +447,7 @@ HTMLApi.prototype.filterInit = function(cb) { v = filters[i]; - html = Handlebars.templates['filter.hbs']({ + html = Handlebars.templates['filter']({ allFilterSchema: schema.collectionFilters, thisFilterSchema: schema.collectionFilters[v.name], cur: v @@ -475,7 +475,7 @@ HTMLApi.prototype.filterAdd = function(name, modifier, value, before) value: value || '' }; - html = Handlebars.templates['filter.hbs']({ + html = Handlebars.templates['filter']({ allFilterSchema: schemaFilters, thisFilterSchema: schemaFilters[name], cur: cur @@ -773,7 +773,7 @@ HTMLApi.prototype.request = function(method,body,opt,really) tpl.contentType = 'application/json'; } - var html = Handlebars.templates['request.hbs'](tpl); + var html = Handlebars.templates['request'](tpl); self._setupModal(html); @@ -823,7 +823,7 @@ HTMLApi.prototype.requestDone = function(err, body, res) tpl.responseHeaders = headers; } - var html = Handlebars.templates['response.hbs'](tpl); + var html = Handlebars.templates['response'](tpl); var out = ''; var selfUrl = false; @@ -1026,7 +1026,7 @@ HTMLApi.prototype.showEdit = function(data,update,schema,url) } var title = (update ? 'Edit' : 'Create') +' '+ schema.id; - var html = Handlebars.templates['edit.hbs'](tpl); + var html = Handlebars.templates['edit'](tpl); var method = (update ? 'PUT' : 'POST'); var popinActions = [ {id: 'ok', text: 'Show Request', /*on_enter: true, */ onClick: function() { self.showRequest(method,schema,retry,url); }.bind(self) }, @@ -1389,7 +1389,7 @@ HTMLApi.prototype.subAdd = function(button, name) var field = this._flattenField('update',name,schemaField,'',1); field.parentIsMap = parentField.type == 'map'; - var html = Handlebars.templates['field.hbs'](field); + var html = Handlebars.templates['field'](field); html = '
' + html + '
'; $(button).before(html); diff --git a/public/view/column-collection.hbs b/public/view/column-collection.hbs index dc95e70..d6dbb56 100644 --- a/public/view/column-collection.hbs +++ b/public/view/column-collection.hbs @@ -2,7 +2,7 @@ Collection -{{>column-links.hbs}} +{{>column-links}}
-{{>column-links.hbs}} +{{>column-links}} {{#eachProperty data}} diff --git a/public/view/edit.hbs b/public/view/edit.hbs index 4471b7c..7ef030e 100644 --- a/public/view/edit.hbs +++ b/public/view/edit.hbs @@ -18,7 +18,7 @@
{{#if writable}} - {{>field.hbs}} + {{>field}} {{else}} {{#if value}} diff --git a/public/view/field.hbs b/public/view/field.hbs index 76329b4..7e538a5 100644 --- a/public/view/field.hbs +++ b/public/view/field.hbs @@ -1,7 +1,7 @@ {{#ifInList type 'array,map'}}
{{#each children}} - {{>field.hbs}} + {{>field}} {{/each}} {{/ifInList}} diff --git a/serve b/serve index a693b41..c82d6c6 100755 --- a/serve +++ b/serve @@ -2,7 +2,7 @@ var assets = require('gd-assets'); -var groups = assets.groups(__dirname+'/groups.json'); +var groups = assets.groups.load(__dirname+'/assets.json'); var pkg = require('./package.json'); -assets.server(groups, pkg, 3000); +assets.server(groups, pkg, process.argv[2] || 3000);