Skip to content

Commit

Permalink
[fix
Browse files Browse the repository at this point in the history
  • Loading branch information
boke0 committed Mar 14, 2021
1 parent f4e5ab2 commit 88f542f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
11 changes: 11 additions & 0 deletions kyokusui/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ def retrieve(self, request):
"boards": Board.list_subscribed(request.user)
})

def log(self, request):
template = self.view.get_template("log.html")
board = Board.retrieve(request.params['board'])
thread = Thread.retrieve(request.params['thread'])
return Response.render(template, {
"board": board,
"thread": thread,
"boards": Board.list_subscribed(request.user)
})

def update(self, request):
thread = Thread.retrieve(request.params['thread'])
form = UpdateThreadForm(request.post())
Expand Down Expand Up @@ -214,6 +224,7 @@ def handle(self, request):
},
"user": {
"_id": res.user._id,
"icon": res.user.icon_to_dataurl(),
"name": res.user.name,
"screen_name": res.user.screen_name
},
Expand Down
2 changes: 2 additions & 0 deletions kyokusui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class App(App):
view("/settings", HomeController, 'settings'),
view("/static/<path:path>", static_files()),
view("/<board>", BoardController, 'retrieve'),
view("/<board>/logs", BoardController, 'logs'),
view("/<board>/logs/<thread>", ThreadController, 'log'),
view("/<board>/<thread>", ThreadController, 'retrieve'),
view("/user/<user>/icon", UserController, 'icon'),
post("/api/v0/board", BoardController, 'create'),
Expand Down
5 changes: 5 additions & 0 deletions kyokusui/templates/board.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ <h2 id='title'>{{ board.name }}</h2>
<button class='btn btn-primary' data-bs-toggle='modal' data-bs-target='#thread_form'>スレッドを立てる</button>
</div>
</div>
<!--
<div class='mt-3 mb-3 d-flex justify-content-end'>
<a href='{{ url('/' + board._id + '/logs') }}'>過去ログ</a>
</div>
-->
<div class='list-group mt-4'>
{% for thread in board.threads|selectattr('closed', 'false') %}
<a href='{{ url('/' + board._id + '/' + thread._id) }}' class='list-group-item list-group-item-action'>
Expand Down
49 changes: 49 additions & 0 deletions kyokusui/templates/log.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% extends "base.html" %}
{% block main %}
{% include "components/thread_form.html" %}
<div class='container'>
<div id='messages'>
<header class='card mb-3'>
<div class='card-body'>
<span class='badge bg-secondary'>過去ログ</span>
<h2 id="title" class='card-title mb-4'>{{ thread.title }}</h2>
<div class='d-flex justify-content-between'>
{{ lists.userItem(request.user, small=True) }}
{% if thread.user == request.user %}
<button class='btn bi bi-gear-fill' onclick='edit()'></button>
{% endif %}
</div>
<div class='card-text d-flex justify-content-end'><small class='text-muted'>{{ thread.created.strftime('%Y-%m-%d %H:%M:%S') }}</small></div>
</div>
</header>
{% for res in thread.res|sort(attribute='datetime') %}
<div class='card mb-3' id="{{loop.index}}">
<div class='card-body'>
<div class='mb-2 d-flex justify-content-between'>
<span class='badge bg-secondary'>#{{loop.index}}</span>
<div class='card-text'><small class='text-muted'>{{ res.datetime.strftime('%Y-%m-%d %H:%M:%S') }}</small></div>
</div>
<div class='mb-3'>
{{ lists.userItem(res.user, small=True) }}
</div>
{{ res.parsed_data.message|hiroyuki|markdown }}
<div class='image-list'>
{% for image in res.parsed_data.images %}
{% set s = uuid() %}
<div class='image' data-bs-toggle='modal' data-bs-target='#img-{{s}}'>
<img src='{{ image }}' />
</div>
<div id='img-{{s}}' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<img src='{{ image }}' style='width: 100%; height: 100%'/>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
15 changes: 11 additions & 4 deletions kyokusui/templates/thread.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,19 @@ <h5 class='modal-title'>スレッドを締めますか?</h5>
mesbox.classList.add("mb-3")
mesbox.innerHTML = `
<div class='card-body'>
<div class='d-flex justify-content-between'>
<div class='card-title d-flex align-items-center'>
<div class='me-2'><strong>#${counter}</strong></div>
</div>
<div class='mb-2 d-flex justify-content-between'>
<span class='badge bg-secondary'>#${counter}</span>
<div class='card-text'><small class='text-muted'>${received.datetime}</small></div>
</div>
<div class='mb-3'>
<div class="user-item small">
<img src='${received.user.icon}' class='icon' />
<div class='detail'>
<div class='name'>${received.user.name}</div>
<div class='screen-name'>${received.user.screen_name}</div>
</div>
</div>
</div>
${data.message}
<div class='image-list'>` + (Array.from(data.images ? data.images : []).map((image, i) => `
<div class='image' data-bs-toggle='modal' data-bs-target='#img-${received._id}-${i}'>
Expand Down

0 comments on commit 88f542f

Please sign in to comment.