2022-06-22 13:11:22 -05:00
|
|
|
{%- import "utils.html" as utils with context -%}
|
|
|
|
{% extends "layout.html" %}
|
|
|
|
{% block content %}
|
|
|
|
|
2022-06-24 04:33:05 -05:00
|
|
|
{% if in_reply_to_object %}
|
2022-06-26 04:09:43 -05:00
|
|
|
<p>In reply to:</p>
|
2022-06-24 04:33:05 -05:00
|
|
|
{{ utils.display_object(in_reply_to_object) }}
|
|
|
|
{% endif %}
|
|
|
|
|
2022-06-22 13:11:22 -05:00
|
|
|
<form action="{{ request.url_for("admin_actions_new") }}" enctype="multipart/form-data" method="POST">
|
|
|
|
{{ utils.embed_csrf_token() }}
|
|
|
|
{{ utils.embed_redirect_url() }}
|
2022-06-26 11:07:55 -05:00
|
|
|
<p>
|
|
|
|
<select name="visibility">
|
2022-06-26 11:40:25 -05:00
|
|
|
{% for (k, v) in visibility_choices %}
|
|
|
|
<option value="{{ k }}" {% if in_reply_to_object and in_reply_to_object.visibility.name == k %}selected{% endif %}>{{ v }}</option>
|
2022-06-26 11:07:55 -05:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</p>
|
2022-06-27 13:55:44 -05:00
|
|
|
{% for emoji in emojis %}
|
2022-07-01 12:35:34 -05:00
|
|
|
<span class="ji">{{ emoji | emojify(True) | safe }}</span>
|
2022-06-27 13:55:44 -05:00
|
|
|
{% endfor %}
|
|
|
|
{% for emoji in custom_emojis %}
|
|
|
|
<span class="ji"><img src="{{ emoji.icon.url }}" alt="{{ emoji.name }}" title="{{ emoji.name }}" class="custom-emoji"></span>
|
|
|
|
{% endfor %}
|
|
|
|
|
2022-06-26 11:07:55 -05:00
|
|
|
<textarea name="content" rows="10" cols="50" autofocus="autofocus" designMode="on" style="font-size:1.2em;width:95%;">{{ content }}</textarea>
|
2022-06-28 14:10:22 -05:00
|
|
|
<p>
|
|
|
|
<input type="text" name="content_warning" placeholder="content warning (will mark the post as sensitive)" style="width:300px;">
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<input type="checkbox" name="is_sensitive" id="is_sensitive"> <label for="is_sensitive">Mark attachment(s) as sentive</label>
|
|
|
|
</p>
|
2022-06-24 04:33:05 -05:00
|
|
|
<input type="hidden" name="in_reply_to" value="{{ request.query_params.in_reply_to }}">
|
2022-06-26 04:09:43 -05:00
|
|
|
<p>
|
|
|
|
<input name="files" type="file" multiple>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<input type="submit" value="Publish">
|
|
|
|
</p>
|
2022-06-22 13:11:22 -05:00
|
|
|
</form>
|
2022-06-27 13:55:44 -05:00
|
|
|
<script>
|
|
|
|
// The new post textarea
|
|
|
|
var ta = document.getElementsByTagName("textarea")[0];
|
|
|
|
// Helper for inserting text (emojis) in the textarea
|
|
|
|
function insertAtCursor (textToInsert) {
|
|
|
|
ta.focus();
|
|
|
|
const isSuccess = document.execCommand("insertText", false, textToInsert);
|
2022-06-22 13:11:22 -05:00
|
|
|
|
2022-06-27 13:55:44 -05:00
|
|
|
// Firefox (non-standard method)
|
|
|
|
if (!isSuccess) {
|
|
|
|
// Credits to https://www.everythingfrontend.com/posts/insert-text-into-textarea-at-cursor-position.html
|
|
|
|
// get current text of the input
|
|
|
|
const value = ta.value;
|
|
|
|
// save selection start and end position
|
|
|
|
const start = ta.selectionStart;
|
|
|
|
const end = ta.selectionEnd;
|
|
|
|
// update the value with our text inserted
|
|
|
|
ta.value = value.slice(0, start) + textToInsert + value.slice(end);
|
|
|
|
// update cursor to be at the end of insertion
|
|
|
|
ta.selectionStart = ta.selectionEnd = start + textToInsert.length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Emoji click callback func
|
|
|
|
var ji = function (ev) {
|
|
|
|
insertAtCursor(ev.target.attributes.alt.value + " ");
|
|
|
|
ta.focus()
|
|
|
|
//console.log(document.execCommand('insertText', false /*no UI*/, ev.target.attributes.alt.value));
|
|
|
|
}
|
|
|
|
// Enable the click for each emojis
|
|
|
|
var items = document.getElementsByClassName("ji")
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
items[i].addEventListener('click', ji);
|
|
|
|
}
|
|
|
|
</script>
|
2022-06-22 13:11:22 -05:00
|
|
|
{% endblock %}
|