making template adjustments

facelift
lza_menace 3 years ago
parent 2363cede02
commit ce735058fb

@ -7,3 +7,4 @@ six
praw praw
qrcode qrcode
Pillow Pillow
arrow

@ -1,5 +1,6 @@
import json import json
import click import click
import arrow
from math import ceil from math import ceil
from datetime import datetime, timedelta from datetime import datetime, timedelta
from random import choice 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.utils.helpers import post_webhook
from suchwow.reddit import make_post from suchwow.reddit import make_post
from suchwow.discord import post_discord_webhook from suchwow.discord import post_discord_webhook
from suchwow import wownero from suchwow import wownero, filters
app = Flask(__name__) app = Flask(__name__)
@ -28,6 +29,7 @@ app.register_blueprint(profile.bp)
app.register_blueprint(comment.bp) app.register_blueprint(comment.bp)
app.register_blueprint(leaderboard.bp) app.register_blueprint(leaderboard.bp)
app.register_blueprint(api.bp) app.register_blueprint(api.bp)
app.register_blueprint(filters.bp)
@app.route("/") @app.route("/")
def index(): def index():
@ -135,5 +137,6 @@ def post_id(post_id):
else: else:
print("That post doesn't exist") print("That post doesn't exist")
if __name__ == "__main__": if __name__ == "__main__":
app.run() app.run()

@ -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()

