nodoku-core 0.2.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,6 +23,12 @@
23
23
  * [Schema for Nodoku skin Yaml file](#schema-for-nodoku-skin-yaml-file)
24
24
  * [Customizing Nodoku page appearance](#customizing-nodoku-page-appearance)
25
25
  * [Nodoku generation scripts](#nodoku-generation-scripts)
26
+ * [Nodoku license](#nodoku-license)
27
+ * [Use for private, educational or commercial needs, excluding applications for webpage or website building tools](#use-for-private-educational-or-commercial-needs-excluding-applications-for-webpage-or-website-building-tools)
28
+ * [Use as part of website or webpage builders](#use-as-part-of-website-or-webpage-builders)
29
+ * [Examples](#examples)
30
+ * [Proper use, free of charge, under the MIT License](#proper-use-free-of-charge-under-the-mit-license)
31
+ * [Prohibited use](#prohibited-use)
26
32
  <!-- TOC -->
27
33
 
28
34
  GitHub link: https://github.com/nodoku/nodoku-core
@@ -901,3 +907,54 @@ To simplify the use of these script it is recommended to add them in the project
901
907
  }
902
908
  ```
903
909
 
910
+
911
+ # Nodoku license
912
+
913
+ The Nodoku License to be used depends on the use case you plan to use Nodoku for:
914
+
915
+ - using Nodoku to build an End Product, which is a webpage or a website for private or commercial use
916
+ - in short, in this case Nodoku **_is free_** to use under the MIT License (see below for more details)
917
+ - using Nodoku to build an End Product, which is a webpage or a website builder (online or offline)
918
+ - in short, in this case the use of Nodoku **_is prohibited_**
919
+
920
+
921
+ Note, that
922
+ > in any case of the allowed, free-of-charge use of Nodoku, **_the present Nodoku license should be included in all copies of the Software, using Nodoku_**.
923
+
924
+
925
+
926
+ ## Use for private, educational or commercial needs, excluding applications for webpage or website building tools
927
+
928
+ Any use of Nodoku, **_except for webpage and website builder applications_**, is allowed free of charge, under the **_MIT license_** ( see the [LICENSE](./blob/main/LICENSE) )
929
+
930
+
931
+
932
+ ## Use as part of website or webpage builders
933
+
934
+ The use of Nodoku for the purposes to provide a solution for online (or offline) website or webpage builders is **_prohibited_**.
935
+
936
+ This prohibition includes the direct or indirect use of the Nodoku library as part of webpage builder solution.
937
+
938
+ Indirect use of Nodoku library would include building a software or a framework that would then be used as part of webpage or website builder.
939
+
940
+ Webpage or Website builder application is any tool, online or offline, that would allow the End User to build a publishable webpage or website, using no code or low amount of code.
941
+
942
+ This is prohibited under this license term since that would constitute a direct competition to Nodoku lo-code site builder.
943
+
944
+ # Examples
945
+
946
+ ## Proper use, free of charge, under the MIT License
947
+
948
+ - building a webpage or a website for a private non-commercial project
949
+ - building a webpage or a website for a private commercial project
950
+ - building a webpage or a website for a public commercial or non-commercial blog
951
+ - building a webpage or a website for a client, that would use it for commercial or non-commercial purposes
952
+ - creating and distributing non-commercially (free of charge) custom Nodoku components
953
+ - creating and distributing commercially custom Nodoku components (developing and selling out new Nodoku-compatible UI components)
954
+ - developing new UI components and selling them out either as a Nodoku component, or a standalone component, or a component compatible with another website builder
955
+
956
+ ## Prohibited use
957
+
958
+ - building a website builder, that would use the Nodoku engine to provide the End User with a tool, that would allow them building their own webpages or websites
959
+ - using Nodoku engine to provide the End User with an automatic, semi-automatic or manual framework, that would allow them building their own webpages or websites
960
+ - using Nodoku libraries to use it as part of the solution that would allow the End User to build a webpage or a website
@@ -41,14 +41,6 @@ export class NdCode {
41
41
  this.code = code;
42
42
  }
43
43
  }
44
- export class NdLink {
45
- urlText;
46
- url;
47
- constructor(text, url) {
48
- this.urlText = text;
49
- this.url = url;
50
- }
51
- }
52
44
  export class NdContentBlock {
53
45
  id;
54
46
  lng;
@@ -1,5 +1,4 @@
1
1
  import { NdCode, NdTranslatableText } from "../content/nd-content";
2
- import { NdLink } from "../content/nd-content";
3
2
  export async function DummyComp(props) {
4
3
  // console.log("content dummy comp", props.theme)
5
4
  const { content, i18nextTrustedHtmlProvider, lng, rowIndex, componentIndex } = props;
@@ -75,18 +74,20 @@ async function render(rowIndex, componentIndex, block, t) {
75
74
  <code lang={code.lang} className={"hljs"} dangerouslySetInnerHTML={{ __html: code.code }}/>
76
75
  </pre>
77
76
  </div>);
78
- }
79
- else if (p instanceof NdLink) {
80
- const link = p;
81
- return (<div>
82
- link
83
- <div key={ip} className={"mb-3 font-normal text-gray-700 dark:text-gray-400"}>
84
- urlText: {link.urlText && showTranslatableText(link.urlText)}
85
- url: {showTranslatableText(link.url)}
86
- </div>
87
-
88
- </div>);
89
- }
77
+ } /*else if (p instanceof NdLink) {
78
+ const link: NdLink = p as NdLink
79
+ return (
80
+ <div>
81
+ link
82
+ <div key={ip} className={"mb-3 font-normal text-gray-700 dark:text-gray-400"}>
83
+ urlText: {link.urlText && showTranslatableText(link.urlText)}
84
+ url: {showTranslatableText(link.url)}
85
+ </div>
86
+
87
+ </div>
88
+
89
+ )
90
+ } */
90
91
  else {
91
92
  const list = p;
92
93
  if (list.ordered) {
@@ -112,7 +113,8 @@ function showTranslatableText(text) {
112
113
  return <span>{text.text} <small>(<i>{text.key}</i>)</small></span>;
113
114
  }
114
115
  function showListItem(i) {
115
- return i.text instanceof NdTranslatableText ?
116
- showTranslatableText(i.text) :
117
- <span>link item {(i.text.urlText ? showTranslatableText(i.text.urlText) : "link text n/a")} : {showTranslatableText(i.text.url)}</span>;
116
+ // return i.text instanceof NdTranslatableText ?
117
+ // showTranslatableText(i.text) :
118
+ // <span>link item {(i.text.urlText ? showTranslatableText(i.text.urlText) : "link text n/a")} : {showTranslatableText(i.text.url)}</span>;
119
+ return showTranslatableText(i.text);
118
120
  }
package/esm/index.js CHANGED
@@ -1,10 +1,12 @@
1
- import { NdContentImage, NdTranslatableText, NdList, NdLink, NdCode, NdCallToAction, NdContentBlock } from "./content/nd-content";
1
+ import { NdContentImage, NdTranslatableText, NdList, NdCode, NdCallToAction, NdContentBlock } from "./content/nd-content";
2
2
  import { NdSkinComponent, NdRow, NdPageSkin, NdSkinComponentProps, NdContentSelector, NdComponentDefinition, NdThemeHierarchy } from "./skin/nd-skin";
3
3
  import { RenderingPageProps, RenderingPriority } from "./core/rendering-page-props";
4
4
  import { RenderingPage } from "./core/rendering-page";
5
5
  import { mergeTheme } from "./theme-utils/theme-merger";
6
6
  import { defaultRowThemeImpl } from "./theme-utils/row-style";
7
- export { NdContentImage, NdTranslatableText, NdList, NdLink, NdCode, NdCallToAction, NdContentBlock, NdSkinComponent, NdRow, NdPageSkin, NdSkinComponentProps, NdContentSelector, NdComponentDefinition, NdThemeHierarchy };
7
+ export { NdContentImage, NdTranslatableText, NdList,
8
+ // NdLink,
9
+ NdCode, NdCallToAction, NdContentBlock, NdSkinComponent, NdRow, NdPageSkin, NdSkinComponentProps, NdContentSelector, NdComponentDefinition, NdThemeHierarchy };
8
10
  export { RenderingPageProps, RenderingPriority, RenderingPage };
9
11
  export { mergeTheme };
10
12
  export { DummyComp } from "./core/dummy-comp";
@@ -3,7 +3,6 @@ import { Marked } from '@ts-stack/markdown';
3
3
  import { parse, TextNode } from 'node-html-parser';
4
4
  import yaml from "js-yaml";
5
5
  import { NdCallToAction } from "../../content/nd-content";
6
- import { NdLink } from "../../content/nd-content";
7
6
  const nsRegex = /.*\/(.*)\.md/;
8
7
  export async function contentMarkdownProvider(mdFileUrl, contentLng, ns = undefined) {
9
8
  return await fetch(mdFileUrl)
@@ -224,7 +223,12 @@ class BlockHolder {
224
223
  img = new NdContentImage();
225
224
  img.url = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.url`, imgHtmlElem.attributes["src"], true);
226
225
  img.alt = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.alt`, imgHtmlElem.attributes["alt"]);
227
- img.title = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.title`, imgHtmlElem.attributes["title"]);
226
+ if (imgHtmlElem.attributes["title"] && imgHtmlElem.attributes["title"].length > 0) {
227
+ img.title = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.title`, imgHtmlElem.attributes["title"]);
228
+ }
229
+ else {
230
+ img.title = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.title`, imgHtmlElem.attributes["alt"]);
231
+ }
228
232
  }
229
233
  });
230
234
  if (img) {
@@ -243,7 +247,12 @@ class BlockHolder {
243
247
  img = new NdContentImage();
244
248
  img.url = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.url`, htmlElem.attributes["src"], true);
245
249
  img.alt = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.alt`, htmlElem.attributes["alt"]);
246
- img.title = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.title`, htmlElem.attributes["title"]);
250
+ if (htmlElem.attributes["title"] && htmlElem.attributes["title"].length > 0) {
251
+ img.title = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.title`, htmlElem.attributes["title"]);
252
+ }
253
+ else {
254
+ img.title = new NdTranslatableText(this.ns, `${blockId}.images.${imi}.title`, htmlElem.attributes["alt"]);
255
+ }
247
256
  }
