From d937a12317168649583a889776e8b6863c837478 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 28 Nov 2022 01:05:57 -0800 Subject: [PATCH] revamping frontend --- Makefile | 3 + nerochan/cli.py | 24 ++++- nerochan/models.py | 9 +- nerochan/routes/artwork.py | 4 + nerochan/routes/main.py | 4 +- nerochan/static/css/main.css | 122 ++++++++++++++++++++++++ nerochan/templates/about.html | 15 ++- nerochan/templates/artwork/show.html | 56 ++++++++++- nerochan/templates/auth/challenge.html | 16 +++- nerochan/templates/auth/login.html | 10 +- nerochan/templates/auth/register.html | 10 +- nerochan/templates/includes/base.html | 13 +-- nerochan/templates/includes/form.html | 14 ++- nerochan/templates/includes/header.html | 20 ---- nerochan/templates/includes/navbar.html | 25 +++++ nerochan/templates/index.html | 11 ++- requirements-dev.txt | 3 + requirements.txt | 2 - 18 files changed, 291 insertions(+), 70 deletions(-) delete mode 100644 nerochan/templates/includes/header.html create mode 100644 nerochan/templates/includes/navbar.html create mode 100644 requirements-dev.txt diff --git a/Makefile b/Makefile index e8ab3aa..b844182 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ setup: ## Establish local environment with dependencies installed .venv/bin/pip install -r requirements.txt mkdir -p data/uploads +setup-dev: ## Install development dependencies + .venv/bin/pip install -r requirements-dev.txt + build: ## Build containers docker-compose build diff --git a/nerochan/cli.py b/nerochan/cli.py index 0309572..bdd8e60 100644 --- a/nerochan/cli.py +++ b/nerochan/cli.py @@ -1,4 +1,6 @@ import click +import lorem + from os import path, makedirs from urllib.request import urlopen @@ -28,7 +30,23 @@ def cli(app): 'wallet': '77toDDnVmSrWMZ5tS17UWXcxQVkD6LtNSArVwzsWdE176oDbYtPTiAqExjDZWGE5KwKPY7Kd1BcWYfCnJuL2RfcqA1gzoEj', 'art': [ 'https://www.monerochan.art/commissions/hammock.png', - 'https://www.monerochan.art/commissions/assaultrifle.png' + 'https://www.monerochan.art/commissions/assaultrifle.png', + 'https://www.monerochan.art/thumbnails/vtubing.png', + 'https://www.monerochan.art/commissions/ribbons.jpg', + 'https://www.monerochan.art/commissions/mining.jpg', + 'https://www.monerochan.art/commissions/wownerochan_headpat.png', + 'https://www.monerochan.art/commissions/wownerochan.jpg' + ] + }, + 'gemini': { + 'wallet': '78TanhCTvw4V8HkY3vD49A5EiyeGCzCHQUm59sByukTcffZPf3QHoK8PDg8WpMUc6VGwqxTu65HvwCUfB2jZutb6NKpjArk', + 'art': [ + 'https://www.monerochan.art/commissions/cheerleader.jpg', + 'https://www.monerochan.art/commissions/maidnero-chan.png', + 'https://www.monerochan.art/commissions/dandelion.png', + 'https://www.monerochan.art/commissions/volleyball_1.jpg', + 'https://www.monerochan.art/commissions/volleyball_2.jpg', + 'https://www.monerochan.art/commissions/virgin_killer.png' ] } } @@ -59,8 +77,8 @@ def cli(app): creator=_user, image=bn, approved=True, - title=f'i made {bn}', - description='' + title=lorem.sentence(), + description=lorem.sentence() ) artwork.save() click.echo(f'[+] Created artwork {artwork.id} for {bn}') diff --git a/nerochan/models.py b/nerochan/models.py index 3463c26..e5f2926 100644 --- a/nerochan/models.py +++ b/nerochan/models.py @@ -25,7 +25,7 @@ class User(pw.Model): register_date = pw.DateTimeField(default=datetime.utcnow) last_login_date = pw.DateTimeField(default=datetime.utcnow) handle = pw.CharField(unique=True) - wallet_address = pw.CharField(unique=True) + wallet_address = pw.CharField(unique=True, null=False) challenge = pw.CharField(default=gen_challenge) is_admin = pw.BooleanField(default=False) is_mod = pw.BooleanField(default=False) @@ -82,13 +82,16 @@ class Artwork(pw.Model): id = pw.AutoField() creator = pw.ForeignKeyField(User) image = pw.CharField() - thumbnail = pw.CharField(null=True) upload_date = pw.DateTimeField(default=datetime.utcnow) last_edit_date = pw.DateTimeField(default=datetime.utcnow) approved = pw.BooleanField(default=False) hidden = pw.BooleanField(default=False) title = pw.CharField() description = pw.TextField(null=True) + + @property + def thumbnail(self): + return f'thumbnail-{self.image}' def generate_thumbnail(self): is_gif = self.image.endswith('.gif') @@ -113,7 +116,7 @@ class Artwork(pw.Model): _image.save(t, format=image.format, save_all=True, append_images=list(_frames), disposal=2) else: image.thumbnail(size, Image.ANTIALIAS) - image.save(t, format=image.format, quality=75) + image.save(t, format=image.format) image.close() self.thumbnail = _t self.save() diff --git a/nerochan/routes/artwork.py b/nerochan/routes/artwork.py index 4a76124..a29f8de 100644 --- a/nerochan/routes/artwork.py +++ b/nerochan/routes/artwork.py @@ -6,6 +6,10 @@ from nerochan.models import Artwork, User bp = Blueprint('artwork', 'artwork', url_prefix='/artwork') +@bp.route('') +def list(): + return 'show all artwork' + @bp.route('/') def show(id): artwork = Artwork.get_or_none(id) diff --git a/nerochan/routes/main.py b/nerochan/routes/main.py index 9246705..9ccff1a 100644 --- a/nerochan/routes/main.py +++ b/nerochan/routes/main.py @@ -12,11 +12,11 @@ bp = Blueprint('main', 'main') def index(): users = User.select().where( User.is_approved == True - ).order_by(User.register_date.desc()) + ).order_by(User.register_date.desc()).limit(10) artwork = Artwork.select().where( Artwork.approved == True, Artwork.hidden == False - ).order_by(Artwork.upload_date.desc()) + ).order_by(Artwork.upload_date.desc()).limit(10) feed = { 'users': users, 'artwork': artwork diff --git a/nerochan/static/css/main.css b/nerochan/static/css/main.css index e69de29..b544830 100644 --- a/nerochan/static/css/main.css +++ b/nerochan/static/css/main.css @@ -0,0 +1,122 @@ +body { + background-color: black; + color: white; + font-family: monospace; +} + +a, a:visited { + color: white; +} + +.artworkLink img { + border-radius: 2px; + margin: 1em; +} + +.artworkLink { + text-decoration: none; +} + +.artworkDescription { + margin-top: 1em; +} + +hr { + margin-top: 0; +} + +input[type="text"] { + color: black; +} + +.walletAddress { + overflow-wrap: anywhere; + user-select: all; +} + +.button-primary { + background-color: #ff6600 !important; + border: 1px solid #ff6600 !important; + transition: all .3s ease; +} + +.button-primary:hover { + background-color: #4c4c4c !important; + color: white !important; + border: 1px solid #4c4c4c !important; + transition: all .3s ease; +} + +.no-margin { + margin: 0; +} + +.navbar + .docs-section { + border-top-width: 0; +} + +.navbar { + margin-bottom: 2em; +} + +.navbar, .navbar-spacer { + display: block; + width: 100%; + height: 6.5rem; + z-index: 99; +} + +.navbar-spacer { + display: none; +} + +.navbar > .container { + width: 100%; +} + +.navbar-list { + list-style: none; + margin-bottom: 0; +} + +.navbar-item { + position: relative; + float: left; + margin-bottom: 0; +} + +.navbar-link { + text-transform: uppercase; + font-size: 11px; + font-weight: 600; + letter-spacing: .2rem; + margin-right: 35px; + text-decoration: none; + line-height: 6.5rem; + color: #222; + transition: all .2s ease; +} + +.navbar-link:hover { + color: #ff6600; + transition: all .2s ease; +} + +.navbar-link.active { + color: #33C3F0; +} + +.has-docked-nav .navbar { + position: fixed; + top: 0; + left: 0; +} + +.has-docked-nav .navbar-spacer { + display: block; +} + +/* Re-overiding the width 100% declaration to match size of % based container */ +.has-docked-nav .navbar > .container { + width: 80%; +} diff --git a/nerochan/templates/about.html b/nerochan/templates/about.html index f966e48..37887bb 100644 --- a/nerochan/templates/about.html +++ b/nerochan/templates/about.html @@ -2,7 +2,18 @@ {% block content %} -

