Compare commits
No commits in common. 'main' and 'mako' have entirely different histories.
@ -1,57 +0,0 @@
|
||||
# Xquisite Branch
|
||||
|
||||
A branching version of the [exquisite corpse](https://en.wikipedia.org/wiki/Exquisite_corpse) game. A drawing app developed for [SI17](https://issue.xpub.nl/17/).
|
||||
|
||||
Draw something, upload it and send the link to someone else: they will continue from your drawing. But wait! There's a catch!!!!! If you send to just one person the chain will continue linearly, but send it to more people and things will start branching in different directions.
|
||||
|
||||
## Install
|
||||
|
||||
Clone the repository.
|
||||
```
|
||||
git clone https://git.xpub.nl/kamo/exquisite-branch.git
|
||||
```
|
||||
|
||||
Create a virtual environment.
|
||||
```
|
||||
python3 -m venv venv
|
||||
```
|
||||
|
||||
Install the requirements with `pip` and the `requirements.txt` file.
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Create an `.env` file in the root folder of the project with the following variables:
|
||||
```
|
||||
DEBUG=True
|
||||
FLASK_ENV=development
|
||||
FLASK_APP=exquisite_branch
|
||||
```
|
||||
|
||||
Before running the app for the first time, be sure to initialize the database. __Watch out:__ this will delete the previous instance of the database along with its contents!
|
||||
```
|
||||
flask init-db
|
||||
```
|
||||
After initializing the database you can run the flask application
|
||||
```
|
||||
flask run
|
||||
```
|
||||
|
||||
## Overview
|
||||
|
||||
_Xquisite Branch_ saves contents in a database, and join them together in a branching version of the exquisite corpse.
|
||||
|
||||
The original exquisite corpse data structure is something similar to a linked list, where every drawing is connected to the previous one. Contents in _Xquisite Branch_ are saved in a database with the same principle.
|
||||
|
||||
Each entry in the database has the following properties:
|
||||
|
||||
- `id`: a unique identifier for every entry
|
||||
- `branch`: a random name for the excerpt
|
||||
- `parent`: the random name of the previous excerpt
|
||||
- `content`: the actual content of the writings
|
||||
- `username`: the author of the excerpt
|
||||
|
||||
When generating the display page, every entry look up its `parent` property to position itself after that.
|
||||
|
||||
Mhh should rewrite this better bc is super convoluted ahah.
|
||||
|
@ -1,45 +1,47 @@
|
||||
from flask import (Blueprint)
|
||||
from flask import (Blueprint, flash, g, redirect,
|
||||
request, session, url_for)
|
||||
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('/')
|
||||
def display():
|
||||
@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)
|
||||
return render_template('display_linked_mako.html', branches=branches)
|
@ -1,18 +1,21 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<%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