diff --git a/src/frontend/components/nomadnetwork/NomadNetworkPage.vue b/src/frontend/components/nomadnetwork/NomadNetworkPage.vue index 9f4feeb..43ced77 100644 --- a/src/frontend/components/nomadnetwork/NomadNetworkPage.vue +++ b/src/frontend/components/nomadnetwork/NomadNetworkPage.vue @@ -43,6 +43,11 @@ + + + + + @@ -69,7 +74,7 @@ Loading {{ nodePageProgress }}% - + @@ -385,6 +390,7 @@ export default { // if page is cache, we can just return it now if(cachedNodePageContent != null){ this.nodePageContent = cachedNodePageContent; + this.renderPageContent(pagePath, cachedNodePageContent); this.isLoadingNodePage = false; return; } @@ -393,31 +399,21 @@ export default { this.downloadNomadNetPage(destinationHash, pagePath, fieldData, (pageContent) => { - const muParser = new MicronParser(); - // do nothing if callback is for a previous request if(seq !== this.nodePageRequestSequence){ console.log("ignoring page content callback for previous page request") return; } - // check if page url ends with .mu but remove page data first - // address:/page/index.mu`Data=123 - const [ pagePathWithoutData, pageData ] = pagePath.split("`"); - - // convert micron to html if page ends with .mu extension - // otherwise, we will just serve the content as is - if(pagePathWithoutData.endsWith(".mu")){ - this.nodePageContent = muParser.convertMicronToHtml(pageContent); - } else { - this.nodePageContent = pageContent; - } + // update page content + this.nodePageContent = pageContent; // update cache const nodePagePathCacheKey = `${destinationHash}:${pagePath}`; this.nodePageCache[nodePagePathCacheKey] = this.nodePageContent; // update page content + this.renderPageContent(pagePath, pageContent); this.isLoadingNodePage = false; // update node path @@ -451,6 +447,39 @@ export default { }); }, + renderPageContent(path, content) { + + // check if page url ends with .mu but remove page data first + // address:/page/index.mu`Data=123 + const [ pagePathWithoutData ] = path.split("`"); + + // convert micron to html if page ends with .mu extension + if(pagePathWithoutData.endsWith(".mu")){ + const muParser = new MicronParser(); + return muParser.convertMicronToHtml(content); + } + + // otherwise, we will just serve the content as is + return content; + + }, + showNodePageSource() { + + // create blob containing page content + const blob = new Blob([this.nodePageContent], { + type: "text/plain", + }); + + // create object url for blob + const objectUrl = URL.createObjectURL(blob); + + // open blob in new tab + window.open(objectUrl, "_blank"); + + // revoke object url to clear memory + setTimeout(() => URL.revokeObjectURL(objectUrl), 10000); + + }, async reloadNodePage() { // reload current node page without adding to history and without using cache @@ -775,6 +804,9 @@ export default { console.error(e); } }, + renderedNodePageContent() { + return this.renderPageContent(this.nodePagePath, this.nodePageContent); + } }, }