forked from kamo/exquisite-branch
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,
|
||||
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(
|
||||
"SELECT content, branch, parent, username FROM branches"
|
||||
).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" />
|
||||
|
||||
<%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%) ' %>
|
||||
% for branch in stream:
|
||||
% for branch in stream:
|
||||
<% transform = transform + ' rotate(' + str((random() * 2 - 1) * 0.02) + 'turn) translateX(100%)'%>
|
||||
<div class="svg-container" style="transform: ${transform}">${branch['content']}</div>
|
||||
% endfor
|
||||
</div>
|
||||
% endfor
|
||||
% endfor
|
||||
|
Loading…
Reference in New Issue