_extend = "base.html"
_footer = "{% file 'footer.html' %}"
_title = "Atheridis' Page"
+_web_title = "Atheridis' Page"
_owner = "Georgios Atheridis"
_email = "georgios@atheridis.org"
[index]
_name = "Home"
_title = "My Blog"
-_nav = 0
+_nav = 100
[final]
-_nav = 5
+_name = "Final"
+_nav = 70
[textfile]
-_nav = 20
+_name = "Text"
+_nav = 80
[about]
-_nav = 10
-
-[page_dir.index]
-_name = "Page Dir"
-_nav = 30
+_name = "About"
+_nav = 90
[posts]
_extend = "post.html"
_name = "Tags"
_nav = 40
-
-[posts.example]
-_owner = "John Doe"
-_email = "john_doe@example.com"
-_date = "2023-02-04"
-_title = "An example post"
-_description = "This is a description for the example post"
-_tags = ["example", "post", "sigma"]
-
-[posts.test]
-_date = "2023-02-02"
-_title = "Test"
-_description = "This is a test"
-_tags = ["test", "post"]
-
-[posts.other]
-_title = "Another Post"
-_description = "The description of another post"
-_tags = ["other", "post", "sigma"]
[posts.other._table]
name = ["Georgios Atheridis", "John Doe", "Jane Doe"]
email = ["georgios@atheridis.org", "johndoe@example.com", "janedoe@example.com"]
"phone number" = ["1234567890", "0777777777"]
-
-[posts.python-code]
-_title = "Python Code"
-_tags = ["post", "python", "example"]
# Is this a markdown file?
+
+$x$
+Title: This is my title
+Owner: John Doe
+Email: john_doe@example.com
+Date: 2023-02-05
+Description: This is a description for the example post
+Tags: example
+ post
+ sigma
+
+
This *is a header* for
===
-# {{ self._title }}
-
-{{ self._description }}
+title: Another Post
+description: The description of another post
+tags: other
+ post
+ sigma
+### {{ self._description }}
This is another file
this was posted on: {{ self._date }}
-# Here is some python code inside my page
+title: Python Code
+tags: post
+ python
+ example
-<h1> test </h1>
+### Here is some python code inside my page
+
+<h3> test </h3>
```python
<h1> test </h1>
{! self._code !}
-# Testing
+title: Test
+description: This is a test
+tags: test
+ post
-This is a test
+# {{ self._description }}
+
+Some test article is being written here
def md_to_html(md: str) -> str:
- return markdown.markdown(md, extensions=["extra", "sane_lists"])
+ return markdown.markdown(md, extensions=["extra", "sane_lists", "meta"])
+
+def md_meta(md: str) -> dict:
+ md_meta = markdown.Markdown(extensions=["meta"])
+ md_meta.convert(md)
+ return md_meta.Meta
def get_max_mtime(dir: str) -> float:
return
if not os.path.isdir(os.path.join(path, dir_name + dir_ext)):
- return
+ if dir_ext != ".md":
+ return
+ with open(os.path.join(path, dir_name + dir_ext), "r") as file_in:
+ m = md_meta(file_in.read()).get(key[1:])
+ if not m:
+ return
+ if len(m) == 1:
+ return m[0]
+ return m
+
+ try:
+ with open(os.path.join(path, dir_name + dir_ext, "_value.md"), "r") as file_in:
+ m = md_meta(file_in.read()).get(key[1:])
+ if m:
+ if len(m) == 1:
+ return m[0]
+ return m
+ except FileNotFoundError:
+ pass
for file in os.listdir(os.path.join(path, dir_name + dir_ext)):
file_name, file_ext = os.path.splitext(file)
return value
except FileNotFoundError:
pass
+ except IndexError:
+ pass
value = data.get(key)
for namespace_item in namespace:
data = data.get(namespace_item, data)
create_page_index(data)
+
builds = []
for root, _, files in os.walk(data["_PAGE_ROOT"]):
if root.startswith(("_", ".")):
+:root {
+ --background-colour-1: #F2FAFB;
+ --background-colour-2: #CBE5E9;
+ --background-colour-3: #CFEEDE;
+ --foreground-colour-1: #2D3536;
+ --foreground-colour-2: #408089;
+ --foreground-colour-3: #9BC7CD;
+ --primary-colour: #B2A6C4;
+ --secondary-colour: #A6C4B2;
+ --tertiary-colour: #C4B2A6;
+}
+
body {
- background: #DDDDDD;
- color: #333333;
- max-width: 900px;
- margin: auto;
- padding-top: 1rem;
+ background: radial-gradient(circle, var(--background-colour-3) 0%, var(--background-colour-2) 100%);
+ color: var(--foreground-colour-1);
+ max-width: 900px;
+ margin: auto;
+ font-family: sans-serif;
+ min-height: 100%;
+}
+a {
+ color: var(--foreground-colour-2);
+ text-decoration: none;
+ transition: 0.15s;
+}
+
+a:hover {
+ color: var(--foreground-colour-1);
+ text-decoration: none;
+}
+
+.content {
+ box-shadow: 0em 0.1em 0.3em var(--foreground-colour-1);
+ border-radius: 0.7em;
+ background: var(--background-colour-1);
+ margin: 2rem;
+ padding: 1.4rem;
+}
+
+header {
+ display: grid;
+ grid-template-areas: "p nav";
+}
+
+header > h1 {
+ margin: 0;
+ padding: 0;
+ display: flex;
+ align-items: center;
}
+
+nav {
+ display: flex;
+ flex-direction: row-reverse;
+}
+
nav a {
- padding-left: 1rem;
- padding-right: 1rem;
+ background: var(--foreground-colour-2);
+ color: var(--background-colour-1);
+ margin-left: 1rem;
+ padding: 0.7rem;
+ padding-top: 0.3rem;
+ padding-bottom: 0.3rem;
+ border-radius: 0.5em;
+ display: flex;
+ align-items: center;
}
+
nav a:hover {
- background: #350;
- color: #ddd;
+ background: var(--foreground-colour-3);
+ color: var(--foreground-color-1);
+}
+
+article {
+ margin: 1rem;
+}
+
+
+article table {
+ width: 100%;
+}
+
+article table thead th {
+ text-align: left;
+}
+
+article table tr:hover td {
+ background-color: var(--background-colour-2);
+}
+
+article table tr td:nth-child(2),
+article table tr td:nth-child(3),
+article table tr td:nth-child(3),
+article table tr td:nth-child(2) {
+ white-space: normal;
}
<!DOCTYPE html>
<html>
- <head>
- <title>{{ self._title }}</title>
- <link rel="stylesheet" href="/static/main.css" />
- </head>
- <body>
- {% file 'scripts/build_nav.py' %}
- <hr />
- {{ self._value }}
- <hr />
- {{ self._footer }}
- </body>
+ <head>
+ <title>{{ self._title }}</title>
+ <link rel="stylesheet" href="/static/main.css" />
+ </head>
+ <body>
+ <header class="content">
+ <h1><a href="/">{{ self._web_title }}</a></h1>
+ {% file 'scripts/build_nav.py' %}
+ </header>
+ <div class="content">
+ {{ self._value }}
+ </div>
+ <footer class="content">
+ {{ self._footer }}
+ </footer>
+ </body>
</html>
-<footer>
- This is my footer on page
-</footer>
+This is my footer on page
{% extend 'base.html' %}
-<h3>Here is my article</h3>
-<p>From: <a href="mailto:{{ self._email }}">{{ self._owner }}</a></p>
-<p>Date: {{ self._date }}</p>
+<div class="post-meta">
+ <h2>{{ self._title }}</h2>
+ <table>
+ <tbody>
+ <tr>
+ <td>From:</td>
+ <td><a href="mailto:{{ self._email }}">{{ self._owner }}</a></td>
+ </tr>
+ <tr>
+ <td>Date:</td>
+ <td>{{ self._date }}</td>
+ </tr>
+ </tbody>
+ </table>
+</div>
<article>
- {{ self._value }}
+ {{ self._value }}
</article>
if post == "tags":
continue
post_timestamp.append(
- (time.strptime(posts[post]["_date"], data["_DATE_FORMAT"]), post)
+ (
+ time.strptime(
+ get_value(data, ("posts", post), "_date"),
+ get_value(data, (), "_DATE_FORMAT"),
+ ),
+ post,
+ )
)
post_timestamp = sorted(post_timestamp, reverse=True)
-_value = "<table><thead><tr>%(head)s</tr></thead><tbody>%(body)s</tbody></table>"
+_value = '<table class="tables"><thead><tr>%(head)s</tr></thead><tbody>%(body)s</tbody></table>'
posts = ""
table = get_value(data, namespace, "_table")