add reusable babycode editor

This commit is contained in:
2025-05-24 02:45:54 +03:00
parent ec3f144b4e
commit 66318698e5
10 changed files with 116 additions and 33 deletions

View File

@ -1,10 +1,6 @@
<%
local is_locked = ntob(thread.is_locked)
local can_post = (not is_locked and not me:is_guest()) or me:is_mod()
-- not locked, not guest, not mod = not false and not false or false = true and true or false = true
-- locked, not guest, not mod = not true and not false or false = false and true or false = false
-- not locked, guest, not mod = not false and not true or false = true and false or false = false
-- not locked, not guest, mod = not false and not false or true = true and true and true
%>
<main>
<nav class="darkbg">
@ -24,10 +20,7 @@
<% render("views.common.infobox", {kind = constants.InfoboxKind.LOCK, msg = "This thread is locked."}) %>
<% end -%>
<% if can_post then %>
<h1>Respond to "<%= thread.title %>"</h1>
<form method="post">
<textarea id="post_content" name="post_content" placeholder="Response body" rows=7 required></textarea><br>
<input type="submit" value="Post reply">
</form>
<script src="/static/js/thread.js"></script>
<h1>Respond to "<%= thread.title %>"</h1>
<% render("views.common.babycode-editor", {ta_name="post_content"}) %>
<script src="/static/js/thread.js"></script>
<% end %>