This commit is contained in:
parent
f9bbd5e6af
commit
fbb586b56c
59
app.py
59
app.py
@ -63,6 +63,60 @@ def homepage():
|
|||||||
return render_template("main-page.html", host_id=docker_short_id, boards=board_list)
|
return render_template("main-page.html", host_id=docker_short_id, boards=board_list)
|
||||||
|
|
||||||
|
|
||||||
|
#### TODO если борды нет, то возвращать 404 мемную
|
||||||
|
#### TODO если треда нет, то возвращать 404 мемную
|
||||||
|
|
||||||
|
|
||||||
|
#### DONE route :: /{board}/
|
||||||
|
@app.route('/<board>')
|
||||||
|
def board_posts(board=None):
|
||||||
|
postos = db.collection('posts')
|
||||||
|
postos = [ p for p in postos if p.get('root_post') == True and p.get('board') == board ]
|
||||||
|
postos = sorted(postos, key=lambda posto: int(posto['_key']), reverse=False)
|
||||||
|
|
||||||
|
return render_template("board-posts.html", host_id=docker_short_id, postos=postos, target_post_id=None)
|
||||||
|
|
||||||
|
|
||||||
|
#### TODO route :: /{board}/{thread}/
|
||||||
|
#### TODO убрать отсюда чужие рут-потсы
|
||||||
|
@app.route("/<board>/<int:target_post_id>")
|
||||||
|
def thread_posts(board=None, target_post_id=None):
|
||||||
|
|
||||||
|
## взять рут-пост
|
||||||
|
## взять всех его детей
|
||||||
|
|
||||||
|
# postos = db.collection('posts')
|
||||||
|
# postos = [ p for p in postos]
|
||||||
|
# postos = sorted(postos, key=lambda posto: int(posto['_key']), reverse=False)
|
||||||
|
|
||||||
|
cursor = db.aql.execute(
|
||||||
|
f"""FOR ppp IN posts
|
||||||
|
FILTER ppp.root_post == True and ppp._key == "{target_post_id}"
|
||||||
|
FOR v IN 1 OUTBOUND ppp post_parents RETURN v"""
|
||||||
|
)
|
||||||
|
|
||||||
|
postos = [ ]
|
||||||
|
while not cursor.empty(): # Pop until nothing is left on the cursor.
|
||||||
|
postos.append(cursor.pop())
|
||||||
|
cursor = db.aql.execute(
|
||||||
|
f'RETURN DOCUMENT("posts/{target_post_id}")'
|
||||||
|
)
|
||||||
|
while not cursor.empty(): # Pop until nothing is left on the cursor.
|
||||||
|
postos.append(cursor.pop())
|
||||||
|
postos = [ p for p in postos ]
|
||||||
|
postos = sorted(postos, key=lambda posto: int(posto['_key']), reverse=False)
|
||||||
|
|
||||||
|
if not target_post_id:
|
||||||
|
target_post_id = postos[0]['_key']
|
||||||
|
|
||||||
|
return render_template("interactive-posts.html", host_id=docker_short_id, postos=postos, target_post_id=target_post_id)
|
||||||
|
|
||||||
|
#### TODO route :: /{board}/{thread}/create_thread/
|
||||||
|
|
||||||
|
#### TODO route :: /{board}/{thread}/answer_post/
|
||||||
|
|
||||||
|
#### TODO route :: /{board}/{thread}/post_to_another_post/
|
||||||
|
|
||||||
|
|
||||||
@app.route('/db_posts')
|
@app.route('/db_posts')
|
||||||
@app.route("/db_posts/<target_post_id>")
|
@app.route("/db_posts/<target_post_id>")
|
||||||
@ -72,6 +126,11 @@ def page_posts_from_db(target_post_id=None):
|
|||||||
postos = [ p for p in postos]
|
postos = [ p for p in postos]
|
||||||
postos = sorted(postos, key=lambda posto: int(posto['_key']), reverse=False)
|
postos = sorted(postos, key=lambda posto: int(posto['_key']), reverse=False)
|
||||||
|
|
||||||
|
|
||||||
|
for p in postos:
|
||||||
|
#if p['root_post']:
|
||||||
|
print(p)
|
||||||
|
|
||||||
if not target_post_id:
|
if not target_post_id:
|
||||||
target_post_id = postos[0]['_key']
|
target_post_id = postos[0]['_key']
|
||||||
|
|
||||||
|
19
templates/board-posts.html
Normal file
19
templates/board-posts.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
{% include 'navbar.html' %}
|
||||||
|
|
||||||
|
<div class="row" >
|
||||||
|
<div class="col s6 m5" id="op-posts">
|
||||||
|
{% include 'op-posts.html' %}
|
||||||
|
</div>
|
||||||
|
<!-- <div class="col s6 m5" id="thread-viz">
|
||||||
|
<iframe src="https://thread-visualizah-dev.board.vdk2ch.ru/" scrolling="no" frameborder="0" style="position: relative; height: 600px; width: 100%; margin:10px;"></iframe>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock content %}
|
@ -17,8 +17,7 @@
|
|||||||
<div class="row" id="post-{{ posto._key }}">
|
<div class="row" id="post-{{ posto._key }}">
|
||||||
|
|
||||||
{% if posto.images | length > 0 %}
|
{% if posto.images | length > 0 %}
|
||||||
<div class="col s4">
|
<div class="col s12">
|
||||||
<div class="card-image" style=" margin:10px; ">
|
|
||||||
<!-- <div class="hex-main">
|
<!-- <div class="hex-main">
|
||||||
<div class="hex-container">
|
<div class="hex-container">
|
||||||
<a href="https://loremflickr.com/g/320/240/paris" target="_blank" ">
|
<a href="https://loremflickr.com/g/320/240/paris" target="_blank" ">
|
||||||
@ -26,13 +25,23 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
<div class="nav-wrapper">
|
||||||
|
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||||
|
<li>
|
||||||
<a href="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg" target="_blank" ">
|
<a href="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg" target="_blank" ">
|
||||||
<img src="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg">
|
<img src="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg" width="300px">
|
||||||
</a>
|
</a>
|
||||||
<span class="card-title"><a class="link" href="#post-{{ posto.parent_post }}"> >>{{ posto.parent_post }} </a> </span>
|
<span class=" "><a class="" href="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg" target="_blank"> photo_2023-05-16_00-49-34.jpg </a> </span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://static.guaranteedstruggle.host/thread-pics/109.png" target="_blank" ">
|
||||||
|
<img src="https://static.guaranteedstruggle.host/thread-pics/109.png" width="300px">
|
||||||
|
</a>
|
||||||
|
<span class=" "><a class="" href="https://static.guaranteedstruggle.host/thread-pics/109.png" target="_blank"> 109.png </a> </span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- <div class="col s8">
|
<!-- <div class="col s8">
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
{% if boards | length > 0 %}
|
{% if boards | length > 0 %}
|
||||||
<p>Доски:</p>
|
<p>Доски:</p>
|
||||||
{% for board in boards %}
|
{% for board in boards %}
|
||||||
<p><a href="/db_posts" class="lime-text red collection-item" style="padding: 2px 2px;">{{board}}</a></p>
|
<p><a href="/{{board}}" class="lime-text red collection-item" style="padding: 2px 2px;">{{board}}</a></p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
53
templates/op-posts.html
Normal file
53
templates/op-posts.html
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{% if postos | length > 0 %}
|
||||||
|
{% for posto in postos %}
|
||||||
|
<div class="row">
|
||||||
|
{% if posto.root_post %}
|
||||||
|
<div class="card s5 deep-orange accent-4 darken-1">
|
||||||
|
{% else %}
|
||||||
|
<div class="card s5 blue-grey darken-1">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="card-content white-text">
|
||||||
|
<span class="new badge yellow" data-badge-caption="">
|
||||||
|
<a class="purple-text" href="#post-{{ posto._key }}"> #{{ posto._key }} </a>
|
||||||
|
</span>
|
||||||
|
<span class="new badge blue" data-badge-caption="">Ответов: {{ posto.answers_num }}</span>
|
||||||
|
<span class="new badge red" data-badge-caption="">Длина треда: {{ posto.children_num }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="row" id="post-{{ posto._key }}">
|
||||||
|
|
||||||
|
{% if posto.images | length > 0 %}
|
||||||
|
<div class="col s12">
|
||||||
|
<!-- <div class="nav-wrapper">
|
||||||
|
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||||
|
<li>
|
||||||
|
<a href="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg" target="_blank" ">
|
||||||
|
<img src="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg" width="300px">
|
||||||
|
</a>
|
||||||
|
<span class=" "><a class="" href="https://static.guaranteedstruggle.host/thread-pics/photo_2023-05-16_00-49-34.jpg" target="_blank"> photo_2023-05-16_00-49-34.jpg </a> </span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://static.guaranteedstruggle.host/thread-pics/109.png" target="_blank" ">
|
||||||
|
<img src="https://static.guaranteedstruggle.host/thread-pics/109.png" width="300px">
|
||||||
|
</a>
|
||||||
|
<span class=" "><a class="" href="https://static.guaranteedstruggle.host/thread-pics/109.png" target="_blank"> 109.png </a> </span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="col s12 card-content white-text">
|
||||||
|
<p>{{ posto.texto }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="col s12 card-action white-text">
|
||||||
|
<div class="right">
|
||||||
|
<!-- <a href="#" hx-post="/post_my_post/{{ posto._key }}" hx-target="#neu-posts" >Answer me!</a> -->
|
||||||
|
<a href="#answer-post" hx-post="/answer_post/{{ posto._key }}" hx-target="#answer-post" >В тред!</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
Loading…
Reference in New Issue
Block a user