add subscribing and unsubscribing, add post editing
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{%- from 'common/icons.html' import icn_info, icn_warn, icn_error, icn_bookmark -%}
|
||||
|
||||
{% macro timestamp(unix_ts) -%}
|
||||
<span class="timestamp" data-utc="{{ unix_ts }}">{{ unix_ts | ts_datetime('%Y-%m-%d %H:%M')}} <abbr title="Server Time">ST</abbr></span>
|
||||
{#<span class="timestamp" data-utc="{{ unix_ts }}">{{ unix_ts | ts_datetime('%Y-%m-%d %H:%M')}} <abbr title="Server Time">ST</abbr></span>#}
|
||||
<time datetime="{{ unix_ts | iso8601 }}">{{ unix_ts | ts_datetime('%Y-%m-%d %H:%M')}} <abbr title="Server Time">ST</abbr></time>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro subheader(title, desc='') -%}
|
||||
@@ -103,9 +104,9 @@
|
||||
<button type="button" class="minimal">•</button>
|
||||
<button type="button" class="minimal"><img src="/static/emoji/angry.png" class="emoji"></button>
|
||||
</span>
|
||||
<a href="##">babycode help</a>
|
||||
</span>
|
||||
<textarea name="babycode_content" id="{{id}}" class="babycode-editor" placeholder="{{placeholder}}" {{'required' if required else ''}}>{{ prefill }}</textarea>
|
||||
<a href="##">babycode help</a>
|
||||
{%- endif -%}
|
||||
{%- endcall -%}
|
||||
{%- endmacro %}
|
||||
@@ -142,11 +143,17 @@
|
||||
</div>
|
||||
<div class="post-content">
|
||||
<div class="plank even minimal secondary-bg no-shadow post-info">
|
||||
<a href="{{get_post_url(post.id, _anchor=true)}}"><i>Posted on {{timestamp(post.created_at)}}</i></a>
|
||||
<a href="{{get_post_url(post.id, _anchor=true)}}">
|
||||
{%- if post.edited_at <= post.created_at -%}
|
||||
<i>Posted on {{timestamp(post.created_at)}}</i>
|
||||
{%- else -%}
|
||||
<i>Edited on {{timestamp(post.edited_at)}}</i>
|
||||
{%- endif -%}
|
||||
</a>
|
||||
{%- if show_toolbar -%}
|
||||
<span class="thread-actions">
|
||||
{%- if owns -%}
|
||||
<a class="linkbutton" href="{{url_for('posts.edit', post_id=post.id)}}">Edit</a>
|
||||
<a class="linkbutton" href="{{url_for('posts.edit', post_id=post.id, _anchor='babycode-content')}}">Edit</a>
|
||||
{%- endif -%}
|
||||
{%- if can_reply -%}
|
||||
<button disabled title="This feature requires JavaScript to be enabled.">Quote</button>
|
||||
@@ -158,28 +165,37 @@
|
||||
</span>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
<div class="plank even no-shadow post-content-inner minimal">{{post.content | safe}}
|
||||
{%- if render_sig and post.signature_rendered -%}
|
||||
<aside class="post-signature">{{post.signature_rendered | safe}}</aside>
|
||||
<div class="plank even no-shadow post-content-inner minimal">
|
||||
{%- if not is_editing -%}
|
||||
{{post.content | safe}}
|
||||
{%- if render_sig and post.signature_rendered -%}
|
||||
<aside class="post-signature">{{post.signature_rendered | safe}}</aside>
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
{{- babycode_editor_component(prefill=post.original_markup) -}}
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{%- if show_reactions -%}
|
||||
<div class="plank even secondary-bg minimal no-shadow">
|
||||
<span class="button-row">
|
||||
{%- 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 %}
|
||||
<button disabled title="{{reactors_str}}" class="minimal {{'alt' if has_reacted else ''}}"><img src="/static/emoji/{{reaction.reaction_text}}.png">{{reaction.c}}</button>
|
||||
{%- endfor -%}
|
||||
</span>
|
||||
{%- if is_logged_in() -%}<button disabled title="This feature requires JavaScript to be enabled.">Add reaction</button>{%- endif -%}
|
||||
{%- if show_reactions -%}
|
||||
<span class="button-row">
|
||||
{%- 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 %}
|
||||
<button disabled title="{{reactors_str}}" class="minimal {{'alt' if has_reacted else ''}}"><img src="/static/emoji/{{reaction.reaction_text}}.png">{{reaction.c}}</button>
|
||||
{%- endfor -%}
|
||||
</span>
|
||||
{%- if is_logged_in() -%}<button disabled title="This feature requires JavaScript to be enabled.">Add reaction</button>{%- endif -%}
|
||||
{%- elif is_editing -%}
|
||||
<input type="submit" value="Save">
|
||||
<a href="{{get_post_url(post.id, _anchor=true)}}" class="linkbutton warn">Cancel</a>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
{%- endif -%}
|
||||
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
24
app/templates/posts/edit.html
Normal file
24
app/templates/posts/edit.html
Normal file
@@ -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 -%}
|
||||
<div class="post plank">{{- full_post(post=post, show_toolbar=false, show_reactions=false) -}}</div>
|
||||
{%- endfor -%}
|
||||
<div class="plank secondary-bg context-explain">
|
||||
<span>↑↑↑</span>
|
||||
<i>Context</i>
|
||||
<span>↑↑↑</span>
|
||||
</div>
|
||||
<form class="post plank" method="POST">
|
||||
{{- full_post(post=post, is_editing=true, show_toolbar=false, show_reactions=false) -}}
|
||||
</form>
|
||||
<div class="plank secondary-bg context-explain">
|
||||
<span>↓↓↓</span>
|
||||
<i>Context</i>
|
||||
<span>↓↓↓</span>
|
||||
</div>
|
||||
{%- for post in context_next -%}
|
||||
<div class="post plank">{{- full_post(post=post, show_toolbar=false, show_reactions=false) -}}</div>
|
||||
{%- endfor -%}
|
||||
{%- endblock -%}
|
||||
@@ -24,7 +24,11 @@
|
||||
{%- if thread.user_id == get_active_user().id -%}
|
||||
<a class="linkbutton" href="{{url_for('threads.edit', thread_id=thread.id)}}">Edit</a>
|
||||
{%- endif -%}
|
||||
<button>Subscribe</button>
|
||||
<form action="{{url_for('threads.subscribe' if not get_active_user().is_subscribed(thread.id) else 'threads.unsubscribe', thread_id=thread.id)}}" method="POST">
|
||||
<input type="hidden" name="last_post_timestamp" value="{{last_post.created_at}}">
|
||||
<input type="hidden" name="last_post_id" value="{{last_post.id}}">
|
||||
<input type="submit" value="{{'Subscribe' if not get_active_user().is_subscribed(thread.id) else 'Unsubscribe'}}">
|
||||
</form>
|
||||
<button disabled title="This feature requires JavaScript to be enabled.">{{icn_bookmark(24)}}Bookmark…</button>
|
||||
{%- endif -%}
|
||||
<a href="{{url_for('threads.feed', thread_id=thread.id)}}" class="linkbutton rss">Subscribe via RSS</a>
|
||||
|
||||
Reference in New Issue
Block a user