Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added assets.json environment override for including custom css and j… #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions _template/app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,33 @@ new Vue({

_this.$http.get('./data.json' + '?cb=' + new Date()).then(function (response) {
_this.initData(response.data, function() {
if(_this.$data.groups.length) {
_this.setupGroups();
} else {
_this.logInfo('You need to add a component to your library before it can be loaded.<br/>You can either do this manually by editing your <code>data.json</code> file,<br/> or you can use the command line helper: <code>astrum new [group_name/component_name]</code>');
}
_this.$http.get('./assets.json' + '?cb=' + new Date()).then(function (response) {
_this.initCustomData(response.data, 'assets', function() {
// Initialize groups after finding and merging custom asset overrides.
_this.initializeGroups();
});
}).catch(function() {
// Initialize groups after failing to find custom asset overrides.
_this.initializeGroups();
});
});
});
},

/**
* Initialize the groups, display a message if no groups have been added.
*/

initializeGroups: function() {
var _this = this;

if(_this.$data.groups.length) {
_this.setupGroups();
} else {
_this.logInfo('You need to add a component to your library before it can be loaded.<br/>You can either do this manually by editing your <code>data.json</code> file,<br/> or you can use the command line helper: <code>astrum new [group_name/component_name]</code>');
}
},

/**
* Determine if a page should be loaded.
*/
Expand Down Expand Up @@ -534,6 +552,23 @@ new Vue({
callback();
},

/**
* Initilise data bindings.
*
* @param data
*/
initCustomData: function(data, key, callback) {
callback = typeof callback !== 'undefined' ? callback : function() {};

var _this = this;

// Override assets
if(data) {
_this.$set(key, data);
}
callback();
},

/**
* Update URL hash.
*
Expand Down