Skip to content

Commit

Permalink
Merge branch 'stable' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeppe Zapp committed Jul 30, 2019
2 parents 5668048 + bd437f6 commit 5da6b7f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
10 changes: 8 additions & 2 deletions src/Client/Helpers/MediaHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ class MediaHelper extends MediaHelperCommon {
}

/**
* Gets the Media Url
* Gets the URL of a media object
*
* @param {String} id
*
* @return {String} URL
*/
static getMediaUrl(id) {
return '/media/' + ProjectHelper.currentProject + '/' + ProjectHelper.currentEnvironment + '/' + id;
checkParam(id, 'id', String, true);

return '/media/' + HashBrown.Context.projectId + '/' + HashBrown.Context.environment + '/' + id;
}

/**
Expand Down
58 changes: 28 additions & 30 deletions src/Client/Views/Editors/FieldEditors/RichTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,34 @@ class RichTextEditor extends HashBrown.Views.Editors.FieldEditors.FieldEditor {
onClickInsertMedia() {
let mediaBrowser = new HashBrown.Views.Modals.MediaBrowser();

mediaBrowser.on('select', (id) => {
HashBrown.Helpers.MediaHelper.getMediaById(id)
.then((media) => {
let html = '';

if(media.url[0] !== '/') { media.url = '/' + media.url; }

if(media.isImage()) {
html = '<img alt="' + media.name + '" src="' + media.url + '">';
} else if(media.isVideo()) {
html = '<video alt="' + media.name + '" src="' + media.url + '">';
}

let activeView = this.activeView || 'wysiwyg';

switch(activeView) {
case 'wysiwyg':
this.wysiwyg.insertHtml(html);
break;

case 'html':
this.html.replaceSelection(html, 'end');
break;

case 'markdown':
this.markdown.replaceSelection(HashBrown.Helpers.MarkdownHelper.toMarkdown(html), 'end');
break;
}
})
.catch(UI.errorModal);
mediaBrowser.on('select', async (id) => {
let media = await HashBrown.Helpers.MediaHelper.getMediaById(id);

if(!media) { return; }

let html = '';

if(media.isImage()) {
html = '<img alt="' + media.name + '" src="/media/' + id + '/' + media.name + '">';
} else if(media.isVideo()) {
html = '<video alt="' + media.name + '" src="/media/' + id + '/' + media.name + '">';
}

let activeView = this.activeView || 'wysiwyg';

switch(activeView) {
case 'wysiwyg':
this.wysiwyg.insertHtml(html);
break;

case 'html':
this.html.replaceSelection(html, 'end');
break;

case 'markdown':
this.markdown.replaceSelection(HashBrown.Helpers.MarkdownHelper.toMarkdown(html), 'end');
break;
}
});
}

Expand Down
3 changes: 0 additions & 3 deletions src/Server/Helpers/DatabaseHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ class DatabaseHelper {

// No value found, return default ones
switch(key) {
<<<<<<< HEAD
=======
case 'protocol':
return 'mongodb';

>>>>>>> v1.2
case 'host':
return 'localhost';

Expand Down

0 comments on commit 5da6b7f

Please sign in to comment.