248
257
  if (img) {
249
258
  newBlock.images.push(img);
@@ -290,20 +299,22 @@ class BlockHolder {
290
299
  if (!cn) {
291
300
  return undefined;
292
301
  }
293
- if (cn instanceof TextNode) {
302
+ if (cn instanceof TextNode && cn.text.length > 0) {
294
303
  return new NdTranslatableText(this.ns, `${idPrefix}`, cn.text);
295
304
  }
296
305
  const p = cn;
297
306
  if (!p.rawTagName) {
298
307
  return undefined;
299
308
  }
300
- // console.log("parsing paragraph", p.innerHTML);
309
+ // console.log("parsing paragraph", p.rawTagName, p.innerHTML);
301
310
  if (p.rawTagName === "p" || p.rawTagName === "blockquote") {
302
311
  return new NdTranslatableText(this.ns, `${idPrefix}`, p.innerHTML);
303
- }
304
- else if (p.rawTagName === "a") {
305
- return new NdLink(new NdTranslatableText(this.ns, `${idPrefix}.urlText`, p.innerHTML), new NdTranslatableText(this.ns, `${idPrefix}.url`, p.attributes["href"], true));
306
- }
312
+ } /*else if (p.rawTagName === "a") {
313
+ return new NdLink(
314
+ new NdTranslatableText(this.ns, `${idPrefix}.urlText`, p.innerHTML),
315
+ new NdTranslatableText(this.ns, `${idPrefix}.url`, p.attributes["href"], true)
316
+ );
317
+ } */
307
318
  else if (p.rawTagName === "pre") {
308
319
  const codeHtml = p.childNodes[0];
309
320
  const rawText = codeHtml.text;
@@ -320,19 +331,32 @@ class BlockHolder {
320
331
  }
321
332
  else if (p.rawTagName === "ul") {
322
333
  return NdList.createUnOrdered(this.parseListItems(idPrefix, p));
323
- } /*else {
324
- return new NdTranslatableText(this.ns, `${idPrefix}`, p.innerHTML);
325
- }*/
326
- console.log("couldn't parse paragraph: ", p.innerHTML);
327
- return undefined;
334
+ }
335
+ else {
336
+ // const pItems: NdTranslatableText[] = []
337
+ // pItems.push(new NdTranslatableText(this.ns, idPrefix, p.innerHTML))
338
+ // p.childNodes
339
+ // .filter(cn => cn.textContent.length > 0)
340
+ // .forEach(cn => pItems.push(new NdTranslatableText(this.ns, idPrefix, cn.rawText)))
341
+ // console.log("reducing inner nodes of paragraph", pItems)
342
+ // return pItems.reduce((prev, current) => new NdTranslatableText(this.ns, prev.key, prev.text + "\n" + current.text) )
343
+ return new NdTranslatableText(this.ns, idPrefix, p.toString());
344
+ }
345
+ // console.log("couldn't parse paragraph: ", p.innerHTML)
346
+ //
347
+ // return undefined;
328
348
  }
329
349
  parseListItems(idPrefix, p) {
350
+ // console.log("parsing list items ", p)
330
351
  return p.childNodes
331
352
  .filter(lin => lin.innerText && lin.innerText.trim().length > 0)
332
353
  .map((lin, k) => {
333
354
  const li = lin;
334
355
  let innerList = undefined;
335
- let liText; //TextNode | undefined;
356
+ let liText = []; // /*| NdLink*/ | undefined;//TextNode | undefined;
357
+ if (li.innerHTML && li.innerHTML.length > 0) {
358
+ liText?.push(new NdTranslatableText(this.ns, `${idPrefix}.items.${k}`, li.innerHTML));
359
+ }
336
360
  if (li.childNodes.length > 0) {
337
361
  // console.log("found inner item", li.childNodes.length, (li.childNodes.map(i => i as HTMLElement)
338
362
  // .map((i1: HTMLElement) => i1.rawTagName ? i1.rawTagName : "N.A")), "<<<");
@@ -343,17 +367,22 @@ class BlockHolder {
343
367
  .find((p) => p != undefined && p instanceof NdList);
344
368
  liText = li.childNodes
345
369
  .map(cn => this.parseParagraph(`${idPrefix}.items.${k}.text`, cn))
346
- .find((p) => p != undefined && (p instanceof NdLink || p instanceof NdTranslatableText));
370
+ .filter((p) => p != undefined && ( /*p instanceof NdLink || */p instanceof NdTranslatableText));
347
371
  // innerList = innerNodes.find((p: NdParagraph | undefined) => p != undefined && p instanceof NdList)
348
372
  // if (li.childNodes[0].rawTagName in ["ol", "ul"]) {
349
373
  // }
350
374
  // liText = li.childNodes.filter(cn => cn instanceof TextNode).find(t => t && t.text.length > 0);
351
375
  // liText = innerNodes.find((p: NdParagraph | undefined) => p != undefined && (p instanceof NdLink || p instanceof NdTranslatableText))
352
376
  }
377
+ let itemText = new NdTranslatableText(this.ns, `${idPrefix}.items.${k}`, "n/a");
378
+ if (liText.length > 0) {
379
+ // console.log("reducing inner item", liText)
380
+ itemText = liText.reduce((prev, current) => new NdTranslatableText(this.ns, prev.key, prev.text + "\n" + current.text));
381
+ }
353
382
  // type l = keyof HTMLElement
354
383
  // console.log("found list", li.childNodes.filter(cn => Object.keys(cn).map(k => k == "parentNode" ? "parent" : (cn as HTMLElement)[k as l])), "<<", lin.innerText, "<<")
355
384
  // const foundList = {text: new NdTranslatableText(this.ns, `${idPrefix}.items.${k}`, liText)/*liText*/, subList: innerList};
356
- const foundList = { text: liText ? liText : new NdTranslatableText(this.ns, `${idPrefix}.items.${k}`, "n/a"), subList: innerList };
385
+ const foundList = { text: itemText, subList: innerList };
357
386
  // console.log("found list", ">>", foundList, "<<")
358
387
  return foundList;
359
388
  // const listItem = this.parseParagraph(`${idPrefix}.items.${k}`, li)
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "nodoku-core",
3
- "version": "0.2.6",
3
+ "version": "0.3.0",
4
4
  "description": "basic foundation for nodoku static site generator",
5
+ "license": "MIT for the use not related to website builders, commercial otherwise, contact for details",
5
6
  "exports": {
6
7
  ".": {
7
8
  "types": "./types/index.d.ts",
@@ -16,7 +16,7 @@ export declare class NdTranslatableText {
16
16
  constructor(ns: string, key?: string, text?: string, excludeFromTranslation?: boolean);
17
17
  }
18
18
  export type NdListItem = {
19
- text: NdTranslatableText | NdLink;
19
+ text: NdTranslatableText;
20
20
  subList: NdParagraph | undefined;
21
21
  };
22
22
  export declare class NdList {
@@ -31,12 +31,7 @@ export declare class NdCode {
31
31
  code: string;
32
32
  constructor(lang: string, code: string);
33
33
  }
34
- export declare class NdLink {
35
- urlText: NdTranslatableText | undefined;
36
- url: NdTranslatableText;
37
- constructor(text: NdTranslatableText, url: NdTranslatableText);
38
- }
39
- export type NdParagraph = NdTranslatableText | NdList | NdCode | NdLink;
34
+ export type NdParagraph = NdTranslatableText | NdList | NdCode;
40
35
  export declare class NdContentBlock {
41
36
  id: string;
42
37
  lng: string;
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NdContentImage, NdTranslatableText, NdList, NdLink, NdListItem, NdCode, NdCallToAction, NdParagraph, NdContentBlock } from "./content/nd-content";
1
+ import { NdContentImage, NdTranslatableText, NdList, /*NdLink, */ NdListItem, NdCode, NdCallToAction, NdParagraph, NdContentBlock } from "./content/nd-content";
2
2
  import { NdSkinComponent, NdRow, NdPageSkin, NdSkinComponentProps, NdContentSelector, NdComponentDefinition, NdThemeHierarchy, NdDefaultThemeName } from "./skin/nd-skin";
3
3
  import { RenderingPageProps, RenderingPriority } from "./core/rendering-page-props";
4
4
  import { RenderingPage } from "./core/rendering-page";
@@ -8,7 +8,7 @@ import { ThemeStyle } from "./theme-utils/theme-style";
8
8
  import { ExtendedThemeStyle } from "./theme-utils/extended-theme-style";
9
9
  import { ImageStyle } from "./theme-utils/image-style";
10
10
  import { RowStyle } from "./theme-utils/row-style";
11
- export { NdContentImage, NdTranslatableText, NdList, type NdListItem, NdLink, NdCode, NdCallToAction, NdContentBlock, NdSkinComponent, NdRow, NdPageSkin, NdSkinComponentProps, NdContentSelector, NdComponentDefinition, NdThemeHierarchy, type NdParagraph, type NdDefaultThemeName, type NdImageProps, type NdI18nextTrustedHtmlProvider, type NdHtmlSanitizer, type NdTrustedHtml, type NdI18NextPostProcessor };
11
+ export { NdContentImage, NdTranslatableText, NdList, type NdListItem, NdCode, NdCallToAction, NdContentBlock, NdSkinComponent, NdRow, NdPageSkin, NdSkinComponentProps, NdContentSelector, NdComponentDefinition, NdThemeHierarchy, type NdParagraph, type NdDefaultThemeName, type NdImageProps, type NdI18nextTrustedHtmlProvider, type NdHtmlSanitizer, type NdTrustedHtml, type NdI18NextPostProcessor };
12
12
  export { RenderingPageProps, RenderingPriority, RenderingPage };
13
13
  export { mergeTheme, type ThemeStyle, type ExtendedThemeStyle, type ImageStyle };
14
14
  export type { NdI18nextProvider, AsyncFunctionComponent, NdImageProvider };