aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2025-03-15 16:04:24 +0200
committerkaotisk <kaotisk@arching-kaos.org>2025-03-15 16:04:24 +0200
commit38cf355f83bc385bcc619c60f07efd3ae5593748 (patch)
tree3b16145981695f46215152dc0723b6572b8ebadb
parent608f9d74bb6891a62a6acce52931286e5528fa18 (diff)
downloadarching-kaos-web-ui-38cf355f83bc385bcc619c60f07efd3ae5593748.tar.gz
arching-kaos-web-ui-38cf355f83bc385bcc619c60f07efd3ae5593748.tar.bz2
arching-kaos-web-ui-38cf355f83bc385bcc619c60f07efd3ae5593748.zip
And ofc i forgot to include the new files
-rw-r--r--src/js/arching-kaos-modules-markdown.js67
-rw-r--r--src/js/ui/sections/markdownSection.js40
2 files changed, 107 insertions, 0 deletions
diff --git a/src/js/arching-kaos-modules-markdown.js b/src/js/arching-kaos-modules-markdown.js
new file mode 100644
index 0000000..840808c
--- /dev/null
+++ b/src/js/arching-kaos-modules-markdown.js
@@ -0,0 +1,67 @@
+// Arching Kaos Module Markdown
+//
+// Kaotisk Hund - 2024
+//
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
+//
+
+import { makeElement } from "./arching-kaos-generator.js";
+import { archingKaosFetchText } from "./arching-kaos-fetch.js";
+import {
+ getNicknameAssossiatedWithGPG,
+ getFullText,
+ getPreviewText
+} from "./arching-kaos-tools.js";
+import { getIPFSURL } from "./url-generators.js";
+
+export function akModuleMarkdown(zblockIPFSHash, zblockObject, blockObject, json){
+ if (!document.querySelector('#markdown-'+zblockIPFSHash)){
+ var markdownSectionDivElement = document.querySelector('#markdown-section');
+ var articleContainerElement = {
+ element:"article",
+ id:`markdown-${zblockIPFSHash}`,
+ innerHTML: [
+ { element:"a", innerText : json.title, href : '#markdown-'+zblockIPFSHash },
+ { element:"span", innerText : ' '},
+ { element:"a", innerText:'[permalink]', target: '_blank', href:'https://news.arching-kaos.net/?from_zblock='+zblockIPFSHash },
+ { element:"p", innerText:`zblock: ${zblockIPFSHash}` },
+ { element:"p", innerText:"Published: " + new Date(blockObject.timestamp*1000) },
+ { element:"p", innerText:"Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg) },
+ { element:"hr" }
+ ]
+ };
+ makeElement(articleContainerElement, markdownSectionDivElement);
+ if(json.ipfs){
+ archingKaosFetchText(getIPFSURL(json.ipfs), getFullText,[`#markdown-${zblockIPFSHash}`]);
+ }
+ if (document.querySelector("#markdown-sec-not-found")) document.querySelector("#markdown-sec-not-found").hidden=true;
+ makeElement({ element:"hr"}, markdownSectionDivElement);
+ }
+ if (!document.querySelector('#markdown-preview-'+zblockIPFSHash)){
+ var markdownSectionDivElement = document.querySelector('.preview');
+ var button = {
+ element:'button',
+ className:'read-more-button',
+ innerText:`Read more`,
+ onclick: `showResult("${blockObject.action.split('/')[0]}-${zblockIPFSHash}")`
+ }
+ var articleContainerElement = {
+ element:"article",
+ id:`markdown-preview-${zblockIPFSHash}`,
+ innerHTML: [
+ { element:"a", innerText : json.title, href : '#markdown-'+zblockIPFSHash },
+ { element:"span", innerText : ' '},
+ { element:"a", innerText:'[permalink]', target: '_blank', href:'https://news.arching-kaos.net/?from_zblock='+zblockIPFSHash },
+ { element:"p", innerText:"Published: " + new Date(blockObject.timestamp*1000) },
+ { element:"p", innerText:"Contributor: " + getNicknameAssossiatedWithGPG(blockObject.gpg) },
+ { element:"hr" }
+ ]
+ };
+ makeElement(articleContainerElement, markdownSectionDivElement);
+ if(json.ipfs){
+ archingKaosFetchText(getIPFSURL(json.ipfs), getPreviewText, [`#markdown-preview-${zblockIPFSHash}`, button]);
+ }
+ makeElement({ element:"hr"}, markdownSectionDivElement);
+ }
+}
+// @license-end
diff --git a/src/js/ui/sections/markdownSection.js b/src/js/ui/sections/markdownSection.js
new file mode 100644
index 0000000..9a51a32
--- /dev/null
+++ b/src/js/ui/sections/markdownSection.js
@@ -0,0 +1,40 @@
+// Arching Kaos Markdown Section
+//
+// Kaotisk Hund - 2024
+//
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
+//
+
+import { makeElement } from "../../arching-kaos-generator.js";
+
+export function markdownSection()
+{
+ var whereAmI = {
+ element: "div",
+ className: "where-am-i",
+ innerHTML: [
+ { element: "img", src:"./img/logo.png", onclick:"menusel({id:'#/welcome-section'})"},
+ { element: "span", innerText:">"},
+ { element: "h2", innerText:"Modules"},
+ { element: "span", innerText:">"},
+ { element: "h2", innerText:"Markdown"}
+ ]
+ };
+ var content = {
+ element: "div",
+ className: "content",
+ innerHTML: [
+ { element: "em", id:"markdown-sec-not-found", innerText: "No data found (yet?)!"}
+ ]
+ };
+ var markdownSection = {
+ element: 'div',
+ id: 'markdown-section',
+ innerHTML: [
+ whereAmI,
+ content
+ ]
+ };
+ makeElement(markdownSection, document.querySelector('.main'));
+}
+// @license-end