Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jz committed Feb 14, 2018
2 parents 13e62e1 + 5982a3c commit 04dd938
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 30 additions & 12 deletions plugins/github/server/Deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class GitHubDeployer extends HashBrown.Models.Deployer {
// If using recursion, get tree instead
if(recursions > 0) {
path = this.extractSubPath(path);


// First get the entire tree
return HashBrown.Helpers.RequestHelper.request('get', 'https://api.github.com/repos/' + this.repo + '/git/trees/' + (this.branch || 'gh-pages') + '?recursive=1&access_token=' + this.token)
.then((data) => {
if(!data || !data.tree) {
Expand All @@ -118,19 +119,36 @@ class GitHubDeployer extends HashBrown.Models.Deployer {

return Promise.resolve(data.tree);
})

// Then get each downloadable URL (necessary for private repos)
.then((tree) => {
for(let i = tree.length -1; i >= 0; i--) {
// Remove anything that's not a file or is not in the target path
if(tree[i].mode !== '100644' || tree[i].path.indexOf(path) !== 0) {
tree.splice(i, 1);
continue;
}

// Replace API URL with static url
tree[i].url = 'https://raw.githubusercontent.com/' + this.repo + '/' + (this.branch || 'gh-pages') + '/' + tree[i].path + '?sanitize=true';
}
let files = [];

let getNextFile = () => {
let file = tree.pop();

if(!file) { return Promise.resolve(files); }

// Skip anything that's not a file or is not in the target path
if(file.mode !== '100644' || file.path.indexOf(path) !== 0) { return getNextFile(); }

return HashBrown.Helpers.RequestHelper.request('get', 'http://api.github.com/repos/' + this.repo + '/contents/' + file.path + '?ref=' + (this.branch || 'gh-pages') + '&access_token=' + this.token)
.then((result) => {
file.url = result.download_url;

files.push(file);

return getNextFile();
})

// The GET request might fail if the file is too big, but then just skip it
.catch(() => {
return getNextFile();

});
};

return Promise.resolve(tree);
return getNextFile();
});
}

Expand Down
1 change: 1 addition & 0 deletions public/css/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,7 @@ h1, h2, h3, h4, h5, h6 {
z-index: 5;
background: transparent;
right: 0;
height: 100%;
top: 50%;
transform: translateY(-50%);
color: #e70d3b;
Expand Down
32 changes: 24 additions & 8 deletions public/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6265,9 +6265,9 @@ var Modal = function (_Crisp$View) {
return;
}

return [_.h4({ class: 'modal__title' }, this.title), _.button({ class: 'modal__close fa fa-close' }).click(function () {
return [_.h4({ class: 'modal__title' }, this.title), _.if(!this.isBlocking, _.button({ class: 'modal__close fa fa-close' }).click(function () {
_this4.close();
})];
}))];
};

/**
Expand All @@ -6289,7 +6289,7 @@ var Modal = function (_Crisp$View) {
}, 50);
}

return _.div({ class: 'modal' + (this.hasTransitionedIn ? ' in' : '') + (this.group ? ' ' + this.group : '') + (this.className ? ' modal--' + this.className : '') }, _.div({ class: 'modal__dialog' }, _.div({ class: 'widget--spinner embedded hidden' }, _.div({ class: 'widget--spinner__image fa fa-refresh' })), _.if(header, _.div({ class: 'modal__header' }, header)), _.if(body, _.div({ class: 'modal__body' }, body)), _.if(footer, _.div({ class: 'modal__footer' }, footer))));
return _.div({ class: 'modal' + (this.hasTransitionedIn ? ' in' : '') + (this.group ? ' ' + this.group : '') + (this.className ? ' modal--' + this.className : '') }, _.div({ class: 'modal__dialog' }, _.div({ class: 'widget--spinner embedded hidden' }, _.div({ class: 'widget--spinner__image fa fa-refresh' })), _.if(header, _.div({ class: 'modal__header' }, header)), _.if(body, _.div({ class: 'modal__body' }, body)), _.if(footer && !this.isBlocking, _.div({ class: 'modal__footer' }, footer))));
};

/**
Expand Down Expand Up @@ -21163,7 +21163,7 @@ module.exports = {
"_args": [
[
"[email protected]",
"/home/mrzapp/Development/Web/hashbrown-cms"
"/home/jz/Development/Web/hashbrown-cms"
]
],
"_development": true,
Expand All @@ -21189,7 +21189,7 @@ module.exports = {
],
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
"_spec": "6.4.0",
"_where": "/home/mrzapp/Development/Web/hashbrown-cms",
"_where": "/home/jz/Development/Web/hashbrown-cms",
"author": {
"name": "Fedor Indutny",
"email": "[email protected]"
Expand Down Expand Up @@ -32515,7 +32515,7 @@ var ContentEditor = function (_Crisp$View) {
}

// Construct remote URL
if (contentUrl !== '/' && contentUrl !== '//') {
if (contentUrl && contentUrl !== '//') {
remoteUrl = connection.url + contentUrl;
remoteUrl = remoteUrl.replace(/\/\//g, '/').replace(':/', '://');
} else {
Expand Down Expand Up @@ -33895,12 +33895,15 @@ var UIHelper = function () {

UIHelper.messageModal = function messageModal(title, body, onClickOK, group) {
var modal = new HashBrown.Views.Modals.Modal({
isBlocking: onClickOK === false,
title: title,
group: group,
body: body
});

modal.on('ok', onClickOK);
if (onClickOK) {
modal.on('ok', onClickOK);
}

return modal;
};
Expand Down Expand Up @@ -41515,7 +41518,20 @@ var MediaViewer = function (_Crisp$View) {


MediaViewer.prototype.template = function template() {
var mediaSrc = (this.model.url || '/media/' + ProjectHelper.currentProject + '/' + ProjectHelper.currentEnvironment + '/' + this.model.id) + '?' + Date.now();
var mediaSrc = this.model.url;

if (!mediaSrc) {
mediaSrc = '/media/' + ProjectHelper.currentProject + '/' + ProjectHelper.currentEnvironment + '/' + this.model.id;
}

// Add timestamp
if (mediaSrc.indexOf('?') > -1) {
mediaSrc += '&';
} else {
mediaSrc += '?';
}

mediaSrc += 't=' + Date.now();

return _.div({ class: 'editor editor--media' }, _.div({ class: 'editor__header' }, _.span({ class: 'editor__header__icon fa fa-file-image-o' }), _.h4({ class: 'editor__header__title' }, this.model.name, _.span({ class: 'editor__header__title__appendix' }, this.model.getContentTypeHeader()))), _.div({ class: 'editor__body' }, _.if(this.model.isImage(), _.img({ class: 'editor--media__preview', src: mediaSrc })), _.if(this.model.isVideo(), _.video({ class: 'editor--media__preview', controls: true }, _.source({ src: mediaSrc, type: this.model.getContentTypeHeader() })))));
};
Expand Down
15 changes: 9 additions & 6 deletions public/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6265,9 +6265,9 @@ var Modal = function (_Crisp$View) {
return;
}

return [_.h4({ class: 'modal__title' }, this.title), _.button({ class: 'modal__close fa fa-close' }).click(function () {
return [_.h4({ class: 'modal__title' }, this.title), _.if(!this.isBlocking, _.button({ class: 'modal__close fa fa-close' }).click(function () {
_this4.close();
})];
}))];
};

/**
Expand All @@ -6289,7 +6289,7 @@ var Modal = function (_Crisp$View) {
}, 50);
}

return _.div({ class: 'modal' + (this.hasTransitionedIn ? ' in' : '') + (this.group ? ' ' + this.group : '') + (this.className ? ' modal--' + this.className : '') }, _.div({ class: 'modal__dialog' }, _.div({ class: 'widget--spinner embedded hidden' }, _.div({ class: 'widget--spinner__image fa fa-refresh' })), _.if(header, _.div({ class: 'modal__header' }, header)), _.if(body, _.div({ class: 'modal__body' }, body)), _.if(footer, _.div({ class: 'modal__footer' }, footer))));
return _.div({ class: 'modal' + (this.hasTransitionedIn ? ' in' : '') + (this.group ? ' ' + this.group : '') + (this.className ? ' modal--' + this.className : '') }, _.div({ class: 'modal__dialog' }, _.div({ class: 'widget--spinner embedded hidden' }, _.div({ class: 'widget--spinner__image fa fa-refresh' })), _.if(header, _.div({ class: 'modal__header' }, header)), _.if(body, _.div({ class: 'modal__body' }, body)), _.if(footer && !this.isBlocking, _.div({ class: 'modal__footer' }, footer))));
};

/**
Expand Down Expand Up @@ -20380,7 +20380,7 @@ module.exports = {
"_args": [
[
"[email protected]",
"/home/mrzapp/Development/Web/hashbrown-cms"
"/home/jz/Development/Web/hashbrown-cms"
]
],
"_development": true,
Expand All @@ -20406,7 +20406,7 @@ module.exports = {
],
"_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
"_spec": "6.4.0",
"_where": "/home/mrzapp/Development/Web/hashbrown-cms",
"_where": "/home/jz/Development/Web/hashbrown-cms",
"author": {
"name": "Fedor Indutny",
"email": "[email protected]"
Expand Down Expand Up @@ -28980,12 +28980,15 @@ var UIHelper = function () {

UIHelper.messageModal = function messageModal(title, body, onClickOK, group) {
var modal = new HashBrown.Views.Modals.Modal({
isBlocking: onClickOK === false,
title: title,
group: group,
body: body
});

modal.on('ok', onClickOK);
if (onClickOK) {
modal.on('ok', onClickOK);
}

return modal;
};
Expand Down
5 changes: 4 additions & 1 deletion src/Client/Helpers/UIHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,15 @@ class UIHelper {
*/
static messageModal(title, body, onClickOK, group) {
let modal = new HashBrown.Views.Modals.Modal({
isBlocking: onClickOK === false,
title: title,
group: group,
body: body
});

modal.on('ok', onClickOK);
if(onClickOK) {
modal.on('ok', onClickOK);
}

return modal;
}
Expand Down
1 change: 1 addition & 0 deletions src/Client/Style/Views/Widgets/Dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
z-index: 5;
background: transparent;
right: 0;
height: 100%;
top: 50%;
transform: translateY(-50%);
color: $primary;
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Views/Editors/ContentEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class ContentEditor extends Crisp.View {
}

// Construct remote URL
if(contentUrl !== '/' && contentUrl !== '//') {
if(contentUrl && contentUrl !== '//') {
remoteUrl = connection.url + contentUrl;
remoteUrl = remoteUrl.replace(/\/\//g, '/').replace(':/', '://');

Expand Down
15 changes: 14 additions & 1 deletion src/Client/Views/Editors/MediaViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ class MediaViewer extends Crisp.View {
* Renders this editor
*/
template() {
let mediaSrc = (this.model.url || '/media/' + ProjectHelper.currentProject + '/' + ProjectHelper.currentEnvironment + '/' + this.model.id) + '?' + Date.now();
let mediaSrc = this.model.url;

if(!mediaSrc) {
mediaSrc = '/media/' + ProjectHelper.currentProject + '/' + ProjectHelper.currentEnvironment + '/' + this.model.id;
}

// Add timestamp
if(mediaSrc.indexOf('?') > -1) {
mediaSrc += '&';
} else {
mediaSrc += '?';
}

mediaSrc += 't=' + Date.now();

return _.div({class: 'editor editor--media'},
_.div({class: 'editor__header'},
Expand Down
10 changes: 6 additions & 4 deletions src/Client/Views/Modals/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Modal extends Crisp.View {
if(this.autoFetch !== false) {
this.fetch();
}

document.body.appendChild(this.element);
}

Expand Down Expand Up @@ -110,8 +110,10 @@ class Modal extends Crisp.View {

return [
_.h4({class: 'modal__title'}, this.title),
_.button({class: 'modal__close fa fa-close'})
.click(() => { this.close(); })
_.if(!this.isBlocking,
_.button({class: 'modal__close fa fa-close'})
.click(() => { this.close(); })
)
];
}

Expand Down Expand Up @@ -145,7 +147,7 @@ class Modal extends Crisp.View {
body
)
),
_.if(footer,
_.if(footer && !this.isBlocking,
_.div({class: 'modal__footer'},
footer
)
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Controllers/PluginController.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PluginController extends Controller {
compiledJs += FileSystem.readFileSync(path, 'utf8');
}

res.set('Content-Type', 'text/javascript');
res.send(compiledJs);
});
}
Expand All @@ -45,6 +46,7 @@ class PluginController extends Controller {
compiledCss += FileSystem.readFileSync(path, 'utf8');
}

res.set('Content-Type', 'text/css');
res.send(compiledCss);
});
}
Expand Down

0 comments on commit 04dd938

Please sign in to comment.