started adding the comment thing
This commit is contained in:
parent
006279b537
commit
f569620fce
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@ __pycache__
|
||||
|
||||
docker-compose.yaml
|
||||
*.sh
|
||||
*.ini
|
||||
|
||||
# Ignore images in posts
|
||||
*.jpg
|
||||
|
||||
18
app/app.py
18
app/app.py
@ -3,13 +3,19 @@ import configparser
|
||||
import random
|
||||
|
||||
import flask
|
||||
import flask_wtf.csrf
|
||||
import flask_session
|
||||
import waitress
|
||||
import markdown
|
||||
|
||||
from post import Post
|
||||
import comment
|
||||
|
||||
app = flask.Flask(__name__, static_url_path='', static_folder='static')
|
||||
|
||||
csrf = flask_wtf.csrf.CSRFProtect()
|
||||
csrf.init_app(app)
|
||||
|
||||
CONFIG_PATH = "./config.ini"
|
||||
config = configparser.ConfigParser()
|
||||
config.read(CONFIG_PATH)
|
||||
@ -66,14 +72,20 @@ def index():
|
||||
# Get posts
|
||||
posts = get_posts()
|
||||
|
||||
post_bodies = []
|
||||
# Get Comments
|
||||
comments = []
|
||||
|
||||
posts_and_comments = []
|
||||
for post in posts:
|
||||
post_bodies.append(post.body)
|
||||
posts_and_comments.append((post.body, comments))
|
||||
|
||||
# Get status
|
||||
status = get_status()
|
||||
|
||||
return flask.render_template('index.html', posts=post_bodies, status=status)
|
||||
# Setup Comment Form
|
||||
form = comment.CommentForm()
|
||||
|
||||
return flask.render_template('index.html', posts=posts_and_comments, status=status, form=form)
|
||||
|
||||
# Games Page
|
||||
@app.route('/games/')
|
||||
|
||||
14
app/comment.py
Normal file
14
app/comment.py
Normal file
@ -0,0 +1,14 @@
|
||||
import flask
|
||||
import flask_session
|
||||
import flask_wtf
|
||||
import wtforms
|
||||
|
||||
|
||||
|
||||
|
||||
class CommentForm(flask_wtf.FlaskForm):
|
||||
textbox = wtforms.TextAreaField()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
[POSTS]
|
||||
posts_folder=./posts
|
||||
|
||||
[STATUS]
|
||||
status_file=./resources/status.text
|
||||
|
||||
[NETWORK]
|
||||
PORT=1111
|
||||
DEV=0
|
||||
@ -172,3 +172,26 @@ a:hover {
|
||||
line-height: 2.25;
|
||||
text-indent: 3em;
|
||||
}
|
||||
|
||||
.comment-container {
|
||||
background-color: var(--primary40);
|
||||
border-style: var(--borders-style);
|
||||
border-radius: var(--border-radius);
|
||||
|
||||
padding: 1em;
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.comment-editor input {
|
||||
width: 100%;
|
||||
padding: 3em 0;
|
||||
line-height: 140%;
|
||||
|
||||
border-style: solid;
|
||||
/* border-color: var(--secondary50); */
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
|
||||
.comment-editor input:focus {
|
||||
border: 3px solid var(--accent);
|
||||
}
|
||||
|
||||
@ -25,7 +25,24 @@
|
||||
<!-- Get it? D-Log? Like digital log? -->
|
||||
<div class="dlog">
|
||||
{% for post in posts %}
|
||||
<div class="post">{{ post|safe }}</div>
|
||||
<div class="post">
|
||||
{{ post[0]|safe }}
|
||||
<div class="comment-container">
|
||||
{% for comment in post[1] %}
|
||||
<div class="comment">{{ comment|safe }}</div>
|
||||
{% endfor %}
|
||||
{% if user %}
|
||||
<div class="comment-editor">
|
||||
<h3>{{ user }}</h3>
|
||||
<form method="post" action="/comment">
|
||||
<!-- <input type="text" class="commenter"> -->
|
||||
{{ form.textbox }}
|
||||
<input type="submit" value="Save">
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
Markdown==3.5.2
|
||||
Flask==2.2.3
|
||||
waitress==2.1.2
|
||||
Werkzeug==2.2.3
|
||||
Werkzeug==2.2.3
|
||||
Flask-Session==0.5.0
|
||||
Flask-WTF==1.1.1
|
||||
Loading…
x
Reference in New Issue
Block a user