1
1
Fork 0

Template reorganization,

floating notifications,
user settings - more to come later
dev
Jan Kužílek 5 years ago
parent 22e6b0db9e
commit 1c228fa781

@ -28,7 +28,7 @@ def create_app():
POST_LIST_THUMB_HEIGHT=200,
POST_UPLOADS=os.path.join(app.instance_path, 'post'),
INSTANCE_NAME='YaDc',
POSTS_PER_PAGE=4,
POSTS_PER_PAGE=8,
SQLALCHEMY_ECHO=True,
)
@ -51,10 +51,11 @@ def create_app():
admin.add_view(ModelView(models.Tag, db.session, endpoint='admin_tag'))
admin.add_view(ModelView(models.Comment, db.session, endpoint='admin_comment'))
from yadc.bp import main, post, auth
from yadc.bp import main, post, auth, user
app.register_blueprint(main.bp)
app.register_blueprint(post.bp, url_prefix='/post')
app.register_blueprint(auth.bp, url_prefix='/user')
app.register_blueprint(auth.bp, url_prefix='/auth')
app.register_blueprint(user.bp, url_prefix='/user')
login.login_view = 'auth.login'
from yadc import utils

@ -35,7 +35,7 @@ def login():
return redirect(nextpage())
return render_template('login.html', form=form)
return render_template('auth/login.html', form=form)
@bp.route('/logout/')
def logout():
@ -60,7 +60,7 @@ def reset_password():
flash('Password successfully reset. Check your email.')
return redirect(url_for('.login'))
return render_template('reset_password.html', form=form)
return render_template('auth/reset_password.html', form=form)
@bp.route('/register/', methods=['GET', 'POST'])
@ -79,4 +79,4 @@ def register():
flash('Your account has been successfully registered. You can now login.')
return redirect(url_for('.login'))
return render_template('register.html', form=form)
return render_template('auth/register.html', form=form)

@ -32,7 +32,7 @@ def uploaded_thumb(*args, **kwargs):
# @bp.route('/threads')
# def threads():
# return render_template('index.html')
# return render_template('post/index.html')
# @bp.route('/user/show/<username>')
# def user_profile(username):

@ -63,7 +63,7 @@ def posts(page):
# flash(posts.items)
# flash(tags)
return render_template('index.html', posts=posts.items, tags=tags, pagination=posts)
return render_template('post/index.html', posts=posts.items, tags=tags, pagination=posts)
@bp.route('/show/<id>')
def post_show(id):
@ -80,7 +80,7 @@ def post_show(id):
form = CommentForm()
form.post_id.data = post.id
return render_template('post.html', post=post, tags=post.tags, comments=post.comments, comment_form=form)
return render_template('post/post.html', post=post, tags=post.tags, comments=post.comments, comment_form=form)
@bp.route('/upload', methods=['GET', 'POST'])
@login_required
@ -115,9 +115,10 @@ def upload():
flash('Successfully submitted {}'.format(str(post)))
return redirect(url_for('.upload'))
#return redirect(url_for('.upload'))
return redirect(url_for('.posts'))
return render_template('upload.html', form=form)
return render_template('post/upload.html', form=form)
@bp.route('comment', methods=['POST'])
@login_required

@ -0,0 +1,29 @@
from flask import (Blueprint, abort, current_app, flash, redirect,
render_template, request, send_from_directory, url_for)
from flask_login import current_user, login_required
from yadc.forms import ChangePassForm
bp = Blueprint('user', __name__)
@bp.route('/<username>')
def profile(username):
return "OH HELLO, HERETIC!"
@bp.route('/settings')
@login_required
def settings():
form = ChangePassForm(request.form)
if request.method == 'POST' and form.validate():
user = current_user
if not user.check_password(form.password_current.data):
flash('Incorrect password')
return redirect(url_for('.settings'))
user.create_password(form.password.data)
db.session.commit()
flash('Password changed successfully.')
return redirect(url_for('.settings'))
return render_template('manage/user.html', form=form)

