Browse Source

Adjust for frozen-flask

Changes:
========
* adjust URL convention to include '.html' (except on index)
* rename 'templates/blog' directory to less ambiguous 'templates/posts'
main
Marie-Joseph 12 months ago
parent
commit
fd75dacebe
  1. 2
      app.hy
  2. 7
      blog.hy
  3. 9
      freeze.hy
  4. 23
      static/styles.css
  5. 4
      templates/blog-post.html
  6. 2
      templates/layout.html
  7. 0
      templates/posts/2021-04-29.html
  8. 0
      templates/posts/2021-05-04.html
  9. 0
      templates/posts/LICENSE.md

2
app.hy

@ -30,7 +30,7 @@ This is the main Flask application for https://tree.st
"""
(render-template "index.html")))
#@((.route app "/blog" :methods ["GET" "POST"])
#@((.route app "/blog.html" :methods ["GET" "POST"])
#@((.route app "/blog/<string:post_name>")
(defn blog [[post-name None]]
"""

7
blog.hy

@ -8,7 +8,7 @@ Blog helper functions
;; These are global variables because they are useful
;; throughout the file. They should be considered private.
(setv _posts-prefix "templates/")
(setv _posts-dir "blog/")
(setv _posts-dir "posts/")
(setv _posts-suffix ".html")
(defn test-retrieve-posts [^str post-name]
@ -31,7 +31,7 @@ Blog helper functions
(lfor post (listdir (+ _posts-prefix _posts-dir))
:if (.endswith post _posts-suffix)
(+ _posts-dir post))
[(+ _posts-dir post-name _posts-suffix)]))
[(+ _posts-dir post-name)]))
(defn post-exists? [^str post-name]
"""
@ -40,5 +40,4 @@ Blog helper functions
"""
(exists (+ _posts-prefix
_posts-dir
post-name
_posts-suffix)))
post-name)))

9
freeze.hy

@ -0,0 +1,9 @@
"""
A script whose execution freezes the website into a static format
"""
(import [flask-frozen [Freezer]])
(import [app [app]])
(if (= __name__ "__main__")
(.freeze (Freezer app)))

23
static/styles.css

@ -1,12 +1,16 @@
/* General styling */
:root {
--text-color: #ffffea;
}
* {
box-sizing: border-box;
}
html {
font-family: sans-serif;
background-color: tan;
font-family: sans-serif;
}
body {
@ -30,36 +34,37 @@ nav {
}
.nav-item {
padding: .25rem;
color: black;
padding: .25rem;
}
/* Content styling */
main {
width: 75%;
max-width: 50rem;
background-color: brown;
margin: 0 auto 0 auto;
max-width: 50rem;
padding: 3rem;
text-align: center;
background-color: brown;
width: 75%;
}
footer {
text-align: center;
margin-top: 3rem;
text-align: center;
}
/* Blog styling */
.blog-post {
text-align: left;
color: var(--text-color);
border-bottom: dotted;
padding: 0rem 0rem 2.5rem 1rem;
text-align: left;
}
.blog-title a {
color: black;
.blog-post a {
color: var(--text-color);
}
.blog-show-more {

4
templates/blog-post.html

@ -1,8 +1,8 @@
<h2 class="blog-title">
<a href="{{ url_for('blog', post_name=self.date()) }}">
<a href="{{ url_for('blog', post_name=self.date()+'.html') }}" tabindex="0">
{% block title %}{% endblock %}
</a>
</h2>
<h4 class="blog-date">{% block date %}{% endblock %}</h4>
<summary class="blog-summary"><p>{% block summary %}{% endblock %}</p></summary>
<summary class="blog-summary" tabindex="0"><p>{% block summary %}{% endblock %}</p></summary>
<details class="blog-content">{% block content %}{% endblock %}</details>

2
templates/layout.html

@ -8,7 +8,7 @@
<link href="{{ url_for('static', filename='favicon.ico') }}" rel="shortcut icon">
<title>Trees' Street</title>
</head>
<body>
<body tabindex="0">
<header>
<h1>You find yourself on a winding path deep in the forest...</h1>
<nav>

0
templates/blog/2021-04-29.html → templates/posts/2021-04-29.html

0
templates/blog/2021-05-04.html → templates/posts/2021-05-04.html

0
templates/blog/LICENSE.md → templates/posts/LICENSE.md