Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
atherdon committed Sep 6, 2021
1 parent 492c106 commit 8b0676b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 171 deletions.
103 changes: 0 additions & 103 deletions src/_depricated-helpers.js

This file was deleted.

34 changes: 0 additions & 34 deletions src/command-line-methods.js

This file was deleted.

22 changes: 22 additions & 0 deletions src/html/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @TODO both layouts things can be moved out from importing it here.
const {
// TODO: finish and fix this thing. it was done by Serge quickly,
// and ruined a lot of our logic
fullTemplate,

fullTemplateOLD
} = require('atherdon-newsletter-js-layouts');



const MESSAGE_HTML_CONTENT_ONLY = 'The content has been parsed successfully';
const MESSAGE_HTML_FULL_TEMPLATE = 'The full-template has been parsed successfully';
const MESSAGE_HTML_FULL_TEMPLATE2 = 'The full-template has been parsed successfully2';

module.exports = {

MESSAGE_HTML_CONTENT_ONLY,
MESSAGE_HTML_FULL_TEMPLATE,
MESSAGE_HTML_FULL_TEMPLATE2

}
20 changes: 19 additions & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ const {
printMessage
} = require('markup-generator');

const { writeReactComponent } = require('./react/methods');

const {
writeReactComponent,

generateTemplateName,

FULL_SOURCE,
CONTENT_SOURCE,
} = require('./utils');


const {
MESSAGE_HTML_CONTENT_ONLY,
MESSAGE_HTML_FULL_TEMPLATE,
Expand All @@ -34,6 +37,7 @@ const {
MESSAGE_REACT_CONTENT
} = require('./command-line-methods');


const {
parse,
parseFullTHing,
Expand Down Expand Up @@ -67,6 +71,8 @@ switch (process.env.PARSE) {
break;
}



function generateFullTemplate2() {
const { content, warnings, previewText } = parseFullTHing({ source: FULL_SOURCE });

Expand All @@ -91,6 +97,9 @@ function generateFullTemplate2() {
printMessage(message, 'green2');
}




function generateFullTemplate() {
// same as from top

Expand All @@ -104,6 +113,9 @@ function generateFullTemplate() {
printMessage(message, 'green2');
}




function generateReactContent() {
const { content, warnings } = parseMDReact(CONTENT_SOURCE);
// console.log("parsedContent", { content, warnings, previewText });
Expand All @@ -119,6 +131,8 @@ function generateReactContent() {
printMessage(message, 'green2');
}



function generateReactFullTemplate() {
const { content, warnings, previewText } = parseMDReactFullThing({ source: FULL_SOURCE });

Expand All @@ -135,6 +149,8 @@ function generateReactFullTemplate() {
printMessage(message, 'green2');
}



// this method is depricated.
// we will remove export of it at some point.
function generateContentOnly() {
Expand All @@ -152,6 +168,8 @@ function generateContentOnly() {
printMessage(message, 'green2');
}



module.exports = {
generateContentOnly,
generateFullTemplate,
Expand Down
24 changes: 24 additions & 0 deletions src/react/methods.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { write } = require('markup-generator');
const reactLayouts = require('atherdon-newsletter-react');

const reactComponent = `
import React from "react";
Expand All @@ -23,3 +24,26 @@ function writeReactComponent(fileName, content, dir = 'generated', message) {
const result = reactComponentReplace(content);
write(fileName, result, dir, message);
}


// const {
// parse,
// parseFullTHing,
// } = require('./html/parseHTML');


const MESSAGE_REACT_FULL_TEMPLATE = 'The FullTemplate has been parsed successfully';
const MESSAGE_REACT_CONTENT = 'The Content has been parsed successfully';

// module.exports = {

// MESSAGE_REACT_FULL_TEMPLATE,
// MESSAGE_REACT_CONTENT,
// };


module.exports = {
reactComponent,
reactComponentReplace,
writeReactComponent
};
33 changes: 0 additions & 33 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
const fs = require('fs');
const { write } = require('markup-generator');


const reactComponent = `
import React from "react";
const Content = () => {
return (
<>
{content}
</>
);
};
export default Content;
`;

function reactComponentReplace(content){
return reactComponent.replace(/{content}/g, content);
}

function writeReactComponent(fileName, content, dir = 'generated', message) {

const result = reactComponentReplace(content);
write(fileName, result, dir, message);
}



const generateTemplateName = (suffix, ext = 'html') => `${suffix}-${Date.now()}.${ext}`;


// @TODO add path, in order to make it work PERFECTLY
const FULL_SOURCE = 'source/source.md';

Expand All @@ -39,8 +8,6 @@ const CONTENT_SOURCE = 'source/source.md';

module.exports = {

writeReactComponent,

FULL_SOURCE,
CONTENT_SOURCE,
generateTemplateName,
Expand Down

0 comments on commit 8b0676b

Please sign in to comment.