A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: update export templates
Abdullah Atta222fc00bd72a
diff --git a/packages/core/utils/templates/helper.js b/packages/core/utils/templates/helper.jsdeleted file mode 100644index 459ee4d2b..000000000--- a/packages/core/utils/templates/helper.js+++ /dev/null@@ -1,57 +0,0 @@-/*-This file is part of the Notesnook project (https://notesnook.com/)--Copyright (C) 2022 Streetwriters (Private) Limited--This program is free software: you can redistribute it and/or modify-it under the terms of the GNU General Public License as published by-the Free Software Foundation, either version 3 of the License, or-(at your option) any later version.--This program is distributed in the hope that it will be useful,-but WITHOUT ANY WARRANTY; without even the implied warranty of-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-GNU General Public License for more details.--You should have received a copy of the GNU General Public License-along with this program. If not, see <http://www.gnu.org/licenses/>.-*/--import { formatDate } from "../date";--function generateMetaTags(metadata, createMetaTag) {- let metaTags = [];- for (let key in metadata) {- let value = metadata[key];- if (typeof value === "object" && !Array.isArray(value)) continue;- else if (Array.isArray(value)) value = value.join(", ");-- // we must have no new line characters- if (typeof value === "string") value = value.replace(/\r?\n|\r/g, "");-- metaTags.push(createMetaTag(key, value));- }- return metaTags;-}--export function buildPage(- template,- createMetaTag,- { metadata, title, headline, content, createdOn, editedOn, tags }-) {- let page = template;-- if (createMetaTag)- page = page.replace(- /{{metaTags}}/g,- generateMetaTags(metadata, createMetaTag).join("\n")- );-- page = page.replace(/{{title}}/g, title);- page = page.replace(/{{headline}}/g, headline);- page = page.replace(/{{content}}/g, content);- page = page.replace(/{{createdOn}}/g, formatDate(createdOn));- page = page.replace(/{{editedOn}}/g, formatDate(editedOn));- page = page.replace(/{{tags}}/g, tags);- return page;-}diff --git a/packages/core/utils/templates/html/builder.js b/packages/core/utils/templates/html/builder.jsindex 1636a0998..a3a5b6406 100644--- a/packages/core/utils/templates/html/builder.js+++ b/packages/core/utils/templates/html/builder.js@@ -17,15 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { buildPage } from "../helper";import HTMLTemplate from "./template";-function createMetaTag(name, content) {- return `<meta name="nn-${name}" content="${content}">`;-}-function buildHTML(templateData) {- return buildPage(HTMLTemplate, createMetaTag, templateData);+ return HTMLTemplate(templateData);}export default { buildHTML };diff --git a/packages/core/utils/templates/html/template.js b/packages/core/utils/templates/html/template.jsindex b7a9ca0e9..164a68d86 100644--- a/packages/core/utils/templates/html/template.js+++ b/packages/core/utils/templates/html/template.js@@ -17,23 +17,23 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-const template = `<!DOCTYPE html>+const template = (data) => `<!DOCTYPE html><html lang="en-US"><head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /><metaname="description"- content="{{headline}}"+ content="${data.headline}"/>- <title>{{title}} - Notesnook</title>- <meta name="created-on" content="{{createdOn}}" />- <meta name="last-edited-on" content="{{editedOn}}" />- <meta name="tags" content="{{tags}}" />+ <title>${data.title} - Notesnook</title>+ <meta name="created-on" content="${data.createdOn}" />+ <meta name="last-edited-on" content="${data.editedOn}" />+ ${data.tags ? `<meta name="tags" content="${data.tags}" />` : ""}</head><body>- <h1>{{title}}</h1>- {{content}}+ <h1>${data.title}</h1>+ ${data.content}</body></html>`;diff --git a/packages/core/utils/templates/markdown/builder.js b/packages/core/utils/templates/markdown/builder.jsindex c62455169..d10888db0 100644--- a/packages/core/utils/templates/markdown/builder.js+++ b/packages/core/utils/templates/markdown/builder.js@@ -17,16 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { buildPage } from "../helper";import MDTemplate from "./template";-function createMetaTag(name, content) {- if (!content || content.length <= 0) return "";- return `[nn-${name}]:- "${content}"`;-}-function buildMarkdown(templateData) {- return buildPage(MDTemplate, createMetaTag, templateData);+ return MDTemplate(templateData);}export default { buildMarkdown };diff --git a/packages/core/utils/templates/markdown/template.js b/packages/core/utils/templates/markdown/template.jsindex d56ff1843..ee40f75ab 100644--- a/packages/core/utils/templates/markdown/template.js+++ b/packages/core/utils/templates/markdown/template.js@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-const template = `# {{title}}+const template = (data) => `# ${data.title}-{{content}}+${data.content}----_Tags: {{tags}}_`;+${data.tags ? `${data.tags}` : ""}`;export default template;diff --git a/packages/core/utils/templates/text/builder.js b/packages/core/utils/templates/text/builder.jsindex e31598870..e61ed30f6 100644--- a/packages/core/utils/templates/text/builder.js+++ b/packages/core/utils/templates/text/builder.js@@ -17,11 +17,10 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { buildPage } from "../helper";import TextTemplate from "./template";function buildText(templateData) {- return buildPage(TextTemplate, undefined, templateData);+ return TextTemplate(templateData);}export default { buildText };diff --git a/packages/core/utils/templates/text/template.js b/packages/core/utils/templates/text/template.jsindex 0f09a23d5..7b4be4923 100644--- a/packages/core/utils/templates/text/template.js+++ b/packages/core/utils/templates/text/template.js@@ -17,12 +17,12 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-const template = `{{title}}+const template = (data) => `${data.title}-----------{{content}}+${data.content}-----------Tags: {{tags}}`;+Tags: ${data.tags}`;export default template;