@ -83,4 +83,10 @@ class UploadForm(CSRFForm):
class CommentForm(CSRFForm):
post_id = HiddenField(validators=[DataRequired()])
content = TextAreaField('Comment', validators=[DataRequired()])
submit = SubmitField('Send')
submit = SubmitField('Send')
class ChangePassForm(CSRFForm):
password_current = PasswordField('Current password', validators=[DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
password_again = PasswordField('Repeat password', validators=[DataRequired(), EqualTo('password')])
submit = SubmitField('Change password')

@ -14,18 +14,8 @@ $header-bg-color: #222;
$nav-bg-color: #111d;//#20141fd0;
$nav-bg-color_hover: #333;//#20141fa0;
// $desktop-width: 560px;
// @mixin mobile {
// @media only screen and (max-width: #{$desktop-width - 1px}) {
// @content;
// }
// }
// @mixin desktop {
// @media only screen and (min-width: #{$desktop-width}) {
// @content;
// }
// }
//$notif-bg-color: #542772d0;
$notif-bg-color: #000c;
body {
@ -204,14 +194,56 @@ header {
}
}
.flash_msgs {
display: flex;
flex-flow: column-reverse nowrap;
position: absolute;
z-index: 20;
// top: 0;
//left: 0;
bottom: 0;
right: 0;
margin: 0;
// margin-top: 20px;
padding: 10px;
//max-width: 1300;
font-size: .9em;
pointer-events: none;
> li {
//width: 300px;
//margin: 0 auto;
width: 250px;
padding: 10px;
&:not(:first-child) {
margin-bottom: 10px;
}
background-color: $notif-bg-color;
overflow: hidden;
@keyframes fade {
0%,100% { opacity: 0 }
20%,80% { opacity: 1 }
}
opacity: 0;
animation: fade 7s normal;
}
}
.main_wrap {
$bp-desktop: ">=desktop";
$bp-tablet: "<desktop";
// margin: 0 auto;
// max-width: 1200px;
margin: 0 auto;
max-width: 1300px;
$main-wrap-padding: 8px;
padding: $main-wrap-padding;

@ -72,4 +72,12 @@
<h3>Edit</h3>
<a href="">edit?</a>
</article>
{% endmacro %}
{% macro render_sidenav(sidenav_links) %}
<article class="sidenav">
{% for class, (name, link) in sidenav_links.items() %}
<a href="{{ link }}">{{ name }}</a>
{% endfor %}
</article>
{% endmacro %}

@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'layout/base.html' %}
{% from "_formhelpers.html" import errors %}
{% block content %}

@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'layout/base.html' %}
{% from "_formhelpers.html" import errors %}
{% block content %}

@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'layout/base.html' %}
{% from "_formhelpers.html" import errors %}
{% block content %}

@ -46,7 +46,7 @@
{% with msgs = get_flashed_messages() %}
{% if msgs %}
<ul>
<ul class="flash_msgs" id="noti">
{% for msg in msgs %}
<li>{{ msg }}</li>
{% endfor %}

@ -0,0 +1,13 @@
{% extends 'layout/base.html' %}
{% from '_includes.html' import render_sidenav with context %}
{% block content %}
<div class="important_subwrap">
<section class="side_panel">
{{ render_sidenav({"speedtest": ("Speedtest", "http://speedtest.cesnet.cz")}) }}
</section>
<section class="{{ setting_class }}">
{% block setting_content %}{% endblock %}
</section>
</div>
{% endblock content %}

@ -0,0 +1,24 @@
{% extends 'layout/settings.html' %}
{% from "_formhelpers.html" import errors %}
{% block setting_content %}
<form action="" method="post">
<h3>Change password</h3>
{{ form.csrf_token }}
<div>
{{ form.password_current(placeholder="Current password") }}
{{ errors(form.password_current) }}
</div>
<div>
{{ form.password(placeholder="Password") }}
{{ errors(form.password) }}
</div>
<div>
{{ form.password_again(placeholder="Repeat password") }}
{{ errors(form.password_again) }}
</div>
<div>
{{ form.submit() }}
</div>
</form>
{% endblock %}

@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'layout/base.html' %}
{% from '_includes.html' import render_tags, render_pagination with context %}
{% block content %}

@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'layout/base.html' %}
{% from '_includes.html' import render_tags, render_comments, render_post_edit with context %}
{% from "_formhelpers.html" import errors %}

@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'layout/base.html' %}
{% from "_formhelpers.html" import errors %}
{% block content %}
Loading…
Cancel
Save