diff --git a/.DS_Store b/.DS_Store index 79a7b6f..38eca62 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 26bfa0f..be85d43 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/venv/ \ No newline at end of file +/venv/ +/build/ \ No newline at end of file diff --git a/app.py b/app.py index 13ca26c..5ee8283 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,7 @@ +import os from flask import Flask, render_template from flask_frozen import Freezer +from markupsafe import Markup app = Flask(__name__) freezer = Freezer(app) @@ -10,6 +12,30 @@ def index(): return render_template('index.html') +@app.route("/blog") +def blog(): + posts = [] + for filename in os.listdir("posts"): + if filename.endswith(".html"): + with open(os.path.join("posts", filename)) as f: + content = f.read() + title = os.path.splitext(filename)[0].replace("-", " ").title() + posts.append({"title": title, "content": Markup(content)}) + return render_template("blog.html", posts=posts) + + +@app.route("/blog/") +def post(post_slug): + post_file = f"posts/{post_slug}.html" + if os.path.exists(post_file): + with open(post_file) as f: + content = Markup(f.read()) + title = post_slug.replace("-", " ").title() + return render_template("post.html", title=title, content=content) + else: + return "Post not found", 404 + + if __name__ == '__main__': freezer.freeze() diff --git a/freeze.py b/freeze.py index a215bea..fc2ec5b 100644 --- a/freeze.py +++ b/freeze.py @@ -1,7 +1,7 @@ -from app import app # Import your Flask app from app.py from flask_frozen import Freezer +from app import app freezer = Freezer(app) -if __name__ == '__main__': - freezer.freeze() # This will generate the static files +if __name__ == "__main__": + freezer.freeze() diff --git a/posts/my-first-post.html b/posts/my-first-post.html new file mode 100644 index 0000000..4ac0a1e --- /dev/null +++ b/posts/my-first-post.html @@ -0,0 +1,2 @@ +

My First Post

+

This is the content of my first blog post. It's awesome!

diff --git a/static/.DS_Store b/static/.DS_Store index 58e7e2e..dbbf3fd 100644 Binary files a/static/.DS_Store and b/static/.DS_Store differ diff --git a/static/css/style.css b/static/css/style.css index b565185..05121ee 100755 --- a/static/css/style.css +++ b/static/css/style.css @@ -468,6 +468,17 @@ nav { padding: 0 3px; } +h1, +h2, +footer { + margin-left: 30px; + font-family: 'Inter', 'Source Han Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; +} + +main { + margin-top: 70px; +} + /* media queries */ @media (prefers-color-scheme: dark) { diff --git a/static/fonts/SourceHanSansCN-Bold-min.woff2 b/static/fonts/SourceHanSansCN-Bold-min.woff2 new file mode 100755 index 0000000..cd56998 Binary files /dev/null and b/static/fonts/SourceHanSansCN-Bold-min.woff2 differ diff --git a/static/fonts/SourceHanSansCN-Regular-min.woff2 b/static/fonts/SourceHanSansCN-Regular-min.woff2 new file mode 100755 index 0000000..95f836f Binary files /dev/null and b/static/fonts/SourceHanSansCN-Regular-min.woff2 differ diff --git a/templates/blog.html b/templates/blog.html new file mode 100644 index 0000000..0af88c1 --- /dev/null +++ b/templates/blog.html @@ -0,0 +1,16 @@ +{% extends "layout.html" %} + +{% block content %} +

Welcome to My Blog

+ +
+ {% for post in posts %} +
+

{{ post.title }}

+
+ {{ post.content | safe }} +
+
+ {% endfor %} +
+{% endblock %} diff --git a/templates/index.html b/templates/index.html index 413faa9..a45e7c6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,8 +1,10 @@ {% extends "layout.html" %} -{% block title %}Home - My Frozen Flask App{% endblock %} +{% block title %}Jerry's blog...{% endblock %} {% block content %} -

Welcome to the Homepage!

-

This is the content specific to the homepage.

+

Jerry's blog

+

This is the content specific to the homepage.

+

This is the content specific to the homepage.

+

This is the content specific to the homepage.

{% endblock %} \ No newline at end of file diff --git a/templates/layout.html b/templates/layout.html index f9f934f..e71c01d 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -28,6 +28,8 @@ + + @@ -38,65 +40,9 @@
-
things I love
+
publications
- Apple -
-
- Friends -
-
- Music -
-
- Swiftie -
-
festivity
-
- Christmas -
- -
other stuff
-
- About -
- - - -
- Clock -
-
- Contact -
-
- Develop -
- -
- Gallery -
- - -
- Survey + Blog
diff --git a/templates/post.html b/templates/post.html new file mode 100644 index 0000000..bd3f67f --- /dev/null +++ b/templates/post.html @@ -0,0 +1,15 @@ +{% extends "layout.html" %} + +{% block title %} +{{ title }} - My Blog +{% endblock %} + +{% block content %} +

{{ title }}

+ +
+ {{ content | safe }} +
+ +Back to Blog +{% endblock %} \ No newline at end of file