diff --git a/dc09.js b/dc09.js index 385cbaa..ed7aef1 100644 --- a/dc09.js +++ b/dc09.js @@ -10,6 +10,7 @@ const exec = (cmd) => { } const CleanCSS = require('clean-css') +const Handlebars = require('handlebars') const html = require('html-minifier') @@ -85,17 +86,14 @@ function buildOne(dir) { print(`${bold}Building:${reset} ${dir}`) const config = `${dir}/webpage.json` - let files - if (fs.existsSync(config)) { - files = JSON.parse(fs.readFileSync(config)) - } - else { + if (!fs.existsSync(config)) { print( 'Unable to find webpage.json, skipping', false, '!', yellow, ) return } + const files = JSON.parse(fs.readFileSync(config)) fs.mkdirSync(`dist/${dir}`, { recursive: true @@ -107,6 +105,8 @@ function buildOne(dir) { renderLess(dir, files) print('Minifying CSS') minifyCss(dir, files) + print('Compiling Handlebars HTML') + compileHbHtml(dir, files) print('Converting paths in HTML') convertPathsHtml(dir, files) print('Minifying HTML') @@ -128,7 +128,7 @@ function minifyJs(dir, files) { function renderLess(dir, files) { files.less = files.less || [] if (files.less.length == 0) return; - rendered = path.resolve(`dist/${dir}/${mincss}`) + const rendered = path.resolve(`dist/${dir}/${mincss}`) exec( 'node_modules/.bin/lessc ' + files.less.map(less => `"${dir}/${less}"`).join(' ') + @@ -147,12 +147,45 @@ function minifyCss(dir, files) { fs.writeFileSync(`dist/${dir}/${mincss}`, content) } +function compileHbHtml(dir, files) { + files.hb = files.hb || [] + const compiled = [] + for (let file of files.hb) { + const parts = file.split('.') + const base = parts.slice(0, -1).join('.') || '' + const name = path.resolve(`${dir}/${file}`) + const conf = path.resolve(`${dir}/${base}.json`) + const built = path.resolve(`dist/${dir}/${base}.html`) + if (!fs.existsSync(conf)) { + print( + `Unable to find ${conf} \n` + + ' for the template, skipping', + false, '!', yellow, + ) + continue + } + const ctx = JSON.parse(fs.readFileSync(conf)) + const template = Handlebars.compile( + fs.readFileSync(name).toString() + ) + fs.writeFileSync(built, template(ctx)) + compiled.push(built) + } + files.html = [ + ...(files.html || []), + ...compiled, + ] +} + function convertPathsHtml(dir, files) { const scriptRegex = /(?:', @@ -166,7 +199,6 @@ function convertPathsHtml(dir, files) { scriptRegex, `` ) - const built = path.resolve(`dist/${dir}/${file}`) fs.writeFileSync(built, content) converted.push(built) } diff --git a/package.json b/package.json index 9390402..2935760 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "dependencies": { "clean-css": "^5.3.1", + "handlebars": "^4.7.7", "html-minifier": "^4.0.0", "less": "^4.1.3", "terser": "^5.16.1" diff --git a/space/index.handlebars b/space/index.handlebars new file mode 100644 index 0000000..3f984c5 --- /dev/null +++ b/space/index.handlebars @@ -0,0 +1,214 @@ + + + + + + DarkCat09's Web Site + + + + + + + + + + +
+
+ + Unable to load image +
+
+ + + + + + + + + + + + + diff --git a/space/index.html b/space/index.html deleted file mode 100644 index 457daed..0000000 --- a/space/index.html +++ /dev/null @@ -1,1008 +0,0 @@ - - - - - - DarkCat09's Web Site - - - - - - - - - - -
-
- - Unable to load image -
-
- - - - - - - - - - - - - diff --git a/space/index.json b/space/index.json new file mode 100644 index 0000000..e954b56 --- /dev/null +++ b/space/index.json @@ -0,0 +1,459 @@ +{ + "spaceobj": [ + { + "img": "img/earth.gif", + "icon": "fas fa-globe-americas", + "name": "Earth" + }, + { + "img": "img/moon.gif", + "icon": "fas fa-moon", + "name": "Moon" + }, + { + "img": "img/sun.gif", + "icon": "fas fa-sun", + "name": "Sun" + }, + { + "img": "img/mars.gif", + "icon": "fa-solid fa-earth-europe", + "name": "Mars" + }, + { + "img": "data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", + "icon": "fa-regular fa-circle-xmark", + "name": "Space" + } + ], + "menu": [ + { + "id": "about", + "icon": "fa-solid fa-user" + }, + { + "id": "code", + "icon": "fa-solid fa-code" + }, + { + "id": "selfhosted", + "icon": "fa-solid fa-cube" + } + ], + "about": [ + { + "icon": "fa-solid fa-calendar-days", + "content": "Birthday: July, 2009 ()" + }, + { + "icon": "fa-solid fa-location-dot", + "content": "Russia, Ulyanovsk" + }, + { + "icon": "fa-solid fa-headphones", + "content": "One Direction
Linkin Park
Imagine Dragons
Pizza" + }, + { + "icon": "fa-solid fa-desktop", + "content": "Manjaro KDE", + "expand": { + "id": 1, + "code": "
"
+            }
+        }
+    ],
+    "profiles": [
+        {
+            "icon": "fa-brands fa-github",
+            "url": "https://github.com/DarkCat09",
+            "name": "GitHub",
+            "user": "DarkCat09"
+        },
+        {
+            "icon": "fa-brands fa-git-alt",
+            "url": "https://codeberg.org/DarkCat09",
+            "name": "Codeberg",
+            "user": "DarkCat09"
+        },
+        {
+            "icon": "fa-solid fa-envelope",
+            "url": "mailto:a.chehckenev@yandex.ru",
+            "name": "E-mail",
+            "user": "a.chechkenev",
+            "copy": "a.chechkenev@yandex.ru"
+        },
+        {
+            "icon": "fa-brands fa-telegram",
+            "url": "https://t.me/darkcat09",
+            "name": "Telegram",
+            "user": "@darkcat09"
+        },
+        {
+            "icon": "fa-solid fa-4",
+            "url": "https://4pda.to/forum/index.php?showuser=8898436",
+            "name": "4PDA",
+            "user": "8898436"
+        },
+        {
+            "icon": "fa-brands fa-discord",
+            "url": "https://discord.com/app",
+            "name": "Discord",
+            "user": "DarkCat09#5587",
+            "copy": "DarkCat09#5587"
+        }
+    ],
+    "langs": [
+        {
+            "icon": "fa-brands fa-python",
+            "name": "Python",
+            "id1": "py",
+            "id2": "python",
+            "skills": [
+                "Basics",
+                "OOP",
+                "PEP8, MyPy",
+                "Unpacking, filter/map",
+                "List/dict comprehension",
+                "Flask",
+                "PyPI packaging",
+                "Unittests",
+                "MkDocs",
+                "Lots of modules"
+            ],
+            "projects": [
+                {
+                    "url": "https://github.com/DarkCat09/python-aternos",
+                    "name": "python-aternos",
+                    "stars": 51
+                },
+                {
+                    "url": "https://github.com/DarkCat09/python-scripts",
+                    "name": "python-scripts",
+                    "stars": 5
+                },
+                {
+                    "url": "https://github.com/DarkCat09/showdialog",
+                    "name": "showdialog",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/randomus",
+                    "name": "randomus",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/knigavuhe",
+                    "name": "knigavuhe",
+                    "stars": 0
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/1e2d1c79d038392adab5280d79626eab",
+                    "name": "discord bots",
+                    "stars": 1
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/b53a72d94786aed696372e889a3b7885",
+                    "name": "bb pixel art",
+                    "stars": 1
+                }
+            ]
+        },
+        {
+            "icon": "fa-brands fa-html5",
+            "name": "HTML & CSS",
+            "id1": "css",
+            "id2": "css",
+            "skills": [
+                "\"{less}\"",
+                "Handlebars",
+                "HTML, CSS basics",
+                "Forms, inputs",
+                "Animations",
+                "Flexboxes",
+                "Grid (learning)"
+            ],
+            "projects": [
+                {
+                    "url": "https://codeberg.org/DarkCat09/pages-src",
+                    "name": "this page",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/cmdsminew",
+                    "name": "cmdsmine",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/monolight",
+                    "name": "monolight",
+                    "stars": 0
+                }
+            ]
+        },
+        {
+            "icon": "fa-brands fa-square-js",
+            "name": "JavaScript",
+            "id1": "js",
+            "id2": "js",
+            "skills": [
+                "Basics",
+                "Loops, conditions",
+                "Sort, filter, etc.",
+                "Arrow expresions",
+                "Destructuring",
+                "Promises, async/await",
+                "DOM, Event Handlers",
+                "2D Canvas",
+                "Handlebars",
+                "OOP (learning)",
+                "NodeJS & NPM (learning)"
+            ],
+            "projects": [
+                {
+                    "url": "https://codeberg.org/DarkCat09/pages-src",
+                    "name": "this page",
+                    "stars": 0
+                },
+                {
+                    "url": "https://codeberg.org/DarkCat09/pages-src/src/branch/main/dc09.js",
+                    "name": "build script (nodejs)",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/monolight",
+                    "name": "monolight",
+                    "stars": 0
+                }
+            ]
+        },
+        {
+            "svg": true,
+            "icon": "svg/kotlin.svg",
+            "name": "Kotlin",
+            "id1": "kt",
+            "id2": "kotlin",
+            "skills": [
+                "(currently learning)",
+                "Basics",
+                "If, when",
+                "Loops, ranges",
+                "Lists, Maps",
+                "OOP, data classes",
+                "Lambdas, Vararg",
+                "Null safety operators",
+                "Android development"
+            ],
+            "projects": [
+                {
+                    "url": "https://github.com/DarkCat09/helloapp",
+                    "name": "helloapp",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/replace-input",
+                    "name": "replace-input",
+                    "stars": 0
+                }
+            ]
+        },
+        {
+            "icon": "fa-solid fa-hashtag",
+            "name": "CSharp",
+            "id1": "cs",
+            "id2": "csharp",
+            "skills": [
+                "Syntax",
+                "Loops, conditions",
+                "WinForms",
+                "MySql.Data",
+                "Tuples, destructuring",
+                "Null safety operators"
+            ],
+            "projects": [
+                {
+                    "url": "https://github.com/DarkCat09/dumptool",
+                    "name": "windows dump tool",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/AchSmartHome",
+                    "name": "AchSmartHome",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/RecurseWinFormsTest",
+                    "name": "recursion example",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/Tariffs",
+                    "name": "tariffs",
+                    "stars": 0
+                }
+            ]
+        },
+        {
+            "icon": "fa-brands fa-windows",
+            "name": "VBScript",
+            "id1": "vbs",
+            "id2": "vbs",
+            "skills": [
+                "Syntax",
+                "Arrays",
+                "Loops, conditions",
+                "Message boxes",
+                "WScript.Shell",
+                "FileSystemObject",
+                "Registry Editing"
+            ],
+            "projects": [
+                {
+                    "url": "https://github.com/DarkCat09/vbscripting",
+                    "name": "vbscripting",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/vbs-season-wallpaper",
+                    "name": "season-wallpaper",
+                    "stars": 0
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/6b7226dc5afea2f4b5c8f6407e323a65",
+                    "name": "add-to-startup",
+                    "stars": 0
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/5f12095cbef4d299f2b8124410ca3e48",
+                    "name": "winrestart",
+                    "stars": 0
+                }
+            ]
+        },
+        {
+            "icon": "fa-solid fa-terminal",
+            "name": "Bash",
+            "id1": "bash",
+            "id2": "bash",
+            "skills": [
+                "Basics",
+                "Loops and conditions",
+                "Functions",
+                "Crontab",
+                "Some escape codes",
+                "Arrays (learning)"
+            ],
+            "projects": [
+                {
+                    "url": "https://github.com/DarkCat09/saveyoureyes",
+                    "name": "save-your-eyes",
+                    "stars": 0
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/cba140c921a5bed7f042e157b2319808",
+                    "name": "1compiler api",
+                    "stars": 0
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/29e4628664dc53666f0b6242395aeab8",
+                    "name": "bashrc",
+                    "stars": 0
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/eb40c544a4a722bb3a62d23e8ad418cb",
+                    "name": "floating window",
+                    "stars": 0
+                }
+            ]
+        },
+        {
+            "icon": "fa-brands fa-java",
+            "name": "Java",
+            "id1": "java",
+            "id2": "java",
+            "skills": [
+                "Syntax",
+                "Loops, conditions",
+                "Lists, HashMap",
+                "JavaFX + SceneBuilder",
+                "Android development"
+            ],
+            "projects": [
+                {
+                    "url": "https://github.com/DarkCat09/blockapp",
+                    "name": "blockapp",
+                    "stars": 0
+                },
+                {
+                    "url": "https://gist.github.com/DarkCat09/ce7286f7acca79177b440bae9251e819",
+                    "name": "magic substring",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/mtkfwtools",
+                    "name": "mtkfwtools",
+                    "stars": 0
+                },
+                {
+                    "url": "https://github.com/DarkCat09/virustotal-gui-fx",
+                    "name": "virustotal-gui-fx",
+                    "stars": 0
+                }
+            ]
+        },{
+            "icon": "fa-brands fa-php",
+            "name": "PHP",
+            "id1": "php",
+            "id2": "php",
+            "skills": [
+                "Variables",
+                "Arrays",
+                "Conditions, loops",
+                "Headers",
+                "Drawing images",
+                "MySQLi",
+                "Bcrypt"
+            ],
+            "projects": [
+                {
+                    "url": "https://github.com/DarkCat09/englearn",
+                    "name": "englearn",
+                    "stars": 0
+                }
+            ]
+        },
+        {
+            "icon": "fa-brands fa-android",
+            "name": "Smali",
+            "id1": "smali",
+            "id2": "smali",
+            "skills": [
+                "Main syntax",
+                "Can read non-obfuscated code",
+                "Can change simple code"
+            ],
+            "projects": []
+        }
+    ],
+    "selfhosted": [
+        {
+            "icon": "fa-solid fa-house",
+            "domain": "dc09.ru"
+        },
+        {
+            "icon": "fa-brands fa-git-alt",
+            "domain": "git.dc09.ru"
+        },
+        {
+            "icon": "fa-solid fa-link",
+            "domain": "url.dc09.ru"
+        },
+        {
+            "icon": "fa-solid fa-address-book",
+            "domain": "sync.dc09.ru"
+        },
+        {
+            "icon": "fa-brands fa-wikipedia-w",
+            "domain": "wt.dc09.ru"
+        }
+    ]
+}
diff --git a/space/styles.less b/space/styles.less
index 3e95948..ec992f0 100644
--- a/space/styles.less
+++ b/space/styles.less
@@ -322,17 +322,11 @@ a {
 					margin: 0;
 					padding: 0;
 
-					.less-logo {
-
+					img {
 						margin: 0;
 						padding: 0;
-						
-						img {
-							margin: 0;
-							padding: 0;
-							display: block;
-							height: 1.16rem;
-						}
+						display: block;
+						height: 1.16rem;
 					}
 				}
 			}
diff --git a/space/webpage.json b/space/webpage.json
index 8096e25..bf7095c 100644
--- a/space/webpage.json
+++ b/space/webpage.json
@@ -1,5 +1,6 @@
 {
-    "html": ["index.html"],
+    "html": [],
+    "hb": ["index.handlebars"],
     "less": ["styles.less"],
     "css": [],
     "js": [