microblog.pub/app/templates/admin_new.html

84 lines
3.1 KiB
HTML
Raw Normal View History

2022-06-22 20:11:22 +02:00
{%- import "utils.html" as utils with context -%}
{% extends "layout.html" %}
2022-07-15 20:01:55 +02:00
{% block head %}
<title>{{ local_actor.display_name }} - New</title>
{% endblock %}
2022-06-22 20:11:22 +02:00
{% block content %}
2022-06-24 11:33:05 +02:00
{% if in_reply_to_object %}
2022-07-09 08:15:33 +02:00
<div class="actor-action">In reply to:</div>
2022-06-24 11:33:05 +02:00
{{ utils.display_object(in_reply_to_object) }}
{% endif %}
2022-07-09 08:15:33 +02:00
<div class="box">
2022-07-03 22:01:47 +02:00
<form class="form" action="{{ request.url_for("admin_actions_new") }}" enctype="multipart/form-data" method="POST">
2022-06-22 20:11:22 +02:00
{{ utils.embed_csrf_token() }}
{{ utils.embed_redirect_url() }}
<p>
<select name="visibility">
{% 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>
{% endfor %}
</select>
</p>
2022-06-27 20:55:44 +02:00
{% for emoji in emojis %}
2022-07-01 19:35:34 +02:00
<span class="ji">{{ emoji | emojify(True) | safe }}</span>
2022-06-27 20:55:44 +02: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-07-03 22:01:47 +02:00
<textarea name="content" rows="10" cols="50" autofocus="autofocus" designMode="on" placeholder="Hey!" style="font-size:1.2em;width:95%;">{{ content }}</textarea>
2022-06-28 21:10:22 +02:00
<p>
2022-07-03 22:01:47 +02:00
<input type="text" name="content_warning" placeholder="content warning (will mark the post as sensitive)" style="width:95%;">
2022-06-28 21:10:22 +02:00
</p>
<p>
2022-07-03 22:01:47 +02:00
<input type="checkbox" name="is_sensitive" id="is_sensitive"> <label for="is_sensitive">Mark attachment(s) as sensitive</label>
2022-06-28 21:10:22 +02:00
</p>
2022-06-24 11:33:05 +02:00
<input type="hidden" name="in_reply_to" value="{{ request.query_params.in_reply_to }}">
2022-06-26 11:09:43 +02:00
<p>
<input name="files" type="file" multiple>
</p>
<p>
<input type="submit" value="Publish">
</p>
2022-06-22 20:11:22 +02:00
</form>
2022-07-09 08:15:33 +02:00
</div>
2022-06-27 20:55:44 +02: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 20:11:22 +02:00
2022-06-27 20:55:44 +02: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 20:11:22 +02:00
{% endblock %}