Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
_XxFedexX_ | 97e43c1a01 | 2 years ago |
_XxFedexX_ | 40b685ad7f | 2 years ago |
_XxFedexX_ | 508adf3d73 | 2 years ago |
_XxFedexX_ | 4d8ede1ea8 | 2 years ago |
@ -1,43 +1,63 @@
|
||||
from flask import jsonify, Blueprint, url_for, request, abort
|
||||
from suchwow.models import Post
|
||||
from suchwow import wownero
|
||||
|
||||
|
||||
bp = Blueprint("api", "api")
|
||||
|
||||
@bp.route("/api/list")
|
||||
def api_list():
|
||||
limit = request.args.get('limit', 30)
|
||||
offset = request.args.get('offset', 0)
|
||||
|
||||
# Hacky way to convert query str value to int
|
||||
try:
|
||||
limit = int(limit)
|
||||
offset = int(offset)
|
||||
except:
|
||||
abort(500, "Bleep bleep")
|
||||
|
||||
if limit > 30:
|
||||
limit = 30
|
||||
|
||||
all_posts = []
|
||||
posts = Post.select().where(Post.approved==True).order_by(Post.timestamp.desc()).limit(limit).offset(offset)
|
||||
for post in posts:
|
||||
wallet = wownero.Wallet()
|
||||
if wallet.connected:
|
||||
address = wallet.get_address(account=post.account_index)
|
||||
else:
|
||||
address = ''
|
||||
|
||||
payload = {
|
||||
'image': url_for('post.uploaded_file', filename=post.image_name, _external=True),
|
||||
'submitter': post.submitter,
|
||||
'address': address,
|
||||
'title': post.title,
|
||||
'text': post.text,
|
||||
'href': url_for('post.read', id=post.id, _external=True),
|
||||
'id': post.id,
|
||||
'timestamp': post.timestamp
|
||||
}
|
||||
all_posts.append(payload)
|
||||
return jsonify(all_posts)
|
||||
from flask import jsonify, Blueprint, url_for, request, abort
|
||||
from suchwow.models import Post
|
||||
from suchwow import wownero
|
||||
|
||||
from suchwow.utils.helpers import rw_cache, get_top_posters, get_top_posts
|
||||
|
||||
|
||||
bp = Blueprint("api", "api")
|
||||
|
||||
|
||||
@bp.route("/api/list")
|
||||
def api_list():
|
||||
limit = request.args.get('limit', 30)
|
||||
offset = request.args.get('offset', 0)
|
||||
|
||||
# Hacky way to convert query str value to int
|
||||
try:
|
||||
limit = int(limit)
|
||||
offset = int(offset)
|
||||
except:
|
||||
abort(500, "Bleep bleep")
|
||||
|
||||
if limit > 30:
|
||||
limit = 30
|
||||
|
||||
all_posts = []
|
||||
posts = Post.select().where(Post.approved == True).order_by(
|
||||
Post.timestamp.desc()).limit(limit).offset(offset)
|
||||
for post in posts:
|
||||
wallet = wownero.Wallet()
|
||||
if wallet.connected:
|
||||
address = wallet.get_address(account=post.account_index)
|
||||
else:
|
||||
address = ''
|
||||
|
||||
payload = {
|
||||
'image': url_for('post.uploaded_file', filename=post.image_name, _external=True),
|
||||
'submitter': post.submitter,
|
||||
'address': address,
|
||||
'title': post.title,
|
||||
'text': post.text,
|
||||
'href': url_for('post.read', id=post.id, _external=True),
|
||||
'id': post.id,
|
||||
'timestamp': post.timestamp
|
||||
}
|
||||
all_posts.append(payload)
|
||||
return jsonify(all_posts)
|
||||
|
||||
|
||||
@bp.route("/api/posters")
|
||||
def api_posters():
|
||||
|
||||
posters = get_top_posters()
|
||||
all_posters = {}
|
||||
for poster, data in posters.items():
|
||||
payload = {
|
||||
"submitter": poster,
|
||||
"posts": data["posts"],
|
||||
"amount": data["amount"],
|
||||
}
|
||||
all_posters.append(payload)
|
||||
|
||||
return jsonify(posters)
|
||||
|
After Width: | Height: | Size: 46 KiB |
@ -1,9 +1,9 @@
|
||||
body {
|
||||
background-image: url("/static/bg.png");
|
||||
background-repeat: repeat;
|
||||
}
|
||||
|
||||
.current-page-btn {
|
||||
color: blue;
|
||||
border: 1px blue solid;
|
||||
}
|
||||
body {
|
||||
background-image: url("/static/bg.webp");
|
||||
background-repeat: repeat;
|
||||
}
|
||||
|
||||
.current-page-btn {
|
||||
color: blue;
|
||||
border: 1px blue solid;
|
||||
}
|
||||
|
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 11 KiB |
@ -1,91 +1,49 @@
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="/">
|
||||
<img src="/static/wow_logo.png">
|
||||
</a>
|
||||
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="navbarBasicExample" class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<a class="navbar-item" href="{{ url_for('index') }}">Home</a>
|
||||
<div class="navbar-item has-dropdown is-hoverable">
|
||||
<a class="navbar-link">Leaderboards</a>
|
||||
|
||||
<div class="navbar-dropdown">
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posters') }}">Top Posters</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=1">Top Memes Last 1 Day</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=3">Top Memes Last 3 Days</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=7">Top Memes Last Week</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=30">Top Memes Last Month</a>
|
||||
</div>
|
||||
</div>
|
||||
<a class="navbar-item" href="{{ url_for('about') }}">About</a>
|
||||
<a class="navbar-item" href="{{ url_for('post.create') }}">Submit</a>
|
||||
{% if session.auth %}
|
||||
<a class="navbar-item" style="color: orange;" href="{{ url_for('mod_queue') }}">Mods!</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<div class="buttons">
|
||||
{% 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 %}
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Navigation -->
|
||||
<!-- <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="/">
|
||||
<h3>SuchWow!</h3>
|
||||
</a>
|
||||
|
||||
<div class="" id="">
|
||||
<ul class="navbar-nav ml-auto">
|
||||
{% if session.auth %}
|
||||
<li class="nav-item">
|
||||
|
||||
</li>
|
||||
{% endif %}
|
||||
<li class="nav-item">
|
||||
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('post.create') }}">Submit</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('about') }}">About</a>
|
||||
</li>
|
||||
{% if session.auth == None %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('auth.login') }}">Login</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
{% if session.auth %}
|
||||
<a class="nav-link" href="{{ url_for('profile.edit') }}">Profile ({{ session.auth.preferred_username }})</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('auth.logout') }}">Logout</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav> -->
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="/">
|
||||
<img src="/static/wow_logo.webp">
|
||||
</a>
|
||||
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="navbarBasicExample" class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<a class="navbar-item" href="{{ url_for('index') }}">Home</a>
|
||||
<div class="navbar-item has-dropdown is-hoverable">
|
||||
<a class="navbar-link">Leaderboards</a>
|
||||
|
||||
<div class="navbar-dropdown">
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posters') }}">Top Posters</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=1">Top Memes Last 1 Day</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=3">Top Memes Last 3 Days</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=7">Top Memes Last Week</a>
|
||||
<a class="navbar-item" href="{{ url_for('leaderboard.top_posts') }}?days=30">Top Memes Last Month</a>
|
||||
</div>
|
||||
</div>
|
||||
<a class="navbar-item" href="{{ url_for('about') }}">About</a>
|
||||
<a class="navbar-item" href="{{ url_for('post.create') }}">Submit</a>
|
||||
{% if session.auth %}
|
||||
<a class="navbar-item" style="color: orange;" href="{{ url_for('mod_queue') }}">Mods!</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<div class="buttons">
|
||||
{% 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 %}
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
Reference in new issue