test linked display

mako
km0 3 years ago
parent 0767c14eea
commit 325fe7e332

@ -34,3 +34,14 @@ def display():
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')
def linked():
db = get_db()
branches = db.execute(
"SELECT content, branch, parent, username FROM branches"
).fetchall()
return render_template('display_linked_mako.html', branches=branches)

@ -1,3 +1,8 @@
.container{
display: block;
padding: 1000px;
}
.streams { .streams {
overflow-x: auto; overflow-x: auto;
overflow-y: hidden; overflow-y: hidden;
@ -9,13 +14,11 @@
.stream { .stream {
white-space: nowrap; white-space: nowrap;
position: absolute; position: relative;
display: inline-block; display: inline-block;
width: 500px; width: 500px;
height: 500px; height: 500px;
position: relative; position: relative;
top: 5000px;
left: 5000px;
} }
.svg-container { .svg-container {

@ -0,0 +1,46 @@
<%inherit file="base_mako.html" />
<%block name="head">
<link rel="stylesheet" href="${url_for('static', filename='css/display_mako.css')}">
</%block>
<main class="container">
<% from random import random %>
<% from collections import defaultdict %>
<% transform = {'NEW': ''} %>
<% visited = defaultdict(int) %>
<div class="stream">
% for branch in branches:
<% visited[branch['parent']] += 1 %>
% if visited[branch['parent']] > 1:
<% steer = (random() - 0.5) * 0.5 %>
% else:
<% steer = 0 %>
% endif
<% transform[branch['branch']] = f'{transform[branch["parent"]]} rotate({random() * 0.04 + steer}turn) translateX(100%)' %>
<div class="svg-container" style="transform: ${transform[branch['parent']]}">
<a href="/draw/${branch['branch']}" target="__blank">
${branch['content']}
</a>
</div>
% endfor
</div>
</main>
Loading…
Cancel
Save