setup per meme views, use html includes

main
lza_menace 3 years ago
parent 49eb1470f5
commit 8e3a6338c7

@ -2,6 +2,7 @@ from uuid import uuid4
from datetime import datetime
from suchwowx.factory import db
from suchwowx import config
def rand_id():

@ -3,7 +3,8 @@ from os import path
from secrets import token_urlsafe
from json import loads, dumps
from flask import Blueprint, render_template, request, current_app, redirect
from flask import Blueprint, render_template, request, current_app
from flask import send_from_directory, redirect
from suchwowx.models import Meme
from suchwowx.factory import db
@ -12,6 +13,11 @@ from suchwowx import config
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)
@bp.route('/new', methods=['GET', 'POST'])
def new():
meme = None
@ -67,7 +73,16 @@ def new():
meme=meme
)
@bp.route('/')
def index():
memes = Meme.query.filter().order_by(Meme.create_date.desc())
return render_template('index.html', memes=memes)
@bp.route('/uploads/<path:filename>')
def uploaded_file(filename):
"""
Retrieve an uploaded file from uploads directory.
"""
return send_from_directory(f'{config.DATA_FOLDER}/uploads', filename)
@bp.route('/meme/<meme_id>')
def meme(meme_id):
meme = Meme.query.filter(Meme.id == meme_id).first()
if not meme:
return redirect('/')
return render_template('meme.html', meme=meme)

@ -0,0 +1,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuchWowX!</title>
<script src="https://unpkg.com/unpoly@2.5.0/unpoly.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/unpoly@2.5.0/unpoly.min.css">
<link rel="stylesheet" href="/static/css/bulma.min.css">
<link rel="stylesheet" href="/static/css/bulma.css.map">
</head>

@ -1,20 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuchWowX!</title>
<script src="https://unpkg.com/unpoly@2.5.0/unpoly.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/unpoly@2.5.0/unpoly.min.css">
<link rel="stylesheet" href="/static/css/bulma.min.css">
<link rel="stylesheet" href="/static/css/bulma.css.map">
</head>
{% include 'includes/head.html' %}
<body>
<section class="section">
<div class="container">
<h1 class="title">
SuchWowX. <br/>
SuchWowX.
</h1>
<p class="subtitle">
Memes. <strong>Interplanetary</strong>!
@ -25,7 +16,7 @@
<div id="memes">
{% for meme in memes %}
<div class="meme" style="padding-top:1em;">
<p>Meme: {{ meme }}</p>
<p>Meme: <a href="{{ url_for('meta.meme', meme_id=meme.id) }}" up-target=".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>

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
{% include 'includes/head.html' %}
<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-target=".container">Go Home</a>
{% 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>
<img src="{{ url_for('meta.uploaded_file', filename=meme.upload_path) }}">
</div>
</div>
{% endif %}
</div>
</section>
</body>
</html>

@ -1,27 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SuchWowX!</title>
<script src="https://unpkg.com/unpoly@2.5.0/unpoly.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/unpoly@2.5.0/unpoly.min.css">
<link rel="stylesheet" href="/static/css/bulma.min.css">
<link rel="stylesheet" href="/static/css/bulma.css.map">
</head>
{% include 'includes/head.html' %}
<body>
<section class="section">
<div class="container">
<h1 class="title">
SuchWowX. <br/>
SuchWowX.
</h1>
<p class="subtitle">
Memes. <strong>Interplanetary</strong>!
</p>
<a class="button" href="{{ url_for('meta.index') }}" up-target=".container">Go Back</a>
<form method="POST" enctype="multipart/form-data" class="site-form" id="memeUpload" action="{{ url_for('meta.new') }}">
<form method="POST" enctype="multipart/form-data" class="site-form" id="memeUpload" action="{{ url_for('meta.new') }}" style="padding-top:1.5em;">
<div class="field">
<label class="label">File</label>
<div class="control">

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/unpoly@2.5.0/unpoly.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/unpoly@2.5.0/unpoly.min.css">
</head>
<body>
<!-- HTML here may use Unpoly attributes like [up-follow] -->
<a href="/" class="one" up-target=".one">
&hearts;
</a>
<a href="/" class="two" up-target=".two">
&spades;
</a>
</body>
</html>
Loading…
Cancel
Save