From ce735058fba61db170b1aa48b9f24225ac82bccf Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 29 Apr 2021 19:27:21 -0700 Subject: [PATCH] making template adjustments --- requirements.txt | 1 + suchwow/app.py | 5 +- suchwow/filters.py | 15 ++++ suchwow/models.py | 17 +++-- suchwow/templates/about.html | 11 +-- suchwow/templates/base.html | 3 +- suchwow/templates/navbar.html | 6 +- suchwow/templates/post/create.html | 8 +-- suchwow/templates/post/read.html | 110 +++++++++++++++++------------ 9 files changed, 103 insertions(+), 73 deletions(-) create mode 100644 suchwow/filters.py diff --git a/requirements.txt b/requirements.txt index b3520aa..99258ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ six praw qrcode Pillow +arrow diff --git a/suchwow/app.py b/suchwow/app.py index 8a7ba73..f987622 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -1,5 +1,6 @@ import json import click +import arrow from math import ceil from datetime import datetime, timedelta from random import choice @@ -14,7 +15,7 @@ from suchwow.utils.decorators import login_required, moderator_required from suchwow.utils.helpers import post_webhook from suchwow.reddit import make_post from suchwow.discord import post_discord_webhook -from suchwow import wownero +from suchwow import wownero, filters app = Flask(__name__) @@ -28,6 +29,7 @@ app.register_blueprint(profile.bp) app.register_blueprint(comment.bp) app.register_blueprint(leaderboard.bp) app.register_blueprint(api.bp) +app.register_blueprint(filters.bp) @app.route("/") def index(): @@ -135,5 +137,6 @@ def post_id(post_id): else: print("That post doesn't exist") + if __name__ == "__main__": app.run() diff --git a/suchwow/filters.py b/suchwow/filters.py new file mode 100644 index 0000000..da6fa09 --- /dev/null +++ b/suchwow/filters.py @@ -0,0 +1,15 @@ +from flask import Blueprint, current_app +from arrow import get as arrow_get + + +bp = Blueprint('filters', 'filters') + +@bp.app_template_filter('shorten_address') +def shorten_address(a): + _p = a[0:4] + _s = a[-4:] + return f'{_p}...{_s}' + +@bp.app_template_filter('humanize') +def humanize(d): + return arrow_get(d).humanize() diff --git a/suchwow/models.py b/suchwow/models.py index 6ad8b6f..db7c2b2 100644 --- a/suchwow/models.py +++ b/suchwow/models.py @@ -47,13 +47,16 @@ class Post(Model): return s[0] + '.thumbnail' + s[1] def get_received_wow(self): - w = wownero.Wallet() - it = w.incoming_transfers(self.account_index) - if 'transfers' in it: - amounts = [amt['amount'] for amt in it['transfers'] if 'transfers' in it] - return wownero.as_wownero(wownero.from_atomic(sum(amounts))) - else: - return '0' + try: + w = wownero.Wallet() + it = w.incoming_transfers(self.account_index) + if 'transfers' in it: + amounts = [amt['amount'] for amt in it['transfers'] if 'transfers' in it] + return wownero.as_wownero(wownero.from_atomic(sum(amounts))) + else: + return '0' + except: + return '?' def show(self): return { diff --git a/suchwow/templates/about.html b/suchwow/templates/about.html index f5befae..8e32dcd 100644 --- a/suchwow/templates/about.html +++ b/suchwow/templates/about.html @@ -3,17 +3,10 @@ {% block content %}
-
+

About

Post memes! Have fun! Comment and talk shit! Earn WOW!

-

Contact

-

I run this site for fun because I like Wownero and enjoy messing around with it. It doesn't make me any money so do not expect quick replies about it. Here are places you can find me:

- +

Quit your day job and become a full-time shitposter and memer!

diff --git a/suchwow/templates/base.html b/suchwow/templates/base.html index 30fd500..d930be5 100644 --- a/suchwow/templates/base.html +++ b/suchwow/templates/base.html @@ -74,8 +74,7 @@ diff --git a/suchwow/templates/navbar.html b/suchwow/templates/navbar.html index 86a67fb..f2a9417 100755 --- a/suchwow/templates/navbar.html +++ b/suchwow/templates/navbar.html @@ -24,13 +24,11 @@