diff --git a/suchwowx/filters.py b/suchwowx/filters.py index ec20dbf..3acd348 100644 --- a/suchwowx/filters.py +++ b/suchwowx/filters.py @@ -6,7 +6,7 @@ bp = Blueprint('filters', 'filters') @bp.app_template_filter('shorten_address') def shorten_address(a): - _p = a[0:4] + _p = a[0:6] _s = a[-4:] return f'{_p}...{_s}' diff --git a/suchwowx/helpers.py b/suchwowx/helpers.py index a6c4105..66d134f 100644 --- a/suchwowx/helpers.py +++ b/suchwowx/helpers.py @@ -28,9 +28,9 @@ def upload_to_ipfs(meme_id: str): 'name': meme.title, 'description': meme.description, 'image': f'ipfs://{artwork_hash}', - 'by': meme.creator_handle, + 'by': meme.user.handle, 'properties': { - 'creator': meme.creator_handle + 'creator': meme.user.handle } } meta_hash = client.add_json(meta) diff --git a/suchwowx/models.py b/suchwowx/models.py index c685db7..ef81028 100644 --- a/suchwowx/models.py +++ b/suchwowx/models.py @@ -35,6 +35,7 @@ class User(db.Model): profile_image = db.Column(db.String(300), nullable=True) website_url = db.Column(db.String(120), nullable=True) moderator = db.relationship('Moderator', back_populates='user') + memes = db.relationship('Meme', back_populates='user') def __repr__(self): return str(self.handle) @@ -96,6 +97,8 @@ class Meme(db.Model): title = db.Column(db.String(50)) description = db.Column(db.String(400), nullable=True) minted = db.Column(db.Boolean, default=False) + user_id = db.Column(db.Integer, db.ForeignKey('users.id')) + user = db.relationship('User', back_populates='memes') def __repr__(self): return str(f'meme-{self.id}') diff --git a/suchwowx/routes/meme.py b/suchwowx/routes/meme.py index 2c487a8..16a5022 100644 --- a/suchwowx/routes/meme.py +++ b/suchwowx/routes/meme.py @@ -38,7 +38,7 @@ def mod(): memes = Meme.query.filter( Meme.meta_ipfs_hash == None ).order_by(Meme.create_date.asc()) - return render_template('mod.html', memes=memes) + return render_template('index.html', memes=memes) @bp.route('/publish', methods=['GET', 'POST']) def publish(): @@ -62,7 +62,6 @@ def publish(): return '' title = request.form.get('title') description = request.form.get('description') - creator = request.form.get('creator') file = request.files["file"] filename = "{}{}".format( token_urlsafe(24), @@ -75,7 +74,7 @@ def publish(): file_name=filename, title=title, description=description, - creator_handle=creator + user_id=current_user.id ) db.session.add(meme) db.session.commit() diff --git a/suchwowx/templates/includes/meme_card.html b/suchwowx/templates/includes/meme_card.html new file mode 100644 index 0000000..469a4e6 --- /dev/null +++ b/suchwowx/templates/includes/meme_card.html @@ -0,0 +1,38 @@ +{# expects meme var #} +
+
+
+ + {% if meme.file_name.endswith('mp4') %} + + {% else %} + {{ meme.title }} + {% endif %} + +
+
+
+
+
+ {% if meme.user.profile_image %} +
+ {{ meme.user.handle }} pfp +
+ {% endif %} +
+
+

{{ meme.user.handle }}

+

{{ meme.user.public_address | shorten_address }}

+
+
+ +
+ {{ meme.description }} +
+ +
+
+
diff --git a/suchwowx/templates/includes/navbar.html b/suchwowx/templates/includes/navbar.html index 765690c..2382709 100644 --- a/suchwowx/templates/includes/navbar.html +++ b/suchwowx/templates/includes/navbar.html @@ -18,6 +18,6 @@ Connect {% endif %} {% else %} - Go Home + Go Home {% endif %} diff --git a/suchwowx/templates/index.html b/suchwowx/templates/index.html index 2369dbe..036b6dd 100644 --- a/suchwowx/templates/index.html +++ b/suchwowx/templates/index.html @@ -19,44 +19,8 @@ {% if memes %} {% for _meme in memes | batch(4) %}
- {% for meme in _meme %} -
- -
-
-
- -
-
-

John Smith

-

@johnsmith

-
-
- -
- {{ meme.description }} -
- -
-
-
- + {% include 'includes/meme_card.html' %} {% endfor %}
{% endfor %} diff --git a/suchwowx/templates/meme.html b/suchwowx/templates/meme.html index 10273e8..84e2bb7 100644 --- a/suchwowx/templates/meme.html +++ b/suchwowx/templates/meme.html @@ -30,7 +30,7 @@

Title: {{ meme.title }}

Description: {{ meme.description }}

-

Creator handle: {{ meme.creator_handle }}

+

Poster Address: {{ meme.user.handle }}

{% if meme.meta_ipfs_hash %}

Meta IPFS: {{ meme.meta_ipfs_hash }}

{% endif %} diff --git a/suchwowx/templates/mod.html b/suchwowx/templates/mod.html deleted file mode 100644 index 88e45ac..0000000 --- a/suchwowx/templates/mod.html +++ /dev/null @@ -1,59 +0,0 @@ - - - {% include 'includes/head.html' %} - -
-
- {% include 'includes/navbar.html' %} - - {% if memes %} - {% for _meme in memes | batch(4) %} -
- - {% for meme in _meme %} -
- -
-
-
- -
-
-

John Smith

-

@johnsmith

-
-
- -
- {{ meme.description }} -
- -
-
-
- - {% endfor %} -
- {% endfor %} - {% endif %} - -
-
- {% include 'includes/footer.html' %} - - diff --git a/suchwowx/templates/profile.html b/suchwowx/templates/profile.html index cc49d63..76e1048 100644 --- a/suchwowx/templates/profile.html +++ b/suchwowx/templates/profile.html @@ -11,14 +11,16 @@

From Avax Chain

-

Handle: +

Handle: ?



From Local Database

+

Handle:

Register Date: {{ user.register_date }}

Login Date: {{ user.last_login_date }}

Moderator: {{ user.is_moderator() }}

Verified: {{ user.verified }}

+

Memes Posted: {{ user.memes | length }}

{% if user.bio %}

Bio: {{ user.bio }}

{% endif %} diff --git a/suchwowx/templates/publish.html b/suchwowx/templates/publish.html index 4a66694..40221f2 100644 --- a/suchwowx/templates/publish.html +++ b/suchwowx/templates/publish.html @@ -28,9 +28,9 @@
- +
- +

{{ current_user.public_address }}