From 325fe7e332877120d2dda2ef16b656b5a59dfc0b Mon Sep 17 00:00:00 2001 From: Francesco Luzzana Date: Mon, 23 May 2022 17:17:52 +0200 Subject: [PATCH] test linked display --- exquisite_branch/display.py | 11 +++++ exquisite_branch/static/css/display_mako.css | 9 ++-- .../templates/display_linked_mako.html | 46 +++++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 exquisite_branch/templates/display_linked_mako.html diff --git a/exquisite_branch/display.py b/exquisite_branch/display.py index ba6e120..3559c05 100644 --- a/exquisite_branch/display.py +++ b/exquisite_branch/display.py @@ -34,3 +34,14 @@ def display(): def flatten(t): 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) \ No newline at end of file diff --git a/exquisite_branch/static/css/display_mako.css b/exquisite_branch/static/css/display_mako.css index d7b44fe..2dc4686 100644 --- a/exquisite_branch/static/css/display_mako.css +++ b/exquisite_branch/static/css/display_mako.css @@ -1,3 +1,8 @@ + +.container{ + display: block; + padding: 1000px; +} .streams { overflow-x: auto; overflow-y: hidden; @@ -9,13 +14,11 @@ .stream { white-space: nowrap; - position: absolute; + position: relative; display: inline-block; width: 500px; height: 500px; position: relative; - top: 5000px; - left: 5000px; } .svg-container { diff --git a/exquisite_branch/templates/display_linked_mako.html b/exquisite_branch/templates/display_linked_mako.html new file mode 100644 index 0000000..1e3fdc2 --- /dev/null +++ b/exquisite_branch/templates/display_linked_mako.html @@ -0,0 +1,46 @@ + + + + +<%inherit file="base_mako.html" /> + + +<%block name="head"> + + + + +
+ + + <% from random import random %> + <% from collections import defaultdict %> + <% transform = {'NEW': ''} %> + <% visited = defaultdict(int) %> + +
+ + % 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%)' %> + + + + % endfor +
+
\ No newline at end of file