Skip to content

Commit 704be58

Browse files
committed
update
1 parent 3338bda commit 704be58

File tree

7 files changed

+88
-25
lines changed

7 files changed

+88
-25
lines changed

parser.js

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ function processConditionals(html, attributes) {
3939
const ifdefRegex = /\$\$ifdef:([a-zA-Z0-9_]+)\$\$([\s\S]*?)\$\$endif\$\$/g;
4040

4141
return html.replace(ifdefRegex, (match, attrName, content) => {
42+
if (attrName === "value" || attrName === "xmlns") return content;
43+
4244
const attribute = attributes.find(attr => attr.name === attrName);
4345

4446
// If the attribute exists, keep the content (without the ifdef/endif tags)
4547
if (attribute && attribute.value) {
4648
// Replace $$attrName$$ with the attribute value
47-
return content.replace(new RegExp(`\\$\\$${attrName}\\$\\$`, 'g'), attribute.value);
49+
content = content.replace(new RegExp(`\\$\\$${attrName}\\$\\$`, 'g'), attribute.value);
50+
content = content.replace(new RegExp(`___${attrName}___`, 'g'), attribute.value);
51+
return content;
4852
}
4953

5054
// If the attribute doesn't exist or is empty, remove the entire block
@@ -75,24 +79,15 @@ export async function parse(originalHtml, reload = false) {
7579
let componentHtml = chtml;
7680
const attributes = Array.from(element.attributes);
7781

78-
componentHtml = processConditionals(componentHtml, attributes);
79-
80-
81-
const componentDom = new DOMParser().parseFromString(componentHtml, 'text/html');
82-
83-
// Replace <slot> with inner elements nodes
84-
const innerHtml = new XMLSerializer().serializeToString(element);
85-
replaceTagWithValue(componentDom, 'slot', innerHtml);
8682

87-
// Replace <slot:attribute></slot:attribute> with attribute value
88-
for (const attribute of attributes) {
89-
replaceTagWithValue(componentDom, `slot-${attribute.name}`, attribute.value);
83+
let innerHtml = new XMLSerializer().serializeToString(element);
84+
let innerText = innerHtml;
85+
if (element.childNodes.length > 0 && element.childNodes[0].nodeType == 3) {
86+
innerText = element.childNodes[0].textContent;
9087
}
9188

92-
componentHtml = new XMLSerializer().serializeToString(componentDom);
93-
9489
// Replace $$attribute$$ with attribute value
95-
90+
9691
const regex = /\$\$([a-zA-Z0-9_]+)\$\$/g;
9792
let match;
9893
while ((match = regex.exec(componentHtml)) !== null) {
@@ -103,10 +98,28 @@ export async function parse(originalHtml, reload = false) {
10398

10499

105100

106-
101+
107102

108103
// Replace $$value$$ with innerHtml
109-
componentHtml = componentHtml.replace(/\$\$value\$\$/g, innerHtml);
104+
componentHtml = componentHtml.replace(/___value___/g, innerText);
105+
componentHtml = componentHtml.replace(/\$\$value\$\$/g, innerText);
106+
107+
componentHtml = processConditionals(componentHtml, attributes);
108+
109+
const componentDom = new DOMParser().parseFromString(componentHtml, 'text/html');
110+
111+
112+
// Replace <slot> with inner elements nodes
113+
114+
replaceTagWithValue(componentDom, 'slot', innerHtml);
115+
116+
// Replace <slot:attribute></slot:attribute> with attribute value
117+
for (const attribute of attributes) {
118+
replaceTagWithValue(componentDom, `slot-${attribute.name}`, attribute.value);
119+
}
120+
121+
componentHtml = new XMLSerializer().serializeToString(componentDom);
122+
110123

111124

112125
const componentFragment = new DOMParser().parseFromString(componentHtml, 'text/html').documentElement;

src/components/x-header.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ <h1><a href="/">N<span class="small">ostr</span>G<span class="small">ame</span>
66
</div>
77
<nav>
88
<a href="/roadmap.html"><ion-icon name="map-outline"></ion-icon>Roadmap</a>
9-
9+
<a href="/docs"><ion-icon name="journal-outline"></ion-icon>Docs</a>
1010
<a href="https://github.com/NostrGameEngine"><ion-icon name="logo-github"></ion-icon>Source</a>
11-
<!-- <a href="/support.html"><ion-icon name="bug-outline"></ion-icon>Support</a> -->
12-
<!-- <a href="/contacts.html"><ion-icon name="mail-outline"></ion-icon>Contact</a> -->
11+
<a href="/contacts.html"><ion-icon name="mail-outline"></ion-icon>Contact</a>
12+
<a href="https://javadoc.ngengine.org"><ion-icon name="cafe-outline"></ion-icon>Javadoc</a>
1313

14+
1415
</nav>
1516

1617
</header>

src/components/x-npub.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div style="word-wrap: anywhere; display:block; ">
2+
<a href="https://primal.net/p/___value___">___value___</a>
3+
</div>

src/components/x-roadmap.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
<ul>
3939
<li>Windows</li>
4040
<li>Linux</li>
41-
<li>Android</li>
41+
<li>MacOS</li>
42+
4243
</ul>
4344
using jvm based languages.
4445
</p>

src/contacts.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
11
<x-page title="| Contacts">
2+
23

4+
<hr>
5+
<h1>Contact</h1>
6+
<hr>
7+
8+
<p>
9+
Feel free to reach out to us through the following channels.
10+
</p>
11+
<p>
12+
<sub>Feedback, questions, and contributions are always welcome!</sub>
13+
14+
</p>
15+
<section class="h cards">
16+
<card>
17+
<h1>Nostr</h1>
18+
<div class="h">
19+
<x-icon icon="p2p" size="6rem"></x-icon>
20+
21+
</div>
22+
<x-npub>npub146wutmuxfmnlx9fcty0lkns2rpwhnl57kpes26mmt4hygalsakrsdllryz</x-npub>
23+
24+
</card>
25+
26+
<card>
27+
28+
<h1>Email</h1>
29+
<div class="h">
30+
<ion-icon class="t-icon" name="mail-outline" style="font-size:6rem"></ion-icon>
31+
32+
</div>
33+
34+
</card>
35+
36+
<card>
37+
38+
<h1>Report an Issue</h1>
39+
<div class="h">
40+
<ion-icon class="t-icon" name="logo-github" style="font-size:6rem"></ion-icon>
41+
42+
</div>
43+
<a href=" https://github.com/NostrGameEngine/ngengine/issues">NostrGameEngine/ngengine</a>
44+
</card>
45+
46+
</section>
347
</x-page>

src/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ <h1>Crossplatform</h1>
4141
<x-icon icon="windows" title="Windows" size="3rem"></x-icon>
4242
<x-icon icon="android" title="Android" size="3rem"></x-icon>
4343
<x-icon icon="html" title="Browser" class="disabled" size="3rem"></x-icon>
44-
<x-icon icon="macos" title="MacOS" class="disabled" size="3rem"></x-icon>
44+
<x-icon icon="macos" title="MacOS" size="3rem"></x-icon>
4545
<x-icon icon="ios" title="iOS" class="disabled" size="3rem"></x-icon>
4646
</div>
4747
<sub>
48-
Native performance on Windows, Linux and Android, with planned support for browsers, macOS, and iOS. With a cross-compilation
49-
toolchain that ensures consistent experiences across all platforms.
48+
Native performance on Windows, Linux macOS and Android, with planned support for browsers and iOS.
5049

5150
</sub>
5251
</card>

static/style.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,9 @@
670670
}
671671

672672

673-
673+
.t-icon {
674+
color: var(--light-purple);
675+
}
674676

675677
h1 .small {
676678
font-size: 0.9rem;

0 commit comments

Comments
 (0)