Cixo Develop 5 maanden geleden
bovenliggende
commit
20c9737775

+ 36 - 0
config.json

@@ -0,0 +1,36 @@
+"config": {
+    "sections": {
+        "O nas": {
+            "content": "content/o_nas.md",
+            "show_in_menu": 0,
+            "own_page": "/o-nas",
+            "template": "templates/section.html"
+        },
+        "Kontakt": {
+            "content": "content/kontakt.md",
+            "show_in_menu": 1,
+            "own_page": "/kontakt",
+            "template": "templates/section.html"
+        }
+    },
+
+    "menu": {
+        "core_template": "templates/core_menu.html",
+        "single_template": "templates/single_menu.html"
+    },
+
+    "page": {
+        "page": "templates/page.html",
+        "header": "templates/header.html",
+        "footer": "templates/footer.html"
+    },
+
+    "styles": [
+        "templates/static/style.css"
+    ],
+
+    "scripts": [
+        "templates/static/script.js"
+    ]
+}
+

+ 0 - 4
content/index.json

@@ -1,4 +0,0 @@
-{
-    "Hello there!": "hello.md",
-    "Contact": "contact.md"
-}

+ 2 - 0
content/o_nas.md

@@ -0,0 +1,2 @@
+# Przeczytaj więcej o nas
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+ 55 - 0
source/configurator.py

@@ -0,0 +1,55 @@
+import json
+import pathlib
+
+class configurator_exception(Exception):
+    pass
+
+class configurator:
+    def __init__(self, config_path: pathlib.Path | None) -> None: 
+        if config_path is None:
+            config_path = self.default_path
+
+        if not config_path.is_file() or not config_path.exists():
+            raise configurator_exception(
+                "Config file \"" \
+                + str(config_path) \
+                + "\" not exists."
+            )
+
+        with config_path.open() as handler:
+            try:
+                self.__storage = json.loads(handler.read())
+
+            except Exception as error:
+                raise configurator_exception(
+                    "Config file is not correct. Error: \"" 
+                    + str(error) 
+                    + "\"."
+                ) 
+
+    @staticmethod
+    def default_path() -> pathlib.Path:
+        return pathlib.Path("./config.json")
+
+    def get(self, key: str) -> any:
+        result = self.__storage
+
+        for count in key.split("."):
+            count = count.strip()
+
+            if len(count) == 0:
+                raise configurator_exception("Empty slot in key.")
+
+            if not count in result:
+                raise configurator_exception(
+                    "\"" \
+                    + count \
+                    + "\" not exists in configuration storage."
+                )
+
+            result = result[count]
+    @
+
+        return result
+    
+

+ 0 - 0
templates/core_menu.html


+ 0 - 0
templates/footer.html


+ 0 - 0
templates/header.html


+ 0 - 7
templates/menu/all.html

@@ -1,7 +0,0 @@
-<nav>
-    <div class="menu">
-        <ul>
-            <!-- menu_items --!>
-        </ul>
-    </div>
-</nav>

+ 0 - 1
templates/menu/single.html

@@ -1 +0,0 @@
-<a href="<!-- link --!>"><li><!-- name --!></li></a>

+ 0 - 0
templates/page.html


+ 0 - 15
templates/page/all.html

@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-
-<html lang="<? lang ?>">
-    <head>
-        <meta charset="UTF-8">
-        <title><? project-name ?></title>
-
-        <link rel="stylesheet" href="static/style.bundle.css" type="text/css">
-        <script src="static/script.bundle.js"></script>
-    </head>
-
-    <body>
-        <!-- body --!> 
-    </body>
-</html>

+ 0 - 3
templates/page/container.html

@@ -1,3 +0,0 @@
-<div class="container">
-    <!-- content --!>
-</div>

+ 0 - 5
templates/page/footer.html

@@ -1,5 +0,0 @@
-<footer>
-    <div class="footer">
-        
-    </div>
-</footer>

+ 0 - 5
templates/page/header.html

@@ -1,5 +0,0 @@
-<header>
-    <div class="header">
-        
-    </div>
-</header>

+ 0 - 15
templates/page/parts.html

@@ -1,15 +0,0 @@
-<div class="top">
-    <!-- header --!>
-    <!-- menu --!>
-</div>
-
-<main>
-    <div class="containers">
-        <!-- content --!>
-    </div>
-</main>
-
-<div class="bottom">
-    <!-- footer --!>
-</div>
-

+ 0 - 0
templates/section.html


+ 0 - 0
templates/single_menu.html


+ 0 - 0
templates/static/script.js


+ 0 - 0
templates/static/style.css