diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-11-29 16:23:39 +0200 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-11-29 16:23:39 +0200 |
commit | afcedd44615d20423d58f4d9c9d8cfa3838a54d4 (patch) | |
tree | e16cd7f2eb4040f7b237baa45aa3f8f80516dcc4 /src/js/arching-kaos-modules-news.js | |
parent | 084e3ce6efc49c2d43ce9b44d96e430f8057848e (diff) | |
download | arching-kaos-web-ui-afcedd44615d20423d58f4d9c9d8cfa3838a54d4.tar.gz arching-kaos-web-ui-afcedd44615d20423d58f4d9c9d8cfa3838a54d4.tar.bz2 arching-kaos-web-ui-afcedd44615d20423d58f4d9c9d8cfa3838a54d4.zip |
Major refactoring
Diffstat (limited to 'src/js/arching-kaos-modules-news.js')
-rw-r--r-- | src/js/arching-kaos-modules-news.js | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/js/arching-kaos-modules-news.js b/src/js/arching-kaos-modules-news.js index d1ebc23..49dfb0a 100644 --- a/src/js/arching-kaos-modules-news.js +++ b/src/js/arching-kaos-modules-news.js @@ -5,8 +5,16 @@ * @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"; -function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){ +export function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){ if (!document.querySelector('#news-'+zblockIPFSHash)){ var newsSectionDivElement = document.querySelector('#news-section'); var articleContainerElement = { @@ -14,7 +22,9 @@ function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){ id:`news-${zblockIPFSHash}`, innerHTML: [ { element:"a", innerText : json.title, href : '#news-'+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" } @@ -24,15 +34,28 @@ function akModuleNews(zblockIPFSHash, zblockObject, blockObject, json){ if(json.ipfs){ archingKaosFetchText(getIPFSURL(json.ipfs), getFullText,[`#news-${zblockIPFSHash}`]); } + if (document.querySelector("#news-sec-not-found")) document.querySelector("#news-sec-not-found").hidden=true; + makeElement({ element:"hr"}, newsSectionDivElement); + } + if (!document.querySelector('#news-preview-'+zblockIPFSHash)){ + var newsSectionDivElement = document.querySelector('.preview'); + var articleContainerElement = { + element:"article", + id:`news-preview-${zblockIPFSHash}`, + innerHTML: [ + { element:"a", innerText : json.title, href : '#news-'+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(small, articleContainerElement); - var hr = { element:"hr" }; - makeElement(hr, articleContainerElement); + makeElement(articleContainerElement, newsSectionDivElement); if(json.ipfs){ - getipfstext(json.ipfs,articleContainerElement.id); + archingKaosFetchText(getIPFSURL(json.ipfs), getPreviewText, [`#news-preview-${zblockIPFSHash}`]); } - if (document.querySelector("#news-sec-not-found")) document.querySelector("#news-sec-not-found").hidden=true; - makeElement(hr, newsSectionDivElement); + makeElement({ element:"hr"}, newsSectionDivElement); } } // @license-end |