@ -47,6 +47,7 @@ class Post(Model):
return s[0] + '.thumbnail' + s[1] return s[0] + '.thumbnail' + s[1]
def get_received_wow(self): def get_received_wow(self):
try:
w = wownero.Wallet() w = wownero.Wallet()
it = w.incoming_transfers(self.account_index) it = w.incoming_transfers(self.account_index)
if 'transfers' in it: if 'transfers' in it:
@ -54,6 +55,8 @@ class Post(Model):
return wownero.as_wownero(wownero.from_atomic(sum(amounts))) return wownero.as_wownero(wownero.from_atomic(sum(amounts)))
else: else:
return '0' return '0'
except:
return '?'
def show(self): def show(self):
return { return {

@ -3,17 +3,10 @@
{% block content %} {% block content %}
<div class="container" style="text-align:center;"> <div class="container" style="text-align:center;">
<div class="about"> <div class="about content">
<h1>About</h1> <h1>About</h1>
<p>Post memes! Have fun! Comment and talk shit! Earn WOW!</p> <p>Post memes! Have fun! Comment and talk shit! Earn WOW!</p>
<h1>Contact</h1> <p>Quit your day job and become a full-time shitposter and memer!</p>
<p>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:</p>
<ul>
<li><a href="https://webchat.freenode.net/?room=#wownero">IRC</a></li>
<li><a href="https://twitter.com/lza_menace">Twitter</a></li>
<li><a href="mailto:lza_menace@protonmail.com">Email</a></li>
<li><a href="https://www.reddit.com/user/lza_menace">Reddit</a></li>
</ul>
</div> </div>
</div> </div>

@ -74,8 +74,7 @@
<footer class="footer"> <footer class="footer">
<div class="content has-text-centered"> <div class="content has-text-centered">
<p><strong>SuchWow</strong> by <a href="https://lzahq.tech" target="_blank">lza_menace</a></p> <p><strong>SuchWow</strong> by <a href="https://lzahq.tech" target="_blank">lza_menace</a></p>
<br /> <p><a href="https://wownero.org/" target="_blank">Learn more about the infamous shitcoin, Wownero</a>.</p>
<p><a href="https://wownero.org/" target="_blank">Learn more about Wownero</a>.</p>
</div> </div>
</footer> </footer>

@ -24,13 +24,11 @@
<div class="navbar-end"> <div class="navbar-end">
<div class="navbar-item"> <div class="navbar-item">
<div class="buttons"> <div class="buttons">
{% if session.auth == None %} {% if not 'auth' in session %}
<a class="button is-primary" href="https://login.wownero.com/developer/"><strong>Sign up</strong></a> <a class="button is-primary" href="https://login.wownero.com/developer/"><strong>Sign up</strong></a>
<a class="button is-light" href="{{ url_for('auth.login') }}">Log in</a> <a class="button is-light" href="{{ url_for('auth.login') }}">Log in</a>
{% else %} {% else %}
{% if session.auth %}
<a class="button is-primary" href="{{ url_for('profile.edit') }}">Profile ({{ session.auth.preferred_username }})</a> <a class="button is-primary" href="{{ url_for('profile.edit') }}">Profile ({{ session.auth.preferred_username }})</a>
{% endif %}
<a class="button is-light" href="{{ url_for('auth.logout') }}">Logout</a> <a class="button is-light" href="{{ url_for('auth.logout') }}">Logout</a>
{% endif %} {% endif %}
</div> </div>

@ -3,13 +3,13 @@
{% block content %} {% block content %}
<div class="container" style="width:40%;"> <div class="container" style="width:40%;">
<div class="submit"> <div class="submit content">
<h1>Submit A Meme</h1> <h1>Submit A Meme</h1>
<h2>Rules</h2> <h2>Rules</h2>
<ol> <ol>
<li>no super low effort memes (ex. putting a wow logo on a picture and that's it) but memes where you add something to the wow logo or around is fine</li> <li>no super low effort memes</li>
<li>no nsfl and nsfw</li> <li>no nsfl and nsfw</li>
<li>it has to do somethign with crypto</li> <li>must pertain to wownero or crypto in general</li>
</ol> </ol>
<form method=post enctype=multipart/form-data class="form-horizontal"> <form method=post enctype=multipart/form-data class="form-horizontal">

@ -3,53 +3,78 @@
{% block content %} {% block content %}
<div class="container"> <div class="container">
<div class="post" style="text-align:center;"> <div class="post" style="text-align:center;">
<a href="/">< Go Back</a>
<nav class="breadcrumb is-centered" aria-label="breadcrumbs">
<ul>
<li><a href="/">All Posts</a></li>
<li class="is-active"><a href="#" aria-current="page">Post {{ post.id }}</a></li>
</ul>
</nav>
{% if post.hidden %} {% if post.hidden %}
<h2>You cannot see this post</h2> <h2>You cannot see this post</h2>
{% else %} {% else %}
<!-- Post Info --> <!-- Post Info -->
<section class="section">
<div class="content">
<h1>{{ post.title }}</h1> <h1>{{ post.title }}</h1>
<p class="subtitle">{{ post.text }}</p> <p>{{ post.text }}</p>
{% if not post.approved %} {% if not post.approved %}
<a href="{{ url_for('post.approve', id=post.id) }}"><button type="button" name="button">Approve</button></a> <a href="{{ url_for('post.approve', id=post.id) }}"><button type="button" name="button">Approve</button></a>
<a href="{{ url_for('post.delete', id=post.id) }}"><button type="button" name="button">Reject</button></a> <a href="{{ url_for('post.delete', id=post.id) }}"><button type="button" name="button">Reject</button></a>
{% endif %} {% endif %}
<p class="subtext">Submitted by <i><u><a href="/?submitter={{ post.submitter }}">{{ post.submitter }}</a></u></i> at <i>{{ post.timestamp }}</i></p> <p>Submitted by <i><u><a href="/?submitter={{ post.submitter }}">{{ post.submitter }}</a></u></i> at <i>{{ post.timestamp }}</i></p>
<br> <img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=600/ style="border-radius:4px;">
<img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=600/ style="margin-bottom:1em;border-radius:4px;"> </div>
<hr> </section>
<!-- Payments --> <!-- Payments -->
<h2>Payments</h2> <section class="section content">
<h3>Payments</h3>
<p style="word-break:break-all;">Vote for this post by sending WOW to the following address:<br><i>{{ address }}</i></p> <p style="word-break:break-all;">Vote for this post by sending WOW to the following address:<br><i>{{ address }}</i></p>
{% if qr_code %} {% if qr_code %}
<img src="data:image/png;base64,{{ qr_code }}" width=180 class="center"><br /><br /> <img src="data:image/png;base64,{{ qr_code }}" width=180 class="center"><br /><br />
{% endif %} {% endif %}
<h5>WOW Received</h5>
<div class="columns">
<div class="column content">
<h4>WOW Received</h4>
{% if transfers.in %} {% if transfers.in %}
<ul> <ul>
{% for transfer in transfers.in %} {% for transfer in transfers.in %}
{% if transfer.amount > 0 %} {% if transfer.amount > 0 %}
<li style="word-break:break-all;list-style:none;">{{ transfer.amount / 100000000000 }} WOW (<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid }}</a>)</li> <li>
{{ transfer.amount / 100000000000 }} WOW
(<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid | shorten_address }}</a>)
- {{ transfer.timestamp | humanize }}
</li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}
<p>No WOW received yet. Show this post some love!</p> <p>No WOW received yet. Show this post some love!</p>
{% endif %} {% endif %}
<h5>WOW Sent</h5> </div>
<div class="column content">
<h4>WOW Sent</h4>
{% if transfers.out %} {% if transfers.out %}
<ul> <ul>
{% for transfer in transfers.out %} {% for transfer in transfers.out %}
<li>{{ transfer.amount / 100000000000 }} WOW (<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid }}</a>)</li> <li>
{{ transfer.amount / 100000000000 }} WOW
(<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid | shorten_address }}</a>)
- {{ transfer.timestamp | humanize }}
</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}
<p>No payouts yet.</p> <p>No payouts yet.</p>
{% endif %} {% endif %}
<hr> </div>
</div>
</section>
{% endif %} {% endif %}
@ -57,13 +82,6 @@
{{ post.show() }} {{ post.show() }}
{% endif %} {% endif %}
{#
{% if "auth" in session %}
{% if session.auth.preferred_username == post.submitter %}
<hr><a href="{{ url_for('post.delete', id=post.id) }}"><button class="btn btn-danger">Delete Post</button></a>
{% endif %}
{% endif %}
#}
</div> </div>
</div> </div>