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,13 +47,16 @@ 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):
w = wownero.Wallet() try:
it = w.incoming_transfers(self.account_index) w = wownero.Wallet()
if 'transfers' in it: it = w.incoming_transfers(self.account_index)
amounts = [amt['amount'] for amt in it['transfers'] if 'transfers' in it] if 'transfers' in it:
return wownero.as_wownero(wownero.from_atomic(sum(amounts))) amounts = [amt['amount'] for amt in it['transfers'] if 'transfers' in it]
else: return wownero.as_wownero(wownero.from_atomic(sum(amounts)))
return '0' else:
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,15 +3,15 @@
{% 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">
<div class="form-group"> <div class="form-group">
<label class="sr-only" for="inlineFormInput">Title</label> <label class="sr-only" for="inlineFormInput">Title</label>

@ -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 -->
<h1>{{ post.title }}</h1> <section class="section">
<p class="subtitle">{{ post.text }}</p> <div class="content">
{% if not post.approved %} <h1>{{ post.title }}</h1>
<a href="{{ url_for('post.approve', id=post.id) }}"><button type="button" name="button">Approve</button></a> <p>{{ post.text }}</p>
<a href="{{ url_for('post.delete', id=post.id) }}"><button type="button" name="button">Reject</button></a> {% if not post.approved %}
{% endif %} <a href="{{ url_for('post.approve', id=post.id) }}"><button type="button" name="button">Approve</button></a>
<p class="subtext">Submitted by <i><u><a href="/?submitter={{ post.submitter }}">{{ post.submitter }}</a></u></i> at <i>{{ post.timestamp }}</i></p> <a href="{{ url_for('post.delete', id=post.id) }}"><button type="button" name="button">Reject</button></a>
<br> {% endif %}
<img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=600/ style="margin-bottom:1em;border-radius:4px;"> <p>Submitted by <i><u><a href="/?submitter={{ post.submitter }}">{{ post.submitter }}</a></u></i> at <i>{{ post.timestamp }}</i></p>
<hr> <img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=600/ style="border-radius:4px;">
</div>
</section>
<!-- Payments --> <!-- Payments -->
<h2>Payments</h2> <section class="section content">
<p style="word-break:break-all;">Vote for this post by sending WOW to the following address:<br><i>{{ address }}</i></p> <h3>Payments</h3>
{% if qr_code %} <p style="word-break:break-all;">Vote for this post by sending WOW to the following address:<br><i>{{ address }}</i></p>
<img src="data:image/png;base64,{{ qr_code }}" width=180 class="center"><br /><br /> {% if qr_code %}
{% endif %} <img src="data:image/png;base64,{{ qr_code }}" width=180 class="center"><br /><br />
<h5>WOW Received</h5> {% endif %}
{% if transfers.in %}
<ul> <div class="columns">
{% for transfer in transfers.in %} <div class="column content">
{% if transfer.amount > 0 %} <h4>WOW Received</h4>
<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> {% if transfers.in %}
<ul>
{% for transfer in transfers.in %}
{% if transfer.amount > 0 %}
<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 %}
{% endfor %}
</ul>
{% else %}
<p>No WOW received yet. Show this post some love!</p>
{% endif %} {% endif %}
{% endfor %} </div>
</ul> <div class="column content">
{% else %} <h4>WOW Sent</h4>
<p>No WOW received yet. Show this post some love!</p> {% if transfers.out %}
{% endif %} <ul>
<h5>WOW Sent</h5> {% for transfer in transfers.out %}
{% if transfers.out %} <li>
<ul> {{ transfer.amount / 100000000000 }} WOW
{% for transfer in transfers.out %} (<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid | shorten_address }}</a>)
<li>{{ transfer.amount / 100000000000 }} WOW (<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid }}</a>)</li> - {{ transfer.timestamp | humanize }}
{% endfor %} </li>
</ul> {% endfor %}
{% else %} </ul>
<p>No payouts yet.</p> {% else %}
{% endif %} <p>No payouts yet.</p>
<hr> {% endif %}
</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>