-
{{post.content | safe}} - {%- if render_sig and post.signature_rendered -%} - +
+ {%- if not is_editing -%} + {{post.content | safe}} + {%- if render_sig and post.signature_rendered -%} + + {%- endif -%} + {%- else -%} + {{- babycode_editor_component(prefill=post.original_markup) -}} {%- endif -%}
- {%- if show_reactions -%}
- - {%- for reaction in Reactions.for_post(post.id) -%} - {% set reactors = Reactions.get_users(post.id, reaction.reaction_text) | map(attribute='username') | list %} - {% set reactors_trimmed = reactors[:10] %} - {% set reactors_str = reactors_trimmed | join (',\n') %} - {% if reactors | count > 10 %} - {% set reactors_str = reactors_str + '\n...and many others' %} - {% endif %} - {% set has_reacted = get_active_user() is not none and get_active_user().username in reactors %} - - {%- endfor -%} - - {%- if is_logged_in() -%}{%- endif -%} + {%- if show_reactions -%} + + {%- for reaction in Reactions.for_post(post.id) -%} + {% set reactors = Reactions.get_users(post.id, reaction.reaction_text) | map(attribute='username') | list %} + {% set reactors_trimmed = reactors[:10] %} + {% set reactors_str = reactors_trimmed | join (',\n') %} + {% if reactors | count > 10 %} + {% set reactors_str = reactors_str + '\n...and many others' %} + {% endif %} + {% set has_reacted = get_active_user() is not none and get_active_user().username in reactors %} + + {%- endfor -%} + + {%- if is_logged_in() -%}{%- endif -%} + {%- elif is_editing -%} + + Cancel + {%- endif -%}
- {%- endif -%} +
{%- endmacro %} diff --git a/app/templates/posts/edit.html b/app/templates/posts/edit.html new file mode 100644 index 0000000..e9f9ab3 --- /dev/null +++ b/app/templates/posts/edit.html @@ -0,0 +1,24 @@ +{%- from 'common/macros.html' import full_post with context -%} +{%- extends 'base.html' -%} +{%- block title -%}editing a post{%- endblock -%} +{%- block content -%} + {%- for post in context_prev -%} +
{{- full_post(post=post, show_toolbar=false, show_reactions=false) -}}
+ {%- endfor -%} +
+ ↑↑↑ + Context + ↑↑↑ +
+
+ {{- full_post(post=post, is_editing=true, show_toolbar=false, show_reactions=false) -}} +
+
+ ↓↓↓ + Context + ↓↓↓ +
+ {%- for post in context_next -%} +
{{- full_post(post=post, show_toolbar=false, show_reactions=false) -}}
+ {%- endfor -%} +{%- endblock -%} diff --git a/app/templates/threads/thread.html b/app/templates/threads/thread.html index 9a5b53a..0086528 100644 --- a/app/templates/threads/thread.html +++ b/app/templates/threads/thread.html @@ -24,7 +24,11 @@ {%- if thread.user_id == get_active_user().id -%} Edit {%- endif -%} - +
+ + + +
{%- endif -%} Subscribe via RSS diff --git a/app/util.py b/app/util.py index a9fbf2d..6b1b9f7 100644 --- a/app/util.py +++ b/app/util.py @@ -1,6 +1,7 @@ -from flask import url_for, session +from flask import url_for, session, request from .models import Posts, Threads from .auth import is_logged_in +import time def get_post_url(post_id, _anchor=False, external=False): post = Posts.find({'id': post_id}) @@ -24,3 +25,9 @@ def get_csrf_token(): def csrf_input(): return f'' + +def get_form_checkbox(name: str) -> bool: + return request.form.get(name, None) == 'on' + +def time_now() -> int: + return int(time.time()) diff --git a/data/static/css/style.css b/data/static/css/style.css index c4cf7d4..e3f7404 100644 --- a/data/static/css/style.css +++ b/data/static/css/style.css @@ -182,7 +182,7 @@ button, .linkbutton, input[type="submit"] { } .tab-content { - + min-height: 250px; &.hidden { display: none; @@ -192,7 +192,7 @@ button, .linkbutton, input[type="submit"] { .babycode-editor { width: 100%; - height: 150px; + min-height: 150px; } .post-edit-form { @@ -620,6 +620,11 @@ form.full-width { } } +.context-explain { + display: flex; + justify-content: space-evenly; +} + /* babycode tags */ .inline-code { background-color: var(--code-bg-color);