major ui improvements, new makefile stuff

main
lza_menace 3 years ago
parent f2701abd82
commit 5719ea1c7e

1
.gitignore vendored

@ -131,6 +131,7 @@ dmypy.json
# Data
data/
go-ipfs/
avalanchego-v1.7.3
*jpg
*png
*svg

@ -20,5 +20,18 @@ install-ipfs:
tar -xvzf go-ipfs_v0.10.0_linux-amd64.tar.gz
cd go-ipfs && bash install.sh
install-avax:
wget https://github.com/ava-labs/avalanchego/releases/download/v1.7.3/avalanchego-linux-amd64-v1.7.3.tar.gz
tar -xzvf avalanchego-linux-amd64-v1.7.3.tar.gz
run-ipfs:
ipfs daemon
run-avax:
./avalanchego-v1.7.3/avalanchego
run-avax-test:
./avalanchego-v1.7.3/avalanchego --network-id fuji
kill:
pkill -e -f suchwowx

@ -18,6 +18,656 @@ ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'svg', 'mp4', 'webp'}
MAX_CONTENT_LENGTH = 32 * 1024 * 1024
TEMPLATES_AUTO_RELOAD = getenv('TEMPLATES_AUTO_RELOAD', True)
# Contract
CONTRACT_ADDRESS = '0xBAb68B24068D21Fa862908818054c7e4d921db5A' # rinkeby ETH
CONTRACT_ABI = [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": True,
"internalType": "address",
"name": "approved",
"type": "address"
},
{
"indexed": True,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": True,
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"indexed": False,
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": True,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": False,
"inputs": [
{
"indexed": True,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": True,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": True,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "approve",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [],
"name": "contractCreator",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [],
"name": "contractVersion",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "creatorTips",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "creatorTokensMinted",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "creatorWowneroAddress",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "getApproved",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "isApprovedForAll",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"name": "metadataTokenId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "ownerOf",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "setApprovalForAll",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "tipperTips",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "tokenCreator",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "tokenMetadata",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "tokenTips",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
},
{
"inputs": [
{
"internalType": "string",
"name": "wowneroAddress",
"type": "string"
}
],
"name": "set_wownero_address",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "metadataIPFSHash",
"type": "string"
}
],
"name": "mint",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "tip",
"outputs": [],
"stateMutability": "payable",
"type": "function",
"payable": True
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "tokenURI",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function",
"constant": True
}
]
# Logging
LOGGING_CONFIG = {
'version': 1,

@ -1,11 +1,12 @@
import ipfsApi
from os import path
from secrets import token_urlsafe
from json import loads, dumps
from requests.exceptions import HTTPError
import ipfsApi
from flask import Blueprint, render_template, request, current_app
from flask import send_from_directory, redirect, flash, url_for
from requests.exceptions import HTTPError
from web3 import Web3
from suchwowx.models import Meme
from suchwowx.factory import db
@ -17,7 +18,15 @@ bp = Blueprint('meta', 'meta')
@bp.route('/')
def index():
memes = Meme.query.filter().order_by(Meme.create_date.desc())
return render_template('index.html', memes=memes)
w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:9650'))
contract_address = w3.toChecksumAddress(config.CONTRACT_ADDRESS)
contract_abi = config.CONTRACT_ABI
contract = w3.eth.contract(
address=contract_address,
abi=contract_abi
)
# total_supply = contract.functions.totalSupply().call()
return render_template('index.html', memes=memes, contract=contract)
@bp.route('/new', methods=['GET', 'POST'])
def new():
@ -100,3 +109,7 @@ def meme(meme_id):
if not meme:
return redirect('/')
return render_template('meme.html', meme=meme)
@bp.route('/creator/<handle>')
def creator(handle):
return render_template('includes/creator.html')

@ -0,0 +1,9 @@
.screen {
padding-bottom: 1em;
max-width: 500px;
margin: 0 auto;
}
/* #memeImage {
cursor: zoom-in;
} */

@ -0,0 +1,11 @@
<up-modal size="medium"> <!-- container with attributes -->
<up-modal-backdrop></up-modal-backdrop> <!-- semi-transparent background -->
<up-modal-viewport> <!-- scroll bar -->
<up-modal-box> <!-- white box with padding -->
<up-modal-content>
<p>Wownero Address: <span id="wowneroAddress">?</span></p>
</up-modal-content> <!-- content parent (unstyled) -->
<up-modal-dismiss>×</up-modal-dismiss> <!-- dismiss icon -->
</up-modal-box>
</up-modal-viewport>
</up-modal>

@ -8,5 +8,6 @@
<!-- <link rel="stylesheet" href="/static/css/bulma.css.map"> -->
<link rel="stylesheet" href="/static/css/vendor/noty-relax.css" />
<link rel="stylesheet" href="/static/css/vendor/noty.css" />
<link rel="stylesheet" href="/static/css/custom.css" />
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
</head>

@ -0,0 +1,13 @@
<div class="screen">
<h1 class="title">
SuchWowX.
</h1>
<p class="subtitle">
Memes. <strong>Interplanetary</strong>!
</p>
{% if request.path == '/' %}
<a class="button is-primary" href="{{ url_for('meta.new') }}">New Meme</a>
{% else %}
<a class="button" href="{{ url_for('meta.index') }}" up-preload up-follow=".container">Go Home</a>
{% endif %}
</div>

@ -4,13 +4,7 @@
<body>
<section class="section">
<div class="container">
<h1 class="title">
SuchWowX.
</h1>
<p class="subtitle">
Memes. <strong>Interplanetary</strong>!
</p>
<a class="button is-primary" href="{{ url_for('meta.new') }}">New Meme</a>
{% include 'includes/navbar.html' %}
{% if get_flashed_messages(with_categories=true) %}
<p>
@ -20,19 +14,16 @@
try installing the software and running the following:
</p>
<code>$ ipfs daemon</code>
</br></br>
{% endif %}
{% if memes %}
<div id="memes">
{% for meme in memes %}
<div class="meme" style="padding-top:1em;">
<p>Meme: <a href="{{ url_for('meta.meme', meme_id=meme.id) }}" up-preload up-follow=".container">{{ meme }}</a></p>
<p>Upload path: {{ meme.upload_path }}</p>
<p>Meta IPFS: {{ meme.meta_ipfs_hash }}</p>
<p>Meme IPFS: {{ meme.meme_ipfs_hash }}</p>
<p>Title: {{ meme.title }}</p>
<p>Description: {{ meme.description }}</p>
<p>Creator handle: {{ meme.creator_handle }}</p>
{% for _meme in memes | batch(4) %}
<div class="columns">
{% for meme in _meme %}
<div class="column" style="padding-top:1em;">
<a href="{{ url_for('meta.meme', meme_id=meme.id) }}" up-preload up-follow=".container">
{% if meme.upload_path.endswith('mp4') %}
<video style="max-height: 60vh!important;max-width:80px;" {% if not request.MOBILE %}autoplay{% else %}controls{% endif %} muted loop>
<source src="{{ url_for('meta.uploaded_file', filename=meme.upload_path) }}" type="video/mp4">
@ -41,9 +32,12 @@
{% else %}
<img src="{{ url_for('meta.uploaded_file', filename=meme.upload_path) }}" width="200px" class="img-fluid" style="" />
{% endif %}
</a>
</div>
{% endfor %}
</div>
{% endfor %}
{% endif %}
</div>

@ -4,37 +4,33 @@
<body>
<section class="section">
<div class="container">
<h1 class="title">
SuchWowX.
</h1>
<p class="subtitle">
Memes. <strong>Interplanetary</strong>!
</p>
<a class="button" href="{{ url_for('meta.index') }}" up-preload up-follow=".container">Go Home</a>
{% include 'includes/navbar.html' %}
{% if meme %}
<div id="meme">
<div class="meme" style="padding-top:1em;">
<p>Meme: {{ meme }}</p>
<p>Upload path: {{ meme.upload_path }}</p>
<p>Meta IPFS: {{ meme.meta_ipfs_hash }}</p>
<p>Meme IPFS: {{ meme.meme_ipfs_hash }}</p>
<p>Title: {{ meme.title }}</p>
<p>Description: {{ meme.description }}</p>
<p>Creator handle: {{ meme.creator_handle }}</p>
<div id="screen">
<div class="screen">
{% if meme.upload_path.endswith('mp4') %}
<video style="max-height: 60vh!important;max-width:100%;" {% if not request.MOBILE %}autoplay{% else %}controls{% endif %} muted loop>
<source src="{{ url_for('meta.uploaded_file', filename=meme.upload_path) }}" type="video/mp4">
Your browser does not support the video tag.
</video>
{% else %}
<img src="{{ url_for('meta.uploaded_file', filename=meme.upload_path) }}"class="img-fluid" style="" />
<img src="{{ url_for('meta.uploaded_file', filename=meme.upload_path) }}" id="memeImage" />
{% endif %}
</br>
<p>Title: <strong>{{ meme.title }}</strong></p>
<p>Description: <strong>{{ meme.description }}</strong></p>
<p>Creator handle: <a href="{{ url_for('meta.creator', handle=meme.creator_handle) }}" up-layer="new">{{ meme.creator_handle }}</a></p>
<p>Meta IPFS: <a href="https://ipfs.io/ipfs/{{ meme.meta_ipfs_hash }}">{{ meme.meta_ipfs_hash }}</a></p>
<p>Meme IPFS: <a href="https://ipfs.io/ipfs/{{ meme.meme_ipfs_hash }}">{{ meme.meme_ipfs_hash }}</a></p>
<p>Meme ID: <code>{{ meme }}</code></p>
</div>
</div>
{% endif %}
</div>
</section>
</body>
</html>

Loading…
Cancel
Save