removed dependencies, html/preview
This commit is contained in:
23
server/migrations/20171017055026-remove-document-html.js
Normal file
23
server/migrations/20171017055026-remove-document-html.js
Normal file
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
up: function(queryInterface, Sequelize) {
|
||||
queryInterface.removeColumn('documents', 'html');
|
||||
queryInterface.removeColumn('documents', 'preview');
|
||||
queryInterface.removeColumn('revisions', 'html');
|
||||
queryInterface.removeColumn('revisions', 'preview');
|
||||
},
|
||||
|
||||
down: function(queryInterface, Sequelize) {
|
||||
queryInterface.addColumn('documents', 'html', {
|
||||
type: Sequelize.TEXT,
|
||||
});
|
||||
queryInterface.addColumn('documents', 'preview', {
|
||||
type: Sequelize.TEXT,
|
||||
});
|
||||
queryInterface.addColumn('revisions', 'html', {
|
||||
type: Sequelize.TEXT,
|
||||
});
|
||||
queryInterface.addColumn('revisions', 'preview', {
|
||||
type: Sequelize.TEXT,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -2,12 +2,9 @@
|
||||
import slug from 'slug';
|
||||
import _ from 'lodash';
|
||||
import randomstring from 'randomstring';
|
||||
import emojiRegex from 'emoji-regex';
|
||||
|
||||
import isUUID from 'validator/lib/isUUID';
|
||||
import { DataTypes, sequelize } from '../sequelize';
|
||||
import { convertToMarkdown } from '../../frontend/utils/markdown';
|
||||
import { truncateMarkdown } from '../utils/truncate';
|
||||
import parseTitle from '../../shared/parseTitle';
|
||||
import Revision from './Revision';
|
||||
|
||||
@@ -25,8 +22,6 @@ const createRevision = doc => {
|
||||
return Revision.create({
|
||||
title: doc.title,
|
||||
text: doc.text,
|
||||
html: doc.html,
|
||||
preview: doc.preview,
|
||||
userId: doc.lastModifiedById,
|
||||
documentId: doc.id,
|
||||
});
|
||||
@@ -40,8 +35,6 @@ const beforeSave = async doc => {
|
||||
const { emoji } = parseTitle(doc.text);
|
||||
|
||||
doc.emoji = emoji;
|
||||
doc.html = convertToMarkdown(doc.text);
|
||||
doc.preview = truncateMarkdown(doc.text, 160);
|
||||
doc.revisionCount += 1;
|
||||
|
||||
// Collaborators
|
||||
@@ -74,8 +67,6 @@ const Document = sequelize.define(
|
||||
private: { type: DataTypes.BOOLEAN, defaultValue: true },
|
||||
title: DataTypes.STRING,
|
||||
text: DataTypes.TEXT,
|
||||
html: DataTypes.TEXT,
|
||||
preview: DataTypes.TEXT,
|
||||
revisionCount: { type: DataTypes.INTEGER, defaultValue: 0 },
|
||||
parentDocumentId: DataTypes.UUID,
|
||||
createdById: {
|
||||
|
||||
@@ -9,8 +9,6 @@ const Revision = sequelize.define('revision', {
|
||||
},
|
||||
title: DataTypes.STRING,
|
||||
text: DataTypes.TEXT,
|
||||
html: DataTypes.TEXT,
|
||||
preview: DataTypes.TEXT,
|
||||
|
||||
userId: {
|
||||
type: 'UUID',
|
||||
|
||||
@@ -21,8 +21,6 @@ async function present(ctx: Object, document: Document, options: ?Options) {
|
||||
private: document.private,
|
||||
title: document.title,
|
||||
text: document.text,
|
||||
html: document.html,
|
||||
preview: document.preview,
|
||||
emoji: document.emoji,
|
||||
createdAt: document.createdAt,
|
||||
createdBy: presentUser(ctx, document.createdBy),
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import truncate from 'truncate-html';
|
||||
import { convertToMarkdown } from '../../frontend/utils/markdown';
|
||||
|
||||
truncate.defaultOptions = {
|
||||
stripTags: false,
|
||||
ellipsis: '...',
|
||||
decodeEntities: false,
|
||||
excludes: ['h1', 'pre'],
|
||||
};
|
||||
|
||||
const truncateMarkdown = (text, length) => {
|
||||
const html = convertToMarkdown(text);
|
||||
return truncate(html, length);
|
||||
};
|
||||
|
||||
export { truncateMarkdown };
|
||||
Reference in New Issue
Block a user