Browse Source

making template adjustments

facelift
lza_menace 3 months ago
parent
commit
ce735058fb
  1. 1
      requirements.txt
  2. 5
      suchwow/app.py
  3. 15
      suchwow/filters.py
  4. 17
      suchwow/models.py
  5. 11
      suchwow/templates/about.html
  6. 3
      suchwow/templates/base.html
  7. 6
      suchwow/templates/navbar.html
  8. 8
      suchwow/templates/post/create.html
  9. 110
      suchwow/templates/post/read.html

1
requirements.txt

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

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

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

17
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 {

11
suchwow/templates/about.html

@ -3,17 +3,10 @@
{% block content %}
<div class="container" style="text-align:center;">
<div class="about">
<div class="about content">
<h1>About</h1>
<p>Post memes! Have fun! Comment and talk shit! Earn WOW!</p>
<h1>Contact</h1>
<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>
<p>Quit your day job and become a full-time shitposter and memer!</p>
</div>
</div>

3
suchwow/templates/base.html

@ -74,8 +74,7 @@
<footer class="footer">
<div class="content has-text-centered">
<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 Wownero</a>.</p>
<p><a href="https://wownero.org/" target="_blank">Learn more about the infamous shitcoin, Wownero</a>.</p>
</div>
</footer>

6
suchwow/templates/navbar.html

@ -24,13 +24,11 @@
<div class="navbar-end">
<div class="navbar-item">
<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-light" href="{{ url_for('auth.login') }}">Log in</a>
{% else %}
{% if session.auth %}
<a class="button is-primary" href="{{ url_for('profile.edit') }}">Profile ({{ session.auth.preferred_username }})</a>
{% endif %}
<a class="button is-primary" href="{{ url_for('profile.edit') }}">Profile ({{ session.auth.preferred_username }})</a>
<a class="button is-light" href="{{ url_for('auth.logout') }}">Logout</a>
{% endif %}
</div>

8
suchwow/templates/post/create.html

@ -3,15 +3,15 @@
{% block content %}
<div class="container" style="width:40%;">
<div class="submit">
<div class="submit content">
<h1>Submit A Meme</h1>
<h2>Rules</h2>
<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>it has to do somethign with crypto</li>
<li>must pertain to wownero or crypto in general</li>
</ol>
<form method=post enctype=multipart/form-data class="form-horizontal">
<div class="form-group">
<label class="sr-only" for="inlineFormInput">Title</label>

110
suchwow/templates/post/read.html

@ -3,53 +3,78 @@
{% block content %}
<div class="container">
<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 %}
<h2>You cannot see this post</h2>
{% else %}
<!-- Post Info -->
<h1>{{ post.title }}</h1>
<p class="subtitle">{{ post.text }}</p>
{% 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.delete', id=post.id) }}"><button type="button" name="button">Reject</button></a>
{% endif %}
<p class="subtext">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="margin-bottom:1em;border-radius:4px;">
<hr>
<section class="section">
<div class="content">
<h1>{{ post.title }}</h1>
<p>{{ post.text }}</p>
{% 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.delete', id=post.id) }}"><button type="button" name="button">Reject</button></a>
{% endif %}
<p>Submitted by <i><u><a href="/?submitter={{ post.submitter }}">{{ post.submitter }}</a></u></i> at <i>{{ post.timestamp }}</i></p>
<img src="{{ url_for('post.uploaded_file', filename=post.image_name) }}" width=600/ style="border-radius:4px;">
</div>
</section>
<!-- Payments -->
<h2>Payments</h2>
<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 %}
<img src="data:image/png;base64,{{ qr_code }}" width=180 class="center"><br /><br />
{% endif %}
<h5>WOW Received</h5>
{% if transfers.in %}
<ul>
{% for transfer in transfers.in %}
{% 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>
<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>
{% if qr_code %}
<img src="data:image/png;base64,{{ qr_code }}" width=180 class="center"><br /><br />
{% endif %}
<div class="columns">
<div class="column content">
<h4>WOW Received</h4>
{% 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 %}
{% endfor %}
</ul>
{% else %}
<p>No WOW received yet. Show this post some love!</p>
{% endif %}
<h5>WOW Sent</h5>
{% if transfers.out %}
<ul>
{% for transfer in transfers.out %}
<li>{{ transfer.amount / 100000000000 }} WOW (<a href="https://wownero.club/transaction/{{ transfer.txid }}" target="_blank">{{ transfer.txid }}</a>)</li>
{% endfor %}
</ul>
{% else %}
<p>No payouts yet.</p>
{% endif %}
<hr>
</div>
<div class="column content">
<h4>WOW Sent</h4>
{% if transfers.out %}
<ul>
{% for transfer in transfers.out %}
<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 %}
</ul>
{% else %}
<p>No payouts yet.</p>
{% endif %}
</div>
</div>
</section>
{% endif %}
@ -57,13 +82,6 @@
{{ post.show() }}
{% 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>

Loading…
Cancel
Save