mirror of
https://github.com/jwinterm/tubbymemes.git
synced 2026-10-17 05:21:28 +02:00
remove auth requirement for posting
This commit is contained in:
@@ -30,10 +30,7 @@ def upload_to_ipfs(meme_id: str):
|
|||||||
'image': f'ipfs://{artwork_hash}',
|
'image': f'ipfs://{artwork_hash}',
|
||||||
'create_date': meme.create_date.strftime('%Y-%m-%d %H:%M:%S'),
|
'create_date': meme.create_date.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
'file_name': meme.file_name,
|
'file_name': meme.file_name,
|
||||||
'ipfs_hash': artwork_hash,
|
'ipfs_hash': artwork_hash
|
||||||
'properties': {
|
|
||||||
'creator_address': meme.user.public_address
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
meta_hash = client.add_json(meta)
|
meta_hash = client.add_json(meta)
|
||||||
print(f'[+] Uploaded metadata to IPFS: {meta_hash}')
|
print(f'[+] Uploaded metadata to IPFS: {meta_hash}')
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ def mod():
|
|||||||
|
|
||||||
@bp.route('/publish', methods=['GET', 'POST'])
|
@bp.route('/publish', methods=['GET', 'POST'])
|
||||||
def publish():
|
def publish():
|
||||||
if not current_user.is_authenticated:
|
|
||||||
flash('You need to connect your wallet first.', 'warning')
|
|
||||||
return redirect(url_for('meme.index'))
|
|
||||||
meme = None
|
meme = None
|
||||||
try:
|
try:
|
||||||
client = ipfsApi.Client('127.0.0.1', 5001)
|
client = ipfsApi.Client('127.0.0.1', 5001)
|
||||||
@@ -64,16 +61,19 @@ def publish():
|
|||||||
)
|
)
|
||||||
full_path = f'{config.DATA_FOLDER}/uploads/{filename}'
|
full_path = f'{config.DATA_FOLDER}/uploads/{filename}'
|
||||||
file.save(full_path)
|
file.save(full_path)
|
||||||
|
id = None
|
||||||
|
if current_user.is_authenticated:
|
||||||
|
id = current_user.id
|
||||||
try:
|
try:
|
||||||
meme = Meme(
|
meme = Meme(
|
||||||
file_name=filename,
|
file_name=filename,
|
||||||
title=title,
|
title=title,
|
||||||
description=description,
|
description=description,
|
||||||
user_id=current_user.id
|
user_id=id
|
||||||
)
|
)
|
||||||
db.session.add(meme)
|
db.session.add(meme)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
if current_user.verified or current_user.moderator:
|
if current_user.is_authenticated and (current_user.verified or current_user.moderator):
|
||||||
res = upload_to_ipfs(meme.id)
|
res = upload_to_ipfs(meme.id)
|
||||||
meme.meta_ipfs_hash = res[0]
|
meme.meta_ipfs_hash = res[0]
|
||||||
meme.meme_ipfs_hash = res[1]
|
meme.meme_ipfs_hash = res[1]
|
||||||
|
|||||||
@@ -27,9 +27,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="media-content">
|
<div class="media-content">
|
||||||
<p class="title is-4">{{ meme.title }}</p>
|
<p class="title is-4">{{ meme.title }}</p>
|
||||||
|
{#
|
||||||
<p class="subtitle is-6">
|
<p class="subtitle is-6">
|
||||||
<a href="{{ meme.user.public_address | show_etherscan }}" target="_blank">({{ meme.user.public_address | shorten_address }})</a>
|
<a href="{{ meme.user.public_address | show_etherscan }}" target="_blank">({{ meme.user.public_address | shorten_address }})</a>
|
||||||
</p>
|
</p>
|
||||||
|
#}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,10 @@
|
|||||||
{% if current_user.moderator %}
|
{% if current_user.moderator %}
|
||||||
<a class="button is-warning" href="{{ url_for('meme.mod') }}" up-preload up-follow=".container">Mod</a>
|
<a class="button is-warning" href="{{ url_for('meme.mod') }}" up-preload up-follow=".container">Mod</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="button is-primary" href="{{ url_for('meme.publish') }}" up-follow=".container">New Meme</a>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="button is-primary" id="metamaskConnect" onclick="onboardMetaMask();">Connect</a>
|
<a class="button is-warning" id="metamaskConnect" onclick="onboardMetaMask();">Connect</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<a class="button is-primary" href="{{ url_for('meme.publish') }}" up-follow=".container">New Meme</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
</a>
|
</a>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p><strong>Poster Address: </strong></br><span style="word-wrap: break-word"><a href="{{ meme.user.public_address | show_etherscan }}" target="_blank">{{ meme.user.public_address }}</a></span></p>
|
|
||||||
{% if meme.meta_ipfs_hash %}
|
{% if meme.meta_ipfs_hash %}
|
||||||
<p><strong>Metadata IPFS:</strong></br><a href="{{ meta_url }}" target="_blank">{{ meme.meta_ipfs_hash }}</a></p>
|
<p><strong>Metadata IPFS:</strong></br><a href="{{ meta_url }}" target="_blank">{{ meme.meta_ipfs_hash }}</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -15,13 +15,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label class="label">Poster Address</label>
|
|
||||||
<div class="control">
|
|
||||||
<p>{{ current_user.public_address }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Title</label>
|
<label class="label">Title</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
|||||||
Reference in New Issue
Block a user