summaryrefslogtreecommitdiffstats
path: root/flaskr/templates
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2023-10-28 11:44:09 -0500
committerMitsuo Tokumori <[email protected]>2023-10-28 11:44:09 -0500
commitcafc557c6820e1808b1e4cf71f58ff99b97ca545 (patch)
tree486f6a0f082bbc3e744cd2f59ab1704ff5edc416 /flaskr/templates
parent72d24988ce8bcf1e5fe841d0ef47532bea08a432 (diff)
downloadustayml-cafc557c6820e1808b1e4cf71f58ff99b97ca545.tar.gz
ustayml-cafc557c6820e1808b1e4cf71f58ff99b97ca545.tar.bz2
ustayml-cafc557c6820e1808b1e4cf71f58ff99b97ca545.zip
Add blueprint blog
Diffstat (limited to 'flaskr/templates')
-rw-r--r--flaskr/templates/blog/create.html15
-rw-r--r--flaskr/templates/blog/index.html30
-rw-r--r--flaskr/templates/blog/update.html20
3 files changed, 65 insertions, 0 deletions
diff --git a/flaskr/templates/blog/create.html b/flaskr/templates/blog/create.html
new file mode 100644
index 0000000..88e31e4
--- /dev/null
+++ b/flaskr/templates/blog/create.html
@@ -0,0 +1,15 @@
+{% extends 'base.html' %}
+
+{% block header %}
+ <h1>{% block title %}New Post{% endblock %}</h1>
+{% endblock %}
+
+{% block content %}
+ <form method="post">
+ <label for="title">Title</label>
+ <input name="title" id="title" value="{{ request.form['title'] }}" required>
+ <label for="body">Body</label>
+ <textarea name="body" id="body">{{ request.form['body'] }}</textarea>
+ <input type="submit" value="Save">
+ </form>
+{% endblock %}
diff --git a/flaskr/templates/blog/index.html b/flaskr/templates/blog/index.html
new file mode 100644
index 0000000..0d3ed17
--- /dev/null
+++ b/flaskr/templates/blog/index.html
@@ -0,0 +1,30 @@
+{% extends 'base.html' %}
+
+
+{% block header %}
+ <h1>{% block title %}Posts{% endblock %}</h1>
+ {% if g.user %}
+ <a class="action" href="{{ url_for('blog.create') }}">New</a>
+ {% endif %}
+{% endblock %}
+
+{% block content %}
+ {% for post in posts %}
+ <article class="post">
+ <header>
+ <div>
+ <h1>{{ post['title'] }}</h1>
+ <div class="about">by {{ post['username'] }} on {{ post['created'].strftime('%Y-%m-%d') }}</div>
+ </div>
+ {% if g.user['id'] == post['author_id'] %}
+ <a class="action" href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
+ {% endif %}
+ </header>
+ <p class="body">{{ post['body'] }}</p>
+ </article>
+ {% if not loop.last %}
+ {# Separate posts with a line #}
+ <hr>
+ {% endif %}
+ {% endfor %}
+{% endblock %} \ No newline at end of file
diff --git a/flaskr/templates/blog/update.html b/flaskr/templates/blog/update.html
new file mode 100644
index 0000000..7420f57
--- /dev/null
+++ b/flaskr/templates/blog/update.html
@@ -0,0 +1,20 @@
+{% extends 'base.html' %}
+
+{% block header %}
+ <h1>{% block title %}Edit "{{ post['title'] }}"{% endblock %}</h1>
+{% endblock %}
+
+{% block content %}
+ <form method="post">
+ <label for="title">Title</label>
+ <input name="title" id="title"
+ value="{{ request.form['title'] or post['title'] }}" required>
+ <label for="body">Body</label>
+ <textarea name="body" id="body">{{ request.form['body'] or post['body'] }}</textarea>
+ <input type="submit" value="Save">
+ </form>
+ <hr>
+ <form action="{{ url_for('blog.delete', id=post['id']) }}" method="post">
+ <input class="danger" type="submit" value="Delete" onclick="return confirm('Are you sure?');">
+ </form>
+{% endblock %} \ No newline at end of file