about

-

nerochan, uwu

+
+
+

about

+

+ This site is dedicated to the Monero communities' favorite e-girl, Monero-Chan. +

+

+ Made with <3 by @lza_menace. + Send him a tip: 49awrmn61ExDUZrV5wJxMM54fxVzHABUYUBNBskLJbxzVwk1KqfrFvdcPNK6RKY2qyfGbcpXP3mbofmnMmFKiFHSCB6jLFA +

+ +
+
{% endblock %} diff --git a/nerochan/templates/artwork/show.html b/nerochan/templates/artwork/show.html index 6e4dd49..eee1564 100644 --- a/nerochan/templates/artwork/show.html +++ b/nerochan/templates/artwork/show.html @@ -5,11 +5,57 @@ {% set img = url_for('main.uploaded_file', filename=artwork.image) %}
-

{{ artwork.title }}

-

{{ artwork.creator.handle }}

- - - +

{{ artwork.title }}

+
+ Posted by {{ artwork.creator.handle }} - {{ artwork.upload_date | humanize }} +
+

{{ artwork.description }}

+
+
+
+
+ + + +
+
+
Send a Tip
+

{{ artwork.creator.wallet_address }}

+
+
+
+ + +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + +
TXIDXMRDate
e599...5429.053 days ago
681a...e264.2528 days ago
+
diff --git a/nerochan/templates/auth/challenge.html b/nerochan/templates/auth/challenge.html index aa3468b..0fd85b7 100644 --- a/nerochan/templates/auth/challenge.html +++ b/nerochan/templates/auth/challenge.html @@ -2,10 +2,16 @@ {% block content %} -

Challenge

-

Handle: {{ user.handle }}

-

Challenge: {{ user.challenge }}

-

Wallet Address: {{ user.wallet_address }}

-{% include 'includes/form.html' %} +
+
+

challenge

+

Handle: {{ user.handle }}

+

Challenge: {{ user.challenge }}

+

Wallet Address: {{ user.wallet_address }}

+ {% include 'includes/form.html' %} +
+
+ + {% endblock %} diff --git a/nerochan/templates/auth/login.html b/nerochan/templates/auth/login.html index a962ae5..70321ef 100644 --- a/nerochan/templates/auth/login.html +++ b/nerochan/templates/auth/login.html @@ -2,7 +2,13 @@ {% block content %} -

Login

-{% include 'includes/form.html' %} +
+
+

login

+ {% include 'includes/form.html' %} + Register +
+
+ {% endblock %} diff --git a/nerochan/templates/auth/register.html b/nerochan/templates/auth/register.html index f68216c..9066f7a 100644 --- a/nerochan/templates/auth/register.html +++ b/nerochan/templates/auth/register.html @@ -2,7 +2,13 @@ {% block content %} -

Register

-{% include 'includes/form.html' %} + +
+
+

register

+ {% include 'includes/form.html' %} + Login +
+
{% endblock %} diff --git a/nerochan/templates/includes/base.html b/nerochan/templates/includes/base.html index 85fa9c4..eb24ea1 100644 --- a/nerochan/templates/includes/base.html +++ b/nerochan/templates/includes/base.html @@ -1,18 +1,9 @@ {% include 'includes/head.html' %} - - {% include 'includes/header.html' %} + + {% include 'includes/navbar.html' %} {% block content %}{% endblock %} {% include 'includes/debug.html' %} - diff --git a/nerochan/templates/includes/form.html b/nerochan/templates/includes/form.html index 98f3518..26de08f 100644 --- a/nerochan/templates/includes/form.html +++ b/nerochan/templates/includes/form.html @@ -1,18 +1,16 @@ -
+ {% for f in form %} {% if f.name == 'csrf_token' %} {{ f }} {% else %} -
- {{ f.label }} - {{ f }} -
+ {{ f.label }} + {{ f }} {% endif %} {% endfor %}
    - {% for field, errors in form.errors.items() %} + {%- for field, errors in form.errors.items() %}
  • {{ form[field].label }}: {{ ', '.join(errors) }}
  • - {% endfor %} + {%- endfor %}
- +
diff --git a/nerochan/templates/includes/header.html b/nerochan/templates/includes/header.html deleted file mode 100644 index 7cacdbc..0000000 --- a/nerochan/templates/includes/header.html +++ /dev/null @@ -1,20 +0,0 @@ - - -{% with messages = get_flashed_messages(with_categories=true) %} - {% if messages %} -

- {% for category, message in messages %} -

{{ message }} - {{ category }}

- {% endfor %} -

- {% endif %} -{% endwith %} diff --git a/nerochan/templates/includes/navbar.html b/nerochan/templates/includes/navbar.html new file mode 100644 index 0000000..06fadd9 --- /dev/null +++ b/nerochan/templates/includes/navbar.html @@ -0,0 +1,25 @@ + + +
+{% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} +

+ {% for category, message in messages %} +

{{ message }} - {{ category }}

+ {% endfor %} +

+ {% endif %} +{% endwith %} +
\ No newline at end of file diff --git a/nerochan/templates/index.html b/nerochan/templates/index.html index c8e4d49..051ba3e 100644 --- a/nerochan/templates/index.html +++ b/nerochan/templates/index.html @@ -5,13 +5,14 @@

Latest Artworks

- {% for _artwork in feed['artwork'] | batch(4) %} - {% for artwork in _artwork %} - + {%- for _artwork in feed['artwork'] | batch(4) %} + {%- for artwork in _artwork %} + - {% endfor %} - {% endfor %} + {%- endfor %} + {%- endfor %} +

...view all

Latest Artists

diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..1b2ffd0 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +flake8==6.0.0 +pyflakes==3.0.1 +lorem==0.1.1 diff --git a/requirements.txt b/requirements.txt index 2076d0f..61abebd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ certifi==2022.9.24 cffi==1.15.1 charset-normalizer==2.1.1 click==8.1.3 -flake8==6.0.0 Flask==2.2.2 Flask-Login==0.6.2 Flask-Session==0.4.0 @@ -25,7 +24,6 @@ Pillow==9.3.0 pycodestyle==2.10.0 pycparser==2.21 pycryptodomex==3.16.0 -pyflakes==3.0.1 PyNaCl==1.5.0 pyparsing==3.0.9 PySocks==1.7.1