Merge branch 'master' into pages
14
ryuji.ts
@@ -1,6 +1,6 @@
|
|||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
export const SYNTAX_REGEX = /\[\[ [a-zA-Z0-9.:\-_!]+ \]\]/g;
|
export const SYNTAX_REGEX = /\[\[ [a-zA-Z0-9.:/\-_!]+ \]\]/g;
|
||||||
|
|
||||||
export type file_extension = `.${string}`;
|
export type file_extension = `.${string}`;
|
||||||
|
|
||||||
@@ -129,11 +129,6 @@ export class Renderer {
|
|||||||
//make sure thing we are iterating over isn't empty
|
//make sure thing we are iterating over isn't empty
|
||||||
if (var_value.length === 0) {
|
if (var_value.length === 0) {
|
||||||
//skip straight to the endfor
|
//skip straight to the endfor
|
||||||
//todo: remove
|
|
||||||
/*let new_index: number = matches.slice(index, matches.length).findIndex((match) => match[0] === "[[ endfor ]]");
|
|
||||||
if (new_index === -1) throw Error("for statement missing an `[[ endfor ]]`");
|
|
||||||
index += new_index;
|
|
||||||
continue;*/
|
|
||||||
let sliced = matches.slice(index+1, matches.length);
|
let sliced = matches.slice(index+1, matches.length);
|
||||||
let new_index: number;
|
let new_index: number;
|
||||||
let extra_fors: number = 0;
|
let extra_fors: number = 0;
|
||||||
@@ -148,7 +143,7 @@ export class Renderer {
|
|||||||
extra_fors--;
|
extra_fors--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof new_index === "undefined") throw Error("if statement missing an `[[ endif ]]`");
|
if (typeof new_index === "undefined") throw Error("`for:` statement missing an `[[ endfor ]]`");
|
||||||
index += new_index+1;
|
index += new_index+1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -225,7 +220,7 @@ export class Renderer {
|
|||||||
extra_ifs--;
|
extra_ifs--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof new_index === "undefined") throw Error("if statement missing an `[[ endif ]]`");
|
if (typeof new_index === "undefined") throw Error("`if:` statement missing an `[[ endif ]]`");
|
||||||
index += new_index+1;
|
index += new_index+1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -243,7 +238,7 @@ export class Renderer {
|
|||||||
//convert to string
|
//convert to string
|
||||||
let var_value: string = String(Renderer.get_var(var_name, vars));
|
let var_value: string = String(Renderer.get_var(var_name, vars));
|
||||||
//add indentation
|
//add indentation
|
||||||
let current_lines: string[] = rendered.split("\n")
|
let current_lines: string[] = rendered.split("\n");
|
||||||
let current_last: string = current_lines[current_lines.length-1];
|
let current_last: string = current_lines[current_lines.length-1];
|
||||||
let indentation: number = 0;
|
let indentation: number = 0;
|
||||||
for (let i=0; i < current_last.length; i++) {
|
for (let i=0; i < current_last.length; i++) {
|
||||||
@@ -260,7 +255,6 @@ export class Renderer {
|
|||||||
} else {
|
} else {
|
||||||
rendered += Renderer.sanitize(var_value);
|
rendered += Renderer.sanitize(var_value);
|
||||||
}
|
}
|
||||||
//offset += var_value.length-match[0].length;
|
|
||||||
}
|
}
|
||||||
//add the html that comes after this, up until the next template syntax match thing
|
//add the html that comes after this, up until the next template syntax match thing
|
||||||
rendered += template_contents.slice(match.index+match[0].length, matches[index+1]?.index ? matches[index+1].index : template_contents.length);
|
rendered += template_contents.slice(match.index+match[0].length, matches[index+1]?.index ? matches[index+1].index : template_contents.length);
|
||||||
|
|||||||
BIN
static/88x31/247.gif
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
static/88x31/btw.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/88x31/fe.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
static/88x31/ie11.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
static/88x31/jsn.gif
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
static/88x31/mh.gif
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
static/88x31/salt.gif
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
@@ -22,6 +22,30 @@ body {
|
|||||||
font-size: 1.02rem;
|
font-size: 1.02rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 2rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 code {
|
||||||
|
font-size: 1.9rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 1.5em !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 code {
|
||||||
|
font-size: 1.4em !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3, h3 code {
|
||||||
|
font-size: 1.3em !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 code {
|
||||||
|
font-size: 1.2em !important;
|
||||||
|
}
|
||||||
|
|
||||||
#return {
|
#return {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
@@ -79,9 +103,11 @@ label[for="dark-mode"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#dark-mode + label[for="dark-mode"]::after {
|
#dark-mode + label[for="dark-mode"]::after {
|
||||||
|
color: black;
|
||||||
content: "🌙";
|
content: "🌙";
|
||||||
}
|
}
|
||||||
|
|
||||||
#dark-mode:checked + label[for="dark-mode"]::after {
|
#dark-mode:checked + label[for="dark-mode"]::after {
|
||||||
|
color: white;
|
||||||
content: "☀️";
|
content: "☀️";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,3 +14,20 @@ h2 {
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.random {
|
||||||
|
margin-top: 10px;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.random:target {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.random:target ~ #ciran {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.random-content {
|
||||||
|
min-height: 40px;
|
||||||
|
}
|
||||||
|
|||||||
12
templates/components/random/badges.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<div class="random" id="badges">
|
||||||
|
<div class="random-content">
|
||||||
|
<img src="88x31/247.gif" alt="nishina gif" loading="lazy"/>
|
||||||
|
<img src="88x31/btw.png" alt="i use debian btw" loading="lazy"/>
|
||||||
|
<img src="88x31/fe.gif" alt="5 nays to 5 eyes" loading="lazy"/>
|
||||||
|
<img src="88x31/ie11.png" alt="A warm welcome to our IE11 users" loading="lazy"/>
|
||||||
|
<img src="88x31/jsn.gif" alt="Just say no to software bloat" loading="lazy"/>
|
||||||
|
<img src="88x31/mh.gif" alt="Certified mostly harmless" loading="lazy"/>
|
||||||
|
<img src="88x31/salt.gif" alt="Salt your passwords, OR ELSE!" loading="lazy"/>
|
||||||
|
</div>
|
||||||
|
<a href="/#quote1">More random stuff</a>
|
||||||
|
</div>
|
||||||
6
templates/components/random/minesweeper.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<div class="random" id="minesweeper">
|
||||||
|
<div class="random-content">
|
||||||
|
<a href="https://prussia.dev/retro?open_windows=minesweeper">Play Minesweeper</a>
|
||||||
|
</div>
|
||||||
|
<a href="/#wikipedia">More random stuff</a>
|
||||||
|
</div>
|
||||||
8
templates/components/random/quote1.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<div class="random" id="quote1">
|
||||||
|
<div class="random-content">
|
||||||
|
<span>If you do not let me in I will break your door, and smash the lock!</span>
|
||||||
|
<br>
|
||||||
|
<span>- Gilgamesh</span>
|
||||||
|
</div>
|
||||||
|
<a href="/#quote2">More random stuff</a>
|
||||||
|
</div>
|
||||||
8
templates/components/random/quote2.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<div class="random" id="quote2">
|
||||||
|
<div class="random-content">
|
||||||
|
<span>In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.</span>
|
||||||
|
<br>
|
||||||
|
<span>- Douglas Adams</span>
|
||||||
|
</div>
|
||||||
|
<a href="/#minesweeper">More random stuff</a>
|
||||||
|
</div>
|
||||||
6
templates/components/random/wikipedia.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<div class="random" id="wikipedia">
|
||||||
|
<div class="random-content">
|
||||||
|
<span>Bored? Go down a <a href="https://en.wikipedia.org/wiki/Main_Page">Wikipedia</a> rabbithole!</span>
|
||||||
|
</div>
|
||||||
|
<a href="/#badges">More random stuff</a>
|
||||||
|
</div>
|
||||||
@@ -25,6 +25,14 @@
|
|||||||
[[ endfor ]]
|
[[ endfor ]]
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
[[ component:random/badges ]]
|
||||||
|
[[ component:random/quote1 ]]
|
||||||
|
[[ component:random/quote2 ]]
|
||||||
|
[[ component:random/minesweeper ]]
|
||||||
|
[[ component:random/wikipedia ]]
|
||||||
|
<a id="ciran" href="/#badges">See some random stuff</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
5
tests.ts
@@ -89,10 +89,9 @@ test_assert_equal(
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
"<p>a</p><p>c</p>",
|
"<p>a</p><p>c</p>",
|
||||||
"nested for loop with if statement test"
|
"for loop with if statement test"
|
||||||
);
|
);
|
||||||
|
|
||||||
//for loop and template
|
|
||||||
test_assert_equal(
|
test_assert_equal(
|
||||||
Renderer.remove_empty_lines(
|
Renderer.remove_empty_lines(
|
||||||
renderer.render(
|
renderer.render(
|
||||||
@@ -113,7 +112,7 @@ test_assert_equal(
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
"<div>\n <ul>\n <li><a href=\"/posts/abc\">Abc!</a></li>\n <li>abcabcabc</li>\n <li><a href=\"/posts/san-shi-san\">San Shi San</a></li>\n <li>abcabcabc</li>\n </ul>\n</div>",
|
"<div>\n <ul>\n <li><a href=\"/posts/abc\">Abc!</a></li>\n <li>abcabcabc</li>\n <li><a href=\"/posts/san-shi-san\">San Shi San</a></li>\n <li>abcabcabc</li>\n </ul>\n</div>",
|
||||||
"for loop with template test"
|
"nested for loop with template test"
|
||||||
);
|
);
|
||||||
|
|
||||||
//[[ if index_var ]] will be false when index_var is 0 btw
|
//[[ if index_var ]] will be false when index_var is 0 btw
|
||||||
|
|||||||