From be8aef16cc5fbca91613fc37d4d7a5d6f8789491 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Sun, 27 Nov 2022 14:17:38 -0800 Subject: [PATCH] scaffold routes --- nerochan/factory.py | 6 +- nerochan/routes/admin.py | 26 ++ nerochan/routes/api.py | 4 + nerochan/routes/artwork.py | 20 ++ nerochan/routes/main.py | 26 +- nerochan/routes/post.py | 27 --- nerochan/routes/user.py | 25 ++ nerochan/static/css/noty-relax.css | 46 ---- nerochan/static/css/noty.css | 222 ------------------ nerochan/static/css/noty.css.map | 1 - nerochan/templates/about.html | 8 + .../templates/{post => artwork}/show.html | 0 nerochan/templates/includes/head.html | 2 - nerochan/templates/user/edit.html | 8 + nerochan/templates/user/show.html | 8 + 15 files changed, 111 insertions(+), 318 deletions(-) create mode 100644 nerochan/routes/admin.py create mode 100644 nerochan/routes/artwork.py delete mode 100644 nerochan/routes/post.py create mode 100644 nerochan/routes/user.py delete mode 100644 nerochan/static/css/noty-relax.css delete mode 100644 nerochan/static/css/noty.css delete mode 100644 nerochan/static/css/noty.css.map create mode 100644 nerochan/templates/about.html rename nerochan/templates/{post => artwork}/show.html (100%) create mode 100644 nerochan/templates/user/edit.html create mode 100644 nerochan/templates/user/show.html diff --git a/nerochan/factory.py b/nerochan/factory.py index dba09be..e10ca08 100644 --- a/nerochan/factory.py +++ b/nerochan/factory.py @@ -2,6 +2,7 @@ from flask import Flask from flask_login import LoginManager from nerochan.cli import cli +from nerochan.routes import artwork def setup_db(app: Flask): @@ -27,12 +28,13 @@ def create_app(): return User.get_or_none(user_id) with app.app_context(): - from nerochan.routes import api, auth, post, main + from nerochan.routes import api, auth, main, artwork, user from nerochan import filters app.register_blueprint(main.bp) app.register_blueprint(api.bp) app.register_blueprint(auth.bp) - app.register_blueprint(post.bp) + app.register_blueprint(artwork.bp) + app.register_blueprint(user.bp) app.register_blueprint(filters.bp) return app diff --git a/nerochan/routes/admin.py b/nerochan/routes/admin.py new file mode 100644 index 0000000..aa2e00a --- /dev/null +++ b/nerochan/routes/admin.py @@ -0,0 +1,26 @@ +from flask import Blueprint, render_template, redirect, url_for, flash +from flask_login import login_required + +from nerochan.models import User + + +bp = Blueprint('admin', 'admin', url_prefix='/admin') + +@bp.route('/') +def main(handle: str): + user = User.select().where(User.handle == handle).first() + if not user: + flash('That user does not exist.', 'warning') + return redirect(url_for('main.index')) + return render_template( + 'user/show.html', + user=user + ) + +# approve artwork +# ban user +# hide artwork +# promote mod +# demote mod +# promote admin +# demote admin \ No newline at end of file diff --git a/nerochan/routes/api.py b/nerochan/routes/api.py index 8e1ca0f..415e2d0 100644 --- a/nerochan/routes/api.py +++ b/nerochan/routes/api.py @@ -9,3 +9,7 @@ def get_prices(): 'test': True, 'message': 'This is only a test.' }) + +# list users +# list artwork +# show leaderboard \ No newline at end of file diff --git a/nerochan/routes/artwork.py b/nerochan/routes/artwork.py new file mode 100644 index 0000000..135fd3a --- /dev/null +++ b/nerochan/routes/artwork.py @@ -0,0 +1,20 @@ +from flask import Blueprint, render_template, flash, redirect, url_for +from flask_login import login_required + +from nerochan.models import Content, User + + +bp = Blueprint('artwork', 'artwork', url_prefix='/artwork') + +@bp.route('/') +def show(artwork_id): + artwork = Content.get_or_none(artwork_id) + if not artwork: + flash('That artwork does not exist.', 'warning') + return redirect(url_for('main.index')) + return render_template('artwork/show.html', artwork=artwork) + +@bp.route('/new', methods=['GET', 'POST']) +@login_required +def create(): + return 'upload your artwork' \ No newline at end of file diff --git a/nerochan/routes/main.py b/nerochan/routes/main.py index 9f9835c..1b1fbf5 100644 --- a/nerochan/routes/main.py +++ b/nerochan/routes/main.py @@ -1,7 +1,4 @@ from flask import Blueprint, render_template -from flask_login import current_user - -from nerochan.models import * bp = Blueprint('main', 'main') @@ -9,22 +6,15 @@ bp = Blueprint('main', 'main') @bp.route('/') def index(): feed = dict() - # new_creators = User.select().where( - # User.roles.contains_any(UserRole.creator) - # ).order_by(User.register_date.desc()).execute() - # feed['new_creators'] = new_creators - # if current_user.is_authenticated: - # active_subscriptions = Subscription.select().where( - # Subscription.is_active == True, - # Subscription.backer == current_user - # ).order_by(Subscription.subscribe_date.desc()).execute() - # feed['active_subscriptions'] = active_subscriptions - # new_posts = Post.select().where( - # Post.hidden == False, - # Post.creator in [c.creator for c in active_subscriptions] - # ).order_by(Post.post_date.desc()).execute() - # feed['new_posts'] = new_posts return render_template( 'index.html', feed=feed ) + +@bp.route('/about') +def about(): + return render_template('about.html') + + +# most tipped artworks +# most tipped artists \ No newline at end of file diff --git a/nerochan/routes/post.py b/nerochan/routes/post.py deleted file mode 100644 index aa8fbe2..0000000 --- a/nerochan/routes/post.py +++ /dev/null @@ -1,27 +0,0 @@ -from flask import Blueprint, render_template, flash, redirect, url_for -from flask_login import current_user - -# from nerochan.models import Content, User - - -bp = Blueprint('post', 'post') - -# @bp.route('/post/') -# def show(post_id): -# post = TextPost.get_or_none(post_id) -# if post: -# if current_user.is_anonymous: -# flash('You must login to view this post.') -# return redirect(url_for('creator.show', username=post.creator.user.username)) -# user_subscriptions = Subscription.select().where( -# Subscription.active == True, -# Subscription.backer == current_user.backer_profile.first() -# ) -# if user_subscriptions: -# return render_template('post/show.html', post=post) -# else: -# flash('Viewing posts requires a subscription.') -# return redirect(url_for('creator.subscription', username=post.creator.user.username)) -# else: -# flash('That post does not exist.') -# return redirect(url_for('meta.index')) diff --git a/nerochan/routes/user.py b/nerochan/routes/user.py new file mode 100644 index 0000000..6cad558 --- /dev/null +++ b/nerochan/routes/user.py @@ -0,0 +1,25 @@ +from flask import Blueprint, render_template, redirect, url_for, flash +from flask_login import login_required + +from nerochan.models import User + + +bp = Blueprint('user', 'user') + +@bp.route('/user/') +def show(handle: str): + user = User.select().where(User.handle == handle).first() + if not user: + flash('That user does not exist.', 'warning') + return redirect(url_for('main.index')) + return render_template( + 'user/show.html', + user=user + ) + +@bp.route('/profile') +@login_required +def edit(): + return render_template( + 'user/edit.html' + ) \ No newline at end of file diff --git a/nerochan/static/css/noty-relax.css b/nerochan/static/css/noty-relax.css deleted file mode 100644 index f5f99ec..0000000 --- a/nerochan/static/css/noty-relax.css +++ /dev/null @@ -1,46 +0,0 @@ -.noty_theme__relax.noty_bar { - margin: 4px 0; - overflow: hidden; - border-radius: 2px; - position: relative; } - .noty_theme__relax.noty_bar .noty_body { - padding: 10px; } - .noty_theme__relax.noty_bar .noty_buttons { - border-top: 1px solid #e7e7e7; - padding: 5px 10px; } - -.noty_theme__relax.noty_type__alert, -.noty_theme__relax.noty_type__notification { - background-color: #fff; - border: 1px solid #dedede; - color: #444; } - -.noty_theme__relax.noty_type__warning { - background-color: #FFEAA8; - border: 1px solid #FFC237; - color: #826200; } - .noty_theme__relax.noty_type__warning .noty_buttons { - border-color: #dfaa30; } - -.noty_theme__relax.noty_type__error { - background-color: #FF8181; - border: 1px solid #e25353; - color: #FFF; } - .noty_theme__relax.noty_type__error .noty_buttons { - border-color: darkred; } - -.noty_theme__relax.noty_type__info, -.noty_theme__relax.noty_type__information { - background-color: #78C5E7; - border: 1px solid #3badd6; - color: #FFF; } - .noty_theme__relax.noty_type__info .noty_buttons, - .noty_theme__relax.noty_type__information .noty_buttons { - border-color: #0B90C4; } - -.noty_theme__relax.noty_type__success { - background-color: #BCF5BC; - border: 1px solid #7cdd77; - color: darkgreen; } - .noty_theme__relax.noty_type__success .noty_buttons { - border-color: #50C24E; } diff --git a/nerochan/static/css/noty.css b/nerochan/static/css/noty.css deleted file mode 100644 index ee33b8f..0000000 --- a/nerochan/static/css/noty.css +++ /dev/null @@ -1,222 +0,0 @@ -.noty_layout_mixin, #noty_layout__top, #noty_layout__topLeft, #noty_layout__topCenter, #noty_layout__topRight, #noty_layout__bottom, #noty_layout__bottomLeft, #noty_layout__bottomCenter, #noty_layout__bottomRight, #noty_layout__center, #noty_layout__centerLeft, #noty_layout__centerRight { - position: fixed; - margin: 0; - padding: 0; - z-index: 9999999; - -webkit-transform: translateZ(0) scale(1, 1); - transform: translateZ(0) scale(1, 1); - -webkit-backface-visibility: hidden; - backface-visibility: hidden; - -webkit-font-smoothing: subpixel-antialiased; - filter: blur(0); - -webkit-filter: blur(0); - max-width: 90%; } - -#noty_layout__top { - top: 0; - left: 5%; - width: 90%; } - -#noty_layout__topLeft { - top: 20px; - left: 20px; - width: 325px; } - -#noty_layout__topCenter { - top: 5%; - left: 50%; - width: 325px; - -webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__topRight { - top: 20px; - right: 20px; - width: 325px; } - -#noty_layout__bottom { - bottom: 0; - left: 5%; - width: 90%; } - -#noty_layout__bottomLeft { - bottom: 20px; - left: 20px; - width: 325px; } - -#noty_layout__bottomCenter { - bottom: 5%; - left: 50%; - width: 325px; - -webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__bottomRight { - bottom: 20px; - right: 20px; - width: 325px; } - -#noty_layout__center { - top: 50%; - left: 50%; - width: 325px; - -webkit-transform: translate(-webkit-calc(-50% - .5px), -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(calc(-50% - .5px), calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__centerLeft { - top: 50%; - left: 20px; - width: 325px; - -webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -#noty_layout__centerRight { - top: 50%; - right: 20px; - width: 325px; - -webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1); - transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); } - -.noty_progressbar { - display: none; } - -.noty_has_timeout.noty_has_progressbar .noty_progressbar { - display: block; - position: absolute; - left: 0; - bottom: 0; - height: 3px; - width: 100%; - background-color: #646464; - opacity: 0.2; - filter: alpha(opacity=10); } - -.noty_bar { - -webkit-backface-visibility: hidden; - -webkit-transform: translate(0, 0) translateZ(0) scale(1, 1); - -ms-transform: translate(0, 0) scale(1, 1); - transform: translate(0, 0) scale(1, 1); - -webkit-font-smoothing: subpixel-antialiased; - overflow: hidden; } - -.noty_effects_open { - opacity: 0; - -webkit-transform: translate(50%); - -ms-transform: translate(50%); - transform: translate(50%); - -webkit-animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; } - -.noty_effects_close { - -webkit-animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; } - -.noty_fix_effects_height { - -webkit-animation: noty_anim_height 75ms ease-out; - animation: noty_anim_height 75ms ease-out; } - -.noty_close_with_click { - cursor: pointer; } - -.noty_close_button { - position: absolute; - top: 2px; - right: 2px; - font-weight: bold; - width: 20px; - height: 20px; - text-align: center; - line-height: 20px; - background-color: rgba(0, 0, 0, 0.05); - border-radius: 2px; - cursor: pointer; - -webkit-transition: all .2s ease-out; - transition: all .2s ease-out; } - -.noty_close_button:hover { - background-color: rgba(0, 0, 0, 0.1); } - -.noty_modal { - position: fixed; - width: 100%; - height: 100%; - background-color: #000; - z-index: 10000; - opacity: .3; - left: 0; - top: 0; } - -.noty_modal.noty_modal_open { - opacity: 0; - -webkit-animation: noty_modal_in .3s ease-out; - animation: noty_modal_in .3s ease-out; } - -.noty_modal.noty_modal_close { - -webkit-animation: noty_modal_out .3s ease-out; - animation: noty_modal_out .3s ease-out; - -webkit-animation-fill-mode: forwards; - animation-fill-mode: forwards; } - -@-webkit-keyframes noty_modal_in { - 100% { - opacity: .3; } } - -@keyframes noty_modal_in { - 100% { - opacity: .3; } } - -@-webkit-keyframes noty_modal_out { - 100% { - opacity: 0; } } - -@keyframes noty_modal_out { - 100% { - opacity: 0; } } - -@keyframes noty_modal_out { - 100% { - opacity: 0; } } - -@-webkit-keyframes noty_anim_in { - 100% { - -webkit-transform: translate(0); - transform: translate(0); - opacity: 1; } } - -@keyframes noty_anim_in { - 100% { - -webkit-transform: translate(0); - transform: translate(0); - opacity: 1; } } - -@-webkit-keyframes noty_anim_out { - 100% { - -webkit-transform: translate(50%); - transform: translate(50%); - opacity: 0; } } - -@keyframes noty_anim_out { - 100% { - -webkit-transform: translate(50%); - transform: translate(50%); - opacity: 0; } } - -@-webkit-keyframes noty_anim_height { - 100% { - height: 0; } } - -@keyframes noty_anim_height { - 100% { - height: 0; } } - -/*# sourceMappingURL=noty.css.map*/ - - -/* Custom */ -.noty_body { - text-align: center; -} diff --git a/nerochan/static/css/noty.css.map b/nerochan/static/css/noty.css.map deleted file mode 100644 index 70e0c46..0000000 --- a/nerochan/static/css/noty.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":[],"names":[],"mappings":"","file":"noty.css","sourceRoot":""} \ No newline at end of file diff --git a/nerochan/templates/about.html b/nerochan/templates/about.html new file mode 100644 index 0000000..f966e48 --- /dev/null +++ b/nerochan/templates/about.html @@ -0,0 +1,8 @@ +{% extends 'includes/base.html' %} + +{% block content %} + +

about

+

nerochan, uwu

+ +{% endblock %} diff --git a/nerochan/templates/post/show.html b/nerochan/templates/artwork/show.html similarity index 100% rename from nerochan/templates/post/show.html rename to nerochan/templates/artwork/show.html diff --git a/nerochan/templates/includes/head.html b/nerochan/templates/includes/head.html index e8068a8..5748fb3 100644 --- a/nerochan/templates/includes/head.html +++ b/nerochan/templates/includes/head.html @@ -17,6 +17,4 @@ - - diff --git a/nerochan/templates/user/edit.html b/nerochan/templates/user/edit.html new file mode 100644 index 0000000..0da9f1e --- /dev/null +++ b/nerochan/templates/user/edit.html @@ -0,0 +1,8 @@ +{% extends 'includes/base.html' %} + +{% block content %} + +

{{ current_user.handle }}

+

Edit your profile

+ +{% endblock %} diff --git a/nerochan/templates/user/show.html b/nerochan/templates/user/show.html new file mode 100644 index 0000000..5f64792 --- /dev/null +++ b/nerochan/templates/user/show.html @@ -0,0 +1,8 @@ +{% extends 'includes/base.html' %} + +{% block content %} + +

{{ user.handle }}

+

User details

+ +{% endblock %}