renovation label and small fixes in templates. linked list by default in view pages (sooo to be fixed)
parent
d9483f63b2
commit
85087c9f56
@ -1,47 +1,45 @@
|
|||||||
from flask import (Blueprint, flash, g, redirect,
|
from flask import (Blueprint)
|
||||||
request, session, url_for)
|
|
||||||
from flask_mako import render_template
|
from flask_mako import render_template
|
||||||
|
|
||||||
from exquisite_branch.db import get_db
|
from exquisite_branch.db import get_db
|
||||||
|
|
||||||
|
|
||||||
bp = Blueprint('display', __name__, url_prefix='/display')
|
bp = Blueprint('display', __name__, url_prefix='/display')
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/')
|
# @bp.route('/')
|
||||||
def display():
|
# def display():
|
||||||
db = get_db()
|
# db = get_db()
|
||||||
|
|
||||||
branches = db.execute(
|
# branches = db.execute(
|
||||||
"SELECT content, branch, parent, username FROM branches"
|
# "SELECT content, branch, parent, username FROM branches"
|
||||||
).fetchall()
|
# ).fetchall()
|
||||||
|
|
||||||
streams = []
|
# streams = []
|
||||||
for branch in branches[::-1]:
|
# for branch in branches[::-1]:
|
||||||
if branch not in flatten(streams):
|
# if branch not in flatten(streams):
|
||||||
stream = [branch]
|
# stream = [branch]
|
||||||
parent = branch['parent']
|
# parent = branch['parent']
|
||||||
while parent != 'NEW':
|
# while parent != 'NEW':
|
||||||
current = next(
|
# current = next(
|
||||||
(x for x in branches if x['branch'] == parent), None)
|
# (x for x in branches if x['branch'] == parent), None)
|
||||||
parent = current['parent']
|
# parent = current['parent']
|
||||||
stream.append(current)
|
# 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):
|
# def flatten(t):
|
||||||
return [item for sublist in t for item in sublist]
|
# return [item for sublist in t for item in sublist]
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/linked')
|
@bp.route('/')
|
||||||
def linked():
|
def display():
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
|
||||||
branches = db.execute(
|
branches = db.execute(
|
||||||
"SELECT content, branch, parent, username FROM branches"
|
"SELECT content, branch, parent, username FROM branches"
|
||||||
).fetchall()
|
).fetchall()
|
||||||
|
|
||||||
return render_template('display_linked_mako.html', branches=branches)
|
return render_template('display_linked_mako.html', branches=branches)
|
||||||
|
@ -1,21 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<%inherit file="base_mako.html" />
|
<%inherit file="base_mako.html" />
|
||||||
|
|
||||||
<%block name="head">
|
<%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>
|
</%block>
|
||||||
|
|
||||||
<% from random import random %>
|
<% from random import random %>
|
||||||
<% offset = 1 / (len(streams) - 1)%>
|
<% offset = 1 / (len(streams) + 1)%>
|
||||||
|
|
||||||
% for stream in streams:
|
% for stream in streams:
|
||||||
<div class="stream">
|
<div class="stream">
|
||||||
<% transform = f'rotate({offset * loop.index}turn) translateX(100%) ' %>
|
<% transform = f'rotate({offset * loop.index}turn) translateX(100%) ' %>
|
||||||
% for branch in stream:
|
% for branch in stream:
|
||||||
<% transform = transform + ' rotate(' + str((random() * 2 - 1) * 0.02) + 'turn) translateX(100%)'%>
|
<% transform = transform + ' rotate(' + str((random() * 2 - 1) * 0.02) + 'turn) translateX(100%)'%>
|
||||||
<div class="svg-container" style="transform: ${transform}">${branch['content']}</div>
|
<div class="svg-container" style="transform: ${transform}">${branch['content']}</div>
|
||||||
% endfor
|
% endfor
|
||||||
</div>
|
</div>
|
||||||
% endfor
|
% endfor
|
||||||
|
Loading…
Reference in New Issue