renovation label and small fixes in templates. linked list by default in view pages (sooo to be fixed)

main
km0 6 months ago
parent d9483f63b2
commit 85087c9f56

@ -1,43 +1,41 @@
from flask import (Blueprint, flash, g, redirect,
request, session, url_for)
from flask import (Blueprint)
from flask_mako import render_template
from exquisite_branch.db import get_db
bp = Blueprint('display', __name__, url_prefix='/display')
@bp.route('/')
def display():
db = get_db()
# @bp.route('/')
# def display():
# db = get_db()
branches = db.execute(
"SELECT content, branch, parent, username FROM branches"
).fetchall()
# branches = db.execute(
# "SELECT content, branch, parent, username FROM branches"
# ).fetchall()
streams = []
for branch in branches[::-1]:
if branch not in flatten(streams):
stream = [branch]
parent = branch['parent']
while parent != 'NEW':
current = next(
(x for x in branches if x['branch'] == parent), None)
parent = current['parent']
stream.append(current)
# streams = []
# for branch in branches[::-1]:
# if branch not in flatten(streams):
# stream = [branch]
# parent = branch['parent']
# while parent != 'NEW':
# current = next(
# (x for x in branches if x['branch'] == parent), None)
# parent = current['parent']
# stream.append(current)
streams.append(stream[::-1])
# streams.append(stream[::-1])
return render_template('display_mako.html', branches=branches, streams=streams)
# return render_template('display_mako.html', branches=branches, streams=streams)
def flatten(t):
return [item for sublist in t for item in sublist]
# def flatten(t):
# return [item for sublist in t for item in sublist]
@bp.route('/linked')
def linked():
@bp.route('/')
def display():
db = get_db()
branches = db.execute(

@ -4,7 +4,20 @@ from flask import (Blueprint, flash, g, redirect,
from exquisite_branch.db import get_db
from werkzeug.exceptions import abort
from shortuuid import uuid
import shortuuid
import uuid
def get_uuid(d=7):
'''return a short uuid (default 7 chars)'''
u = uuid.uuid4()
s = shortuuid.encode(u)
return s[:d]
bp = Blueprint('draw', __name__, url_prefix='/draw')
@ -31,7 +44,8 @@ def draw(parent=None):
print(url_for('share.share', branch=f"{branch}"))
return redirect(url_for('share.share', branch=branch))
branch = uuid()
branch = get_uuid()
previous = db.execute(
"SELECT content, branch, parent FROM branches"
@ -48,7 +62,7 @@ def draw(parent=None):
@bp.route('/last', methods=('GET', 'POST'))
def last():
branch = uuid()
branch = get_uuid()
db = get_db()
previous = db.execute(
'SELECT * FROM branches ORDER BY id DESC LIMIT 1'
@ -74,7 +88,7 @@ def last():
@bp.route('/', methods=('GET', 'POST'))
def new():
db = get_db()
branch = uuid()
branch = get_uuid()
parent = 'NEW'
if request.method == 'POST':

@ -13,8 +13,8 @@
<body>
<nav>
<%block name='nav' >
<a href="{{url_for('home.home')}}">Home</a>
<a href="{{url_for('display.display')}}">Results</a>
<a href="${url_for('home.home')}">Home</a>
<a href="${url_for('display.display')}">Results</a>
</%block>
</nav>
${self.body()}

@ -1,15 +1,12 @@
<%inherit file="base_mako.html" />
<%block name="head">
<link rel="stylesheet" href="${url_for('static', filename='css/display_mako.css')}">
<link rel="stylesheet" href="${url_for('static', filename='css/display_mako.css')}">
</%block>
<% from random import random %>
<% offset = 1 / (len(streams) - 1)%>
<% offset = 1 / (len(streams) + 1)%>
% for stream in streams:
<div class="stream">
<% transform = f'rotate({offset * loop.index}turn) translateX(100%) ' %>

@ -8,6 +8,20 @@
<link rel="stylesheet" href="{{url_for('static', filename='css/variables.css')}}" />
<link rel="stylesheet" href="{{url_for('static', filename='css/global.css')}}" />
<link rel="stylesheet" href="{{url_for('static', filename='css/home.css')}}" />
<style>
.renovation
{
background-color: yellow;
display: inline-block;
transform: translateY(-90px) rotate(10deg);
padding: 8px;
font-size: 0.88rem;
font-family: 'Brush Script MT', cursive;
}
</style>
</head>
<body>
<header class="title">
@ -17,6 +31,7 @@
></object>
<h1>really exquisite indeed</h1>
<span class='renovation'>RENOVATION IN PROGRESS!</span>
</header>
<main>
<a href="{{url_for('draw.new')}}">Start new</a> <br />

Loading…
Cancel
Save