Support for custom block thumbnails in Mosaico templates
This commit is contained in:
parent
7788b0bc67
commit
446d75ce71
5 changed files with 139 additions and 96 deletions
|
@ -1,19 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
function base(text, baseUrl) {
|
||||
if (baseUrl.endsWith('/')) {
|
||||
baseUrl = baseUrl.substring(0, baseUrl.length - 1);
|
||||
// FIXME - process also urlencoded strings - this is for the mosaico/img/template, which passes the file in src parameter
|
||||
|
||||
function base(text, trustedBaseUrl, sandboxBaseUrl) {
|
||||
if (trustedBaseUrl.endsWith('/')) {
|
||||
trustedBaseUrl = trustedBaseUrl.substring(0, trustedBaseUrl.length - 1);
|
||||
}
|
||||
|
||||
return text.split('[URL_BASE]').join(baseUrl);
|
||||
if (sandboxBaseUrl.endsWith('/')) {
|
||||
sandboxBaseUrl = sandboxBaseUrl.substring(0, sandboxBaseUrl.length - 1);
|
||||
}
|
||||
|
||||
return text.split('[URL_BASE]').join(trustedBaseUrl).split('[SANDBOX_URL_BASE]').join(sandboxBaseUrl);
|
||||
}
|
||||
|
||||
function unbase(text, baseUrl) {
|
||||
if (baseUrl.endsWith('/')) {
|
||||
baseUrl = baseUrl.substring(0, baseUrl.length - 1);
|
||||
function unbase(text, trustedBaseUrl, sandboxBaseUrl, treatSandboxAsTrusted = false) {
|
||||
if (trustedBaseUrl.endsWith('/')) {
|
||||
trustedBaseUrl = trustedBaseUrl.substring(0, trustedBaseUrl.length - 1);
|
||||
}
|
||||
|
||||
return text.split(baseUrl).join('[URL_BASE]');
|
||||
if (sandboxBaseUrl.endsWith('/')) {
|
||||
sandboxBaseUrl = sandboxBaseUrl.substring(0, sandboxBaseUrl.length - 1);
|
||||
}
|
||||
|
||||
return text.split(trustedBaseUrl).join('[URL_BASE]').split(sandboxBaseUrl).join(treatSandboxAsTrusted ? '[URL_BASE]' : '[SANDBOX_URL_BASE]');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue