Basic support for Mosaico templates.

TODO:
- Allow choosing a mosaico template in a mosaico-based template
- Integrate the custom mosaico templates with templates (endpoint for retrieving a mosaico template, replacement of URL_BASE and PLACEHOLDER tags
- Implement support for MJML-based Mosaico templates
- Implement support for MJML-based templates
- Implement support for GrapeJS-based templates
This commit is contained in:
Tomas Bures 2018-04-02 19:05:22 +02:00
parent 7b5642e911
commit 6706d93bc1
21 changed files with 2192 additions and 26 deletions

View file

@ -2,7 +2,7 @@
exports.up = (knex, Promise) => (async() => {
await knex.schema.table('custom_fields', table => {
table.json('settings');
table.text('settings');
});
await knex.schema.table('custom_fields', table => {

View file

@ -2,7 +2,7 @@
exports.up = (knex, Promise) => (async() => {
await knex.schema.table('segments', table => {
table.json('settings');
table.text('settings');
});
await knex.schema.table('segments', table => {

View file

@ -5,7 +5,7 @@ exports.up = (knex, Promise) => (async() => {
await knex.schema.createTable(`files_${entityType}`, table => {
table.increments('id').primary();
table.integer('entity').unsigned().notNullable().references('templates.id');
table.integer('entity').unsigned().notNullable().references(`${entityType}s.id`);
table.string('filename');
table.string('originalname');
table.string('mimetype');

View file

@ -1,6 +1,6 @@
exports.up = (knex, Promise) => (async() => {
await knex.schema.table('templates', table => {
table.json('data');
table.text('data', 'longtext');
table.string('type');
});

View file

@ -0,0 +1,61 @@
const mosaicoTemplates = require('../../../shared/mosaico-templates');
exports.up = (knex, Promise) => (async() => {
await knex.schema.createTable('mosaico_templates', table => {
table.increments('id').primary();
table.string('name');
table.text('description');
table.string('type');
table.text('data', 'longtext');
table.timestamp('created').defaultTo(knex.fn.now());
table.integer('namespace').unsigned().references('namespaces.id');
});
await knex.schema.createTable(`shares_mosaico_template`, table => {
table.integer('entity').unsigned().notNullable().references(`mosaico_templates.id`).onDelete('CASCADE');
table.integer('user').unsigned().notNullable().references('users.id').onDelete('CASCADE');
table.string('role', 128).notNullable();
table.boolean('auto').defaultTo(false);
table.primary(['entity', 'user']);
});
await knex.schema.createTable(`permissions_mosaico_template`, table => {
table.integer('entity').unsigned().notNullable().references(`mosaico_templates.id`).onDelete('CASCADE');
table.integer('user').unsigned().notNullable().references('users.id').onDelete('CASCADE');
table.string('operation', 128).notNullable();
table.primary(['entity', 'user', 'operation']);
});
await knex.schema.createTable(`files_mosaico_template`, table => {
table.increments('id').primary();
table.integer('entity').unsigned().notNullable().references('mosaico_templates.id');
table.string('filename');
table.string('originalname');
table.string('mimetype');
table.string('encoding');
table.integer('size');
table.timestamp('created').defaultTo(knex.fn.now());
table.index(['entity', 'originalname'])
});
const versafix = {
name: 'Versafix One',
description: 'Default Mosaico Template',
type: 'html',
namespace: 1,
data: JSON.stringify({
html: mosaicoTemplates.versafix
})
};
await knex('mosaico_templates').insert(versafix);
})();
exports.down = (knex, Promise) => (async() => {
await knex.schema
.dropTable('shares_mosaico_template')
.dropTable('permissions_mosaico_template')
.dropTable('files_mosaico_template')
.dropTable('mosaico_templates')
;
})();