mobile style improvements, block registration with date unset

This commit is contained in:
Yusur 2025-07-07 16:47:52 +02:00
parent 66471558b9
commit 793c0b6612
4 changed files with 75 additions and 6 deletions

View file

@ -1,6 +1,8 @@
@import "constants.sass" @import "constants.sass"
body
margin: 0
.content-container .content-container
display: flex display: flex
@ -18,6 +20,7 @@
main main
min-height: 70vh min-height: 70vh
margin: 12px auto
// __ header styles __ // // __ header styles __ //
@ -28,7 +31,6 @@ header.header
overflow: hidden overflow: hidden
height: 3em height: 3em
padding: .75em 1.5em padding: .75em 1.5em
margin: -12px
line-height: 1 line-height: 1
h1 h1
margin: 0 margin: 0

View file

@ -10,7 +10,58 @@
grid-template-columns: 1fr 1fr grid-template-columns: 1fr 1fr
.nomobile .nomobile
display: none display: none !important
body
position: relative
footer.mobile-nav
position: sticky
bottom: 0
left: 0
width: 100%
overflow: hidden
margin: 0
padding: 0
background-color: var(--background)
box-shadow: 0 0 6px var(--border)
z-index: 150
> ul
display: flex
list-style: none
margin: 0
padding: 0
flex-direction: row
align-items: stretch
justify-content: stretch
> li
flex: 1
padding: .5em
margin: 0
text-align: center
a
text-decoration: none
.icon
font-size: 2rem
.content-nav
margin: 1em
width: unset
header.header h1
margin-top: 4px
margin-left: 6px
.content-header
text-align: center
.big-search-bar form
flex-direction: column
[type="submit"]
width: unset
margin: 12px auto
@media screen and (max-width: 960px) @media screen and (max-width: 960px)
.header-username .header-username
@ -33,4 +84,4 @@
@media screen and (min-width: 801px) @media screen and (min-width: 801px)
.mobileonly .mobileonly
display: none display: none !important

View file

@ -46,11 +46,11 @@
{% if g.no_user %} {% if g.no_user %}
<!-- no user --> <!-- no user -->
{% elif current_user.is_authenticated %} {% elif current_user.is_authenticated %}
<li> <li class="nomobile">
<a class="round border-accent" href="/create" title="Create a post"> <a class="round border-accent" href="/create" title="Create a post">
<i class="icon icon-add"></i> <i class="icon icon-add"></i>
<span class="a11y">create</span> <span class="a11y">create</span>
<span class="nomobile">New post</span> <span>New post</span>
</a> </a>
</li> </li>
<li><a href="{{ current_user.url() }}" title="{{ current_user.handle() }}'s profile">{{ icon('profile')}}<span class="a11y">profile</span></a> <li><a href="{{ current_user.url() }}" title="{{ current_user.handle() }}'s profile">{{ icon('profile')}}<span class="a11y">profile</span></a>
@ -99,6 +99,17 @@
<li><a href="https://github.com/sakuragasaki46/freak">GitHub</a></li> <li><a href="https://github.com/sakuragasaki46/freak">GitHub</a></li>
</ul> </ul>
</footer> </footer>
{% if current_user and current_user.is_authenticated %}
<footer class="mobile-nav mobileonly">
<ul>
<li><a href="/" title="Homepage">{{ icon('home') }}</a></li>
<li><a href="/search" title="Search">{{ icon('search') }}</a></li>
<li><a href="/create" title="Create">{{ icon('add') }}</a></li>
<li><a href="{{ current_user.url() }}" title="Messages">{{ icon('message') }}</a></li>
<li><a href="https://trollface.dk" title="Notifications">{{ icon('notification') }}</a></li>
</ul>
</footer>
{% endif %}
<script> <script>
function changeAccentColorTime() { function changeAccentColorTime() {
let hours = (new Date).getHours(); let hours = (new Date).getHours();

View file

@ -4,6 +4,7 @@ import datetime
from typing import Mapping from typing import Mapping
from flask import Blueprint, abort, render_template, request, redirect, flash from flask import Blueprint, abort, render_template, request, redirect, flash
from flask_login import login_required, login_user, logout_user, current_user from flask_login import login_required, login_user, logout_user, current_user
from werkzeug.exceptions import Forbidden
from ..models import REPORT_REASONS, db, User from ..models import REPORT_REASONS, db, User
from ..utils import age_and_days from ..utils import age_and_days
from sqlalchemy import select, insert from sqlalchemy import select, insert
@ -53,9 +54,13 @@ def validate_register_form() -> dict:
try: try:
f['gdpr_birthday'] = datetime.date.fromisoformat(request.form['birthday']) f['gdpr_birthday'] = datetime.date.fromisoformat(request.form['birthday'])
if age_and_days(f['gdpr_birthday']) == (0, 0):
# block bot attempt to register
raise Forbidden
if age_and_days(f['gdpr_birthday']) < (14,): if age_and_days(f['gdpr_birthday']) < (14,):
f['banned_at'] = datetime.datetime.now() f['banned_at'] = datetime.datetime.now()
f['banned_reason'] = REPORT_REASONS['underage'] f['banned_reason'] = REPORT_REASONS['underage']
except ValueError: except ValueError:
raise ValueError('Invalid date format') raise ValueError('Invalid date format')
f['username'] = request.form['username'].lower() f['username'] = request.form['username'].lower()