Add theme
This commit is contained in:
4
main.py
4
main.py
@@ -46,9 +46,13 @@ def comment(comment_id):
|
||||
user_id = session.get('user_id')
|
||||
thread_id, parent_id, title, comments = db.get_subcomments(comment_id)
|
||||
comments = create_comment_tree(comments)
|
||||
reply_comment, = comments
|
||||
comments = reply_comment.children
|
||||
reply_comment.children = []
|
||||
return render_template(
|
||||
'comments.html',
|
||||
title = title,
|
||||
reply_comment = reply_comment,
|
||||
comments = comments,
|
||||
parent_id = parent_id,
|
||||
thread_id = thread_id,
|
||||
|
||||
91
static/theme.css
Normal file
91
static/theme.css
Normal file
@@ -0,0 +1,91 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: sans-serif;
|
||||
background-color: #f2f2e2;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
body > * {
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
nav {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
overflow-x: auto;
|
||||
background-color: #ffca4b;
|
||||
}
|
||||
|
||||
nav > * {
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
padding: 20px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
main {
|
||||
width: 80%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
tr:not(:last-child) {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 50em;
|
||||
height: 15em;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
width: 50em;
|
||||
font-family: monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.logo {
|
||||
margin: 0;
|
||||
padding: 5px;
|
||||
padding-left: 15px;
|
||||
font-size: 3em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
table.form {
|
||||
border-collapse: unset;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
table.form > * > tr > td, th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.comment {
|
||||
margin-left: 20px;
|
||||
padding-left: 10px;
|
||||
border-left: 1px dotted;
|
||||
}
|
||||
|
||||
.flash.success {
|
||||
background-color: #ff4646;
|
||||
border-radius: 5px;
|
||||
padding: 8px;
|
||||
}
|
||||
@@ -1,23 +1,27 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta content="utf-8" http-equiv="encoding">
|
||||
<link rel=stylesheet href="{{ url_for('static', filename='theme.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<a href="{{ url_for('index') }}">Home</a>
|
||||
<a class=logo href="{{ url_for('index') }}">A</a>
|
||||
<div style="margin:auto"></div>
|
||||
{% if 'user_id' in session %}
|
||||
<a href="{{ url_for('user_edit') }}">{{ session.get('username', '???') }}</a>
|
||||
|
|
||||
<span>|</span>
|
||||
<a href="{{ url_for('logout') }}">Logout</a>
|
||||
{% else %}
|
||||
<a href="{{ url_for('login') }}">Login</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
<main>
|
||||
<h1>{{ title }}</h1>
|
||||
{% for category, msg in get_flashed_messages(True) %}
|
||||
<p>{{ category}}: {{ msg }}</p>
|
||||
<p class="flash {{ category }}">{{ msg }}</p>
|
||||
{% endfor %}
|
||||
<main>
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</body>
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
{% macro render_comment(comment) %}
|
||||
<div style="margin-left:20px">
|
||||
<p><i>{{ comment.author }}</i></p>
|
||||
{% macro render_comment_pre(comment) %}
|
||||
<div class=comment>
|
||||
<p><sub><i>{{ comment.author }}</i></sub></p>
|
||||
<p>{{ comment.text }}</p>
|
||||
<sup><a href="{{ url_for("comment", comment_id = comment.id) }}">reply</a></sup>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_comment_post(comment) %}
|
||||
{% for c in comment.children %}
|
||||
{{ render_comment(c) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro render_comment(comment) %}
|
||||
{{ render_comment_pre(comment) }}
|
||||
<sup><a href="{{ url_for("comment", comment_id = comment.id) }}">reply</a></sup>
|
||||
{{ render_comment_post(comment) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro reply() %}
|
||||
{% if 'user_id' in session %}
|
||||
<form method="post" action="comment/">
|
||||
<textarea name="text"></textarea>
|
||||
<input type="submit" value="Post comment">
|
||||
<p><textarea name="text"></textarea></p>
|
||||
<p><input type="submit" value="Post comment"></p>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends 'base.html' %}
|
||||
{% from 'comment.html' import render_comment, reply %}
|
||||
{% from 'comment.html' import render_comment, render_comment_pre, render_comment_post, reply %}
|
||||
|
||||
{% block content %}
|
||||
<sup><a href="{{ url_for('thread', thread_id = thread_id) }}">thread</a></sup>
|
||||
@@ -7,9 +7,14 @@
|
||||
<sup><a href="../{{ parent_id }}">parent</a></sup>
|
||||
{% endif %}
|
||||
|
||||
{{ render_comment_pre(reply_comment) }}
|
||||
|
||||
{{ reply() }}
|
||||
|
||||
{% for c in comments %}
|
||||
{{ render_comment(c) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ render_comment_post(reply_comment) }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
{% block content %}
|
||||
<p>Are you sure you want to delete "{{ thread_title }}"?</p>
|
||||
<form method="post" action="../delete">
|
||||
<p>
|
||||
<form method="post" action="../delete" style=inline>
|
||||
<input type="submit" value="Yes">
|
||||
</form>
|
||||
<form method="get" action="..">
|
||||
</form>
|
||||
<form method="get" action=".." style=inline>
|
||||
<input type="submit" value="No">
|
||||
</form>
|
||||
</form>
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<ul>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Forum</th>
|
||||
</tr>
|
||||
{% for id, name, description in subforums %}
|
||||
<li><a href="{{ url_for('subforum', forum_id = id) }}">{{ name }} - {{ description }}</a></li>
|
||||
<tr>
|
||||
<td><a href="{{ url_for('subforum', forum_id = id) }}"><b>{{ name }}</b> - {{ description }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,8 +2,16 @@
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
<input type="text" name="title">
|
||||
<textarea name="text"></textarea>
|
||||
<input type="submit" value="Post">
|
||||
<table class=form>
|
||||
<tr>
|
||||
<td>Title</td>
|
||||
<td><input type="text" name="title"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Text</td>
|
||||
<td><textarea name="text"></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p><input type="submit" value="Post"></p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
|
||||
{% block content %}
|
||||
<p>{{ description }}</p>
|
||||
<a href="{{ url_for('new_thread', forum_id = forum_id) }}">Create thread</a>
|
||||
<ul>
|
||||
<p><a href="{{ url_for('new_thread', forum_id = forum_id) }}">Create thread</a></p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Topic</th>
|
||||
</tr>
|
||||
{% for id, title in threads %}
|
||||
<li><a href="{{ url_for('thread', thread_id = id) }}">{{ title }}</a></li>
|
||||
<tr>
|
||||
<th><a href="{{ url_for('thread', thread_id = id) }}">{{ title }}</a></th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
<p>{{ author }} - rjgoire</p>
|
||||
<sup><i>{{ author }}</i></sup>
|
||||
<p>{{ text }}</p>
|
||||
|
||||
{{ reply() }}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
<p>{{ name }}</p>
|
||||
<textarea name="about">{{ about }}</textarea>
|
||||
<input type="submit" value="Update">
|
||||
<p><textarea name="about">{{ about }}</textarea></p>
|
||||
<p><input type="submit" value="Update"></p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user