epicyon/webapp_create_post.py

965 lines
43 KiB
Python
Raw Normal View History

2020-11-09 22:57:12 +00:00
__filename__ = "webapp_create_post.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
2022-02-03 13:58:20 +00:00
__version__ = "1.3.0"
2020-11-09 22:57:12 +00:00
__maintainer__ = "Bob Mottram"
2021-09-10 16:14:50 +00:00
__email__ = "bob@libreserver.org"
2020-11-09 22:57:12 +00:00
__status__ = "Production"
2021-06-15 15:08:12 +00:00
__module_group__ = "Web Interface"
2020-11-09 22:57:12 +00:00
import os
2021-12-26 16:59:38 +00:00
from utils import get_new_post_endpoints
2021-12-28 14:41:10 +00:00
from utils import is_public_post_from_url
2021-12-27 22:19:18 +00:00
from utils import get_nickname_from_actor
2021-12-27 19:05:25 +00:00
from utils import get_domain_from_actor
2021-12-27 15:56:15 +00:00
from utils import get_media_formats
2021-12-26 14:08:58 +00:00
from utils import get_config_param
2021-12-26 12:02:29 +00:00
from utils import acct_dir
2021-12-26 17:29:09 +00:00
from utils import get_currencies
2021-12-26 17:18:34 +00:00
from utils import get_category_types
2022-02-25 19:12:40 +00:00
from utils import get_account_timezone
2022-04-15 19:18:59 +00:00
from utils import get_supported_languages
from webapp_utils import html_common_emoji
2022-04-15 12:56:30 +00:00
from webapp_utils import begin_edit_section
from webapp_utils import end_edit_section
2021-12-29 21:55:09 +00:00
from webapp_utils import get_banner_file
from webapp_utils import html_header_with_external_style
from webapp_utils import html_footer
from webapp_utils import edit_text_field
from webapp_utils import edit_number_field
from webapp_utils import edit_currency_field
from webapp_post import individual_post_as_html
2022-05-22 12:37:57 +00:00
from maps import get_map_preferences_url
from maps import get_map_preferences_coords
2020-11-09 22:57:12 +00:00
2021-12-29 21:55:09 +00:00
def _html_following_data_list(base_dir: str, nickname: str,
domain: str, domain_full: str) -> str:
2020-11-09 22:57:12 +00:00
"""Returns a datalist of handles being followed
"""
2022-01-01 10:42:14 +00:00
list_str = '<datalist id="followingHandles">\n'
following_filename = \
2021-12-26 12:02:29 +00:00
acct_dir(base_dir, nickname, domain) + '/following.txt'
2021-07-05 20:24:43 +00:00
msg = None
2022-01-01 10:42:14 +00:00
if os.path.isfile(following_filename):
2022-06-09 14:46:30 +00:00
with open(following_filename, 'r',
encoding='utf-8') as following_file:
2022-01-01 10:42:14 +00:00
msg = following_file.read()
# add your own handle, so that you can send DMs
# to yourself as reminders
2021-12-26 10:00:46 +00:00
msg += nickname + '@' + domain_full + '\n'
2021-07-05 20:24:43 +00:00
if msg:
# include petnames
2022-01-01 10:42:14 +00:00
petnames_filename = \
2021-12-26 12:02:29 +00:00
acct_dir(base_dir, nickname, domain) + '/petnames.txt'
2022-01-01 10:42:14 +00:00
if os.path.isfile(petnames_filename):
following_list = []
2022-06-09 14:46:30 +00:00
with open(petnames_filename, 'r',
encoding='utf-8') as petnames_file:
2022-01-01 10:42:14 +00:00
pet_str = petnames_file.read()
2021-07-05 20:24:43 +00:00
# extract each petname and append it
2022-01-01 10:42:14 +00:00
petnames_list = pet_str.split('\n')
for pet in petnames_list:
following_list.append(pet.split(' ')[0])
2021-07-05 20:24:43 +00:00
# add the following.txt entries
2022-01-01 10:42:14 +00:00
following_list += msg.split('\n')
2021-07-05 20:24:43 +00:00
else:
# no petnames list exists - just use following.txt
2022-01-01 10:42:14 +00:00
following_list = msg.split('\n')
following_list.sort()
if following_list:
for following_address in following_list:
if following_address:
list_str += '<option>@' + following_address + '</option>\n'
list_str += '</datalist>\n'
return list_str
def _html_new_post_drop_down(scope_icon: str, scope_description: str,
reply_str: str,
2021-12-29 21:55:09 +00:00
translate: {},
2022-01-01 10:42:14 +00:00
show_public_on_dropdown: bool,
2021-12-31 23:50:29 +00:00
default_timeline: str,
2022-01-01 10:42:14 +00:00
path_base: str,
dropdown_new_post_suffix: str,
dropdown_new_blog_suffix: str,
dropdown_unlisted_suffix: str,
dropdown_followers_suffix: str,
dropdown_dm_suffix: str,
dropdown_reminder_suffix: str,
dropdown_report_suffix: str,
no_drop_down: bool,
2021-12-31 21:18:12 +00:00
access_keys: {}) -> str:
2020-11-09 22:57:12 +00:00
"""Returns the html for a drop down list of new post types
"""
2022-01-01 10:42:14 +00:00
drop_down_content = '<nav><div class="newPostDropdown">\n'
if not no_drop_down:
drop_down_content += ' <input type="checkbox" ' + \
2021-02-05 12:22:23 +00:00
'id="my-newPostDropdown" value="" name="my-checkbox">\n'
2022-01-01 10:42:14 +00:00
drop_down_content += ' <label for="my-newPostDropdown"\n'
drop_down_content += ' data-toggle="newPostDropdown">\n'
2022-03-28 08:47:53 +00:00
drop_down_content += ' <img loading="lazy" decoding="async" ' + \
'alt="" title="" src="/' + \
2022-01-01 10:42:14 +00:00
'icons/' + scope_icon + '"/><b>' + scope_description + '</b></label>\n'
if no_drop_down:
drop_down_content += '</div></nav>\n'
return drop_down_content
drop_down_content += ' <ul>\n'
if show_public_on_dropdown:
drop_down_content += \
'<li><a href="' + path_base + dropdown_new_post_suffix + \
2021-12-31 21:18:12 +00:00
'" accesskey="' + access_keys['Public'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_public.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Public'] + '</b><br>' + \
translate['Visible to anyone'] + '</a></li>\n'
2021-12-31 23:50:29 +00:00
if default_timeline == 'tlfeatures':
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + dropdown_new_blog_suffix + \
2021-12-31 21:18:12 +00:00
'" accesskey="' + access_keys['menuBlogs'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" ' + \
'alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_blog.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Article'] + '</b><br>' + \
translate['Create an article'] + '</a></li>\n'
else:
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + dropdown_new_blog_suffix + \
2021-12-31 21:18:12 +00:00
'" accesskey="' + access_keys['menuBlogs'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" ' + \
'alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_blog.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Blog'] + '</b><br>' + \
translate['Publicly visible post'] + '</a></li>\n'
drop_down_content += \
'<li><a href="' + path_base + dropdown_unlisted_suffix + \
2022-03-28 08:47:53 +00:00
'"><img loading="lazy" decoding="async" alt="" title="" src="/' + \
'icons/scope_unlisted.png"/><b>' + \
translate['Unlisted'] + '</b><br>' + \
translate['Not on public timeline'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + dropdown_followers_suffix + \
2021-12-31 21:18:12 +00:00
'" accesskey="' + access_keys['menuFollowers'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_followers.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Followers'] + '</b><br>' + \
translate['Only to followers'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + dropdown_dm_suffix + \
2021-12-31 21:18:12 +00:00
'" accesskey="' + access_keys['menuDM'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_dm.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['DM'] + '</b><br>' + \
translate['Only to mentioned people'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + dropdown_reminder_suffix + \
2021-12-31 21:18:12 +00:00
'" accesskey="' + access_keys['Reminder'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_reminder.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Reminder'] + '</b><br>' + \
translate['Scheduled note to yourself'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + dropdown_report_suffix + \
2021-12-31 21:18:12 +00:00
'" accesskey="' + access_keys['reportButton'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_report.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Report'] + '</b><br>' + \
translate['Send to moderators'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
if not reply_str:
drop_down_content += \
'<li><a href="' + path_base + \
2021-12-31 21:18:12 +00:00
'/newshare" accesskey="' + access_keys['menuShares'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_share.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Shares'] + '</b><br>' + \
translate['Describe a shared item'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + \
2021-12-31 21:18:12 +00:00
'/newwanted" accesskey="' + access_keys['menuWanted'] + '">' + \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" src="/' + \
2021-08-09 18:41:05 +00:00
'icons/scope_wanted.png"/><b>' + \
translate['Wanted'] + '</b><br>' + \
translate['Describe something wanted'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += \
'<li><a href="' + path_base + \
2022-03-28 08:47:53 +00:00
'/newquestion"><img loading="lazy" decoding="async" ' + \
'alt="" title="" src="/' + \
2020-12-09 13:08:26 +00:00
'icons/scope_question.png"/><b>' + \
2020-11-09 22:57:12 +00:00
translate['Question'] + '</b><br>' + \
translate['Ask a question'] + '</a></li>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += ' </ul>\n'
2022-01-01 10:42:14 +00:00
drop_down_content += '</div></nav>\n'
return drop_down_content
2020-11-09 22:57:12 +00:00
2022-07-12 19:03:30 +00:00
def html_new_post(media_instance: bool, translate: {},
2021-12-29 21:55:09 +00:00
base_dir: str, http_prefix: str,
2022-06-08 09:23:34 +00:00
path: str, in_reply_to: str,
2021-12-29 21:55:09 +00:00
mentions: [],
2022-01-01 10:42:14 +00:00
share_description: str,
report_url: str, page_number: int,
2021-12-29 21:55:09 +00:00
category: str,
nickname: str, domain: str,
domain_full: str,
2021-12-31 23:50:29 +00:00
default_timeline: str, newswire: {},
2022-01-01 10:42:14 +00:00
theme: str, no_drop_down: bool,
access_keys: {}, custom_submit_text: str,
2022-06-08 09:23:34 +00:00
conversation_id: str,
2021-12-29 21:55:09 +00:00
recent_posts_cache: {}, max_recent_posts: int,
session, cached_webfingers: {},
person_cache: {}, port: int,
post_json_object: {},
project_version: str,
yt_replace_domain: str,
twitter_replacement_domain: str,
show_published_date_only: bool,
peertube_instances: [],
allow_local_network_access: bool,
system_language: str,
max_like_count: int, signing_priv_key_pem: str,
cw_lists: {}, lists_enabled: str,
2022-06-08 09:23:34 +00:00
box_name: str,
2022-07-05 14:40:26 +00:00
reply_is_chat: bool, bold_reading: bool,
dogwhistles: {}) -> str:
2020-11-09 22:57:12 +00:00
"""New post screen
"""
2022-01-01 10:42:14 +00:00
reply_str = ''
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
is_new_reminder = False
if path.endswith('/newreminder'):
2022-01-01 10:42:14 +00:00
is_new_reminder = True
# the date and time
2022-01-01 10:42:14 +00:00
date_and_time_str = '<p>\n'
if not is_new_reminder:
date_and_time_str += \
2022-03-28 08:47:53 +00:00
'<img loading="lazy" decoding="async" alt="" title="" ' + \
2022-06-08 09:20:56 +00:00
'class="emojicalendar" src="/icons/calendar.png"/>\n'
# select a date and time for this post
2022-01-01 10:42:14 +00:00
date_and_time_str += '<label class="labels">' + \
translate['Date'] + ': </label>\n'
2022-01-01 10:42:14 +00:00
date_and_time_str += '<input type="date" name="eventDate">\n'
date_and_time_str += '<label class="labelsright">' + \
2022-05-23 12:14:36 +00:00
translate['Start Time'] + ': '
2022-01-01 10:42:14 +00:00
date_and_time_str += \
2022-05-23 12:14:36 +00:00
'<input type="time" name="eventTime"></label>\n<br>\n'
date_and_time_str += '<label class="labelsright">' + \
translate['End Time'] + ': '
date_and_time_str += \
'<input type="time" name="eventEndTime"></label>\n</p>\n'
2022-01-01 10:42:14 +00:00
show_public_on_dropdown = True
message_box_height = 400
2022-06-08 09:38:00 +00:00
image_description_height = 150
2020-11-09 22:57:12 +00:00
# filename of the banner shown at the top
2022-01-01 10:42:14 +00:00
banner_file, _ = \
2021-12-29 21:55:09 +00:00
get_banner_file(base_dir, nickname, domain, theme)
2020-11-09 22:57:12 +00:00
2021-08-09 18:41:05 +00:00
if not path.endswith('/newshare') and not path.endswith('/newwanted'):
2020-11-09 22:57:12 +00:00
if not path.endswith('/newreport'):
2022-06-08 09:23:34 +00:00
if not in_reply_to or is_new_reminder:
2022-01-01 10:42:14 +00:00
new_post_text = '<h1>' + \
2020-12-07 11:03:14 +00:00
translate['Write your post text below.'] + '</h1>\n'
2020-11-09 22:57:12 +00:00
else:
2022-01-01 10:42:14 +00:00
new_post_text = ''
if category != 'accommodation':
2022-01-01 10:42:14 +00:00
new_post_text = \
'<p class="new-post-text">' + \
translate['Write your reply to'] + \
2022-06-08 09:23:34 +00:00
' <a href="' + in_reply_to + \
'" rel="nofollow noopener noreferrer" ' + \
'target="_blank">' + \
translate['this post'] + '</a></p>\n'
2021-12-25 22:09:19 +00:00
if post_json_object:
2022-02-25 19:12:40 +00:00
timezone = \
get_account_timezone(base_dir, nickname, domain)
2022-01-01 10:42:14 +00:00
new_post_text += \
2021-12-29 21:55:09 +00:00
individual_post_as_html(signing_priv_key_pem,
True, recent_posts_cache,
max_recent_posts,
translate, None,
base_dir, session,
cached_webfingers,
person_cache,
nickname, domain, port,
post_json_object,
None, True, False,
http_prefix,
project_version,
2022-06-08 09:23:34 +00:00
box_name,
2021-12-29 21:55:09 +00:00
yt_replace_domain,
twitter_replacement_domain,
show_published_date_only,
peertube_instances,
allow_local_network_access,
theme, system_language,
max_like_count,
False, False, False,
False, False, False,
2022-02-25 19:12:40 +00:00
cw_lists, lists_enabled,
2022-03-24 13:14:41 +00:00
timezone, False,
2022-07-05 14:40:26 +00:00
bold_reading, dogwhistles)
2022-01-01 10:42:14 +00:00
reply_str = '<input type="hidden" ' + \
2022-06-08 09:23:34 +00:00
'name="replyTo" value="' + in_reply_to + '">\n'
2020-11-09 22:57:12 +00:00
# if replying to a non-public post then also make
# this post non-public
2021-12-28 14:41:10 +00:00
if not is_public_post_from_url(base_dir, nickname, domain,
2022-06-08 09:23:34 +00:00
in_reply_to):
2022-01-01 10:42:14 +00:00
new_post_path = path
if '?' in new_post_path:
new_post_path = new_post_path.split('?')[0]
if new_post_path.endswith('/newpost'):
2020-11-09 22:57:12 +00:00
path = path.replace('/newpost', '/newfollowers')
2022-01-01 10:42:14 +00:00
show_public_on_dropdown = False
2020-11-09 22:57:12 +00:00
else:
2022-01-01 10:42:14 +00:00
new_post_text = \
2021-07-05 20:24:43 +00:00
'<h1>' + translate['Write your report below.'] + '</h1>\n'
2020-11-09 22:57:12 +00:00
# custom report header with any additional instructions
2021-12-25 16:17:53 +00:00
if os.path.isfile(base_dir + '/accounts/report.txt'):
2022-06-09 14:46:30 +00:00
with open(base_dir + '/accounts/report.txt', 'r',
encoding='utf-8') as file:
2022-01-01 10:42:14 +00:00
custom_report_text = file.read()
if '</p>' not in custom_report_text:
custom_report_text = \
2020-11-09 22:57:12 +00:00
'<p class="login-subtext">' + \
2022-01-01 10:42:14 +00:00
custom_report_text + '</p>\n'
rep_str = '<p class="login-subtext">'
custom_report_text = \
custom_report_text.replace('<p>', rep_str)
new_post_text += custom_report_text
2020-11-09 22:57:12 +00:00
idx = 'This message only goes to moderators, even if it ' + \
'mentions other fediverse addresses.'
2022-01-01 10:42:14 +00:00
new_post_text += \
2020-11-09 22:57:12 +00:00
'<p class="new-post-subtext">' + translate[idx] + '</p>\n' + \
'<p class="new-post-subtext">' + translate['Also see'] + \
' <a href="/terms">' + \
translate['Terms of Service'] + '</a></p>\n'
else:
2021-08-09 18:41:05 +00:00
if path.endswith('/newshare'):
2022-01-01 10:42:14 +00:00
new_post_text = \
2021-08-09 18:41:05 +00:00
'<h1>' + \
translate['Enter the details for your shared item below.'] + \
'</h1>\n'
else:
2022-01-01 10:42:14 +00:00
new_post_text = \
2021-08-09 18:41:05 +00:00
'<h1>' + \
translate['Enter the details for your wanted item below.'] + \
'</h1>\n'
2020-11-09 22:57:12 +00:00
if path.endswith('/newquestion'):
2022-01-01 10:42:14 +00:00
new_post_text = \
2020-11-21 09:56:45 +00:00
'<h1>' + \
2020-11-09 22:57:12 +00:00
translate['Enter the choices for your question below.'] + \
2020-11-21 09:56:45 +00:00
'</h1>\n'
2020-11-09 22:57:12 +00:00
2021-12-25 16:17:53 +00:00
if os.path.isfile(base_dir + '/accounts/newpost.txt'):
2022-06-09 14:46:30 +00:00
with open(base_dir + '/accounts/newpost.txt', 'r',
encoding='utf-8') as file:
2022-01-01 10:42:14 +00:00
new_post_text = \
2020-11-21 09:56:45 +00:00
'<p>' + file.read() + '</p>\n'
2020-11-09 22:57:12 +00:00
2021-12-31 21:18:12 +00:00
css_filename = base_dir + '/epicyon-profile.css'
2021-12-25 16:17:53 +00:00
if os.path.isfile(base_dir + '/epicyon.css'):
2021-12-31 21:18:12 +00:00
css_filename = base_dir + '/epicyon.css'
2020-11-09 22:57:12 +00:00
if '?' in path:
path = path.split('?')[0]
2022-01-01 10:42:14 +00:00
new_post_endpoints = get_new_post_endpoints()
path_base = path
for curr_post_type in new_post_endpoints:
path_base = path_base.replace('/' + curr_post_type, '')
2020-11-09 22:57:12 +00:00
2022-04-15 13:46:25 +00:00
attach_str = 'Attach an image, video or audio file'
new_post_image_section = begin_edit_section('📷 ' + translate[attach_str])
2022-01-01 10:42:14 +00:00
new_post_image_section += \
2021-07-24 10:13:40 +00:00
' <input type="file" id="attachpic" name="attachpic"'
2022-01-01 10:42:14 +00:00
formats_string = get_media_formats()
new_post_image_section += \
' accept="' + formats_string + '">\n'
2022-06-08 09:30:18 +00:00
new_post_image_section += \
' <label class="labels">' + \
translate['Describe your attachment'] + '</label>\n'
2022-04-15 13:27:25 +00:00
new_post_image_section += \
2022-06-08 09:20:56 +00:00
' <textarea id="imageDescription" name="imageDescription" ' + \
'style="height:' + str(image_description_height) + \
'px" spellcheck="true" autocomplete="on"></textarea>\n'
2022-04-15 12:56:30 +00:00
new_post_image_section += end_edit_section()
2022-01-01 10:42:14 +00:00
2022-04-19 13:56:26 +00:00
new_post_emoji_section = ''
2022-04-19 13:54:53 +00:00
common_emoji_str = html_common_emoji(base_dir, 16)
if common_emoji_str:
new_post_emoji_section = \
begin_edit_section('😀 ' + translate['Common emoji'])
new_post_emoji_section += \
'<label class="labels">' + \
translate['Copy and paste into your text'] + '</label><br>\n'
new_post_emoji_section += common_emoji_str
new_post_emoji_section += end_edit_section()
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_public.png'
scope_description = translate['Public']
if share_description:
if category == 'accommodation':
2022-01-01 10:42:14 +00:00
placeholder_subject = translate['Request to stay']
else:
2022-01-01 10:42:14 +00:00
placeholder_subject = translate['Ask about a shared item.'] + '..'
2020-12-07 11:03:14 +00:00
else:
2022-01-01 10:42:14 +00:00
placeholder_subject = \
2020-12-07 11:03:14 +00:00
translate['Subject or Content Warning (optional)'] + '...'
2022-01-01 10:42:14 +00:00
placeholder_mentions = ''
2022-06-08 09:23:34 +00:00
if in_reply_to:
2022-01-01 10:42:14 +00:00
placeholder_mentions = \
2020-11-09 22:57:12 +00:00
translate['Replying to'] + '...'
2022-01-01 10:42:14 +00:00
placeholder_message = ''
if category != 'accommodation':
2022-01-04 22:48:13 +00:00
if default_timeline == 'tlfeatures':
placeholder_message = translate['Write your news report'] + '...'
else:
placeholder_message = translate['Write something'] + '...'
2021-09-19 17:32:22 +00:00
else:
idx = 'Introduce yourself and specify the date ' + \
'and time when you wish to stay'
2022-01-01 10:42:14 +00:00
placeholder_message = translate[idx]
extra_fields = ''
2020-11-09 22:57:12 +00:00
endpoint = 'newpost'
if path.endswith('/newblog'):
2022-01-01 10:42:14 +00:00
placeholder_subject = translate['Title']
scope_icon = 'scope_blog.png'
2021-12-31 23:50:29 +00:00
if default_timeline != 'tlfeatures':
2022-01-01 10:42:14 +00:00
scope_description = translate['Blog']
2020-11-09 22:57:12 +00:00
else:
2022-01-01 10:42:14 +00:00
scope_description = translate['Article']
2020-11-09 22:57:12 +00:00
endpoint = 'newblog'
elif path.endswith('/newunlisted'):
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_unlisted.png'
scope_description = translate['Unlisted']
2020-11-09 22:57:12 +00:00
endpoint = 'newunlisted'
elif path.endswith('/newfollowers'):
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_followers.png'
scope_description = translate['Followers']
2020-11-09 22:57:12 +00:00
endpoint = 'newfollowers'
elif path.endswith('/newdm'):
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_dm.png'
scope_description = translate['DM']
2020-11-09 22:57:12 +00:00
endpoint = 'newdm'
2022-04-29 21:25:14 +00:00
placeholder_message = '⚠️ ' + translate['DM warning']
2022-01-01 10:42:14 +00:00
elif is_new_reminder:
scope_icon = 'scope_reminder.png'
scope_description = translate['Reminder']
2020-11-09 22:57:12 +00:00
endpoint = 'newreminder'
elif path.endswith('/newreport'):
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_report.png'
scope_description = translate['Report']
2020-11-09 22:57:12 +00:00
endpoint = 'newreport'
elif path.endswith('/newquestion'):
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_question.png'
scope_description = translate['Question']
placeholder_message = translate['Enter your question'] + '...'
2020-11-09 22:57:12 +00:00
endpoint = 'newquestion'
2022-01-01 10:42:14 +00:00
extra_fields = '<div class="container">\n'
extra_fields += ' <label class="labels">' + \
2020-11-09 22:57:12 +00:00
translate['Possible answers'] + ':</label><br>\n'
2022-01-01 10:42:14 +00:00
for question_ctr in range(8):
extra_fields += \
2020-11-09 22:57:12 +00:00
' <input type="text" class="questionOption" placeholder="' + \
2022-01-01 10:42:14 +00:00
str(question_ctr + 1) + \
'" name="questionOption' + str(question_ctr) + '"><br>\n'
extra_fields += \
2020-11-09 22:57:12 +00:00
' <label class="labels">' + \
translate['Duration of listing in days'] + \
':</label> <input type="number" name="duration" ' + \
'min="1" max="365" step="1" value="14"><br>\n'
2022-01-01 10:42:14 +00:00
extra_fields += '</div>'
2020-11-09 22:57:12 +00:00
elif path.endswith('/newshare'):
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_share.png'
scope_description = translate['Shared Item']
placeholder_subject = translate['Name of the shared item'] + '...'
placeholder_message = \
2020-11-09 22:57:12 +00:00
translate['Description of the item being shared'] + '...'
endpoint = 'newshare'
2022-01-01 10:42:14 +00:00
extra_fields = '<div class="container">\n'
extra_fields += \
2021-12-29 21:55:09 +00:00
edit_number_field(translate['Quantity'],
'itemQty', 1, 1, 999999, 1)
2022-01-01 10:42:14 +00:00
extra_fields += '<br>' + \
2021-12-29 21:55:09 +00:00
edit_text_field(translate['Type of shared item. eg. hat'] + ':',
'itemType', '', '', True)
2022-01-01 10:42:14 +00:00
category_types = get_category_types(base_dir)
cat_str = translate['Category of shared item. eg. clothing']
extra_fields += '<label class="labels">' + cat_str + '</label><br>\n'
2021-08-07 17:44:25 +00:00
2022-01-01 10:42:14 +00:00
extra_fields += ' <select id="themeDropdown" ' + \
2021-08-07 17:55:49 +00:00
'name="category" class="theme">\n'
2022-01-01 10:42:14 +00:00
for cat in category_types:
translated_category = "food"
if translate.get(cat):
translated_category = translate[cat]
extra_fields += ' <option value="' + \
translated_category + '">' + \
translated_category + '</option>\n'
extra_fields += ' </select><br>\n'
extra_fields += \
2021-12-29 21:55:09 +00:00
edit_number_field(translate['Duration of listing in days'],
'duration', 14, 1, 365, 1)
2022-01-01 10:42:14 +00:00
extra_fields += '</div>\n'
extra_fields += '<div class="container">\n'
city_or_loc_str = translate['City or location of the shared item']
extra_fields += edit_text_field(city_or_loc_str + ':', 'location', '')
extra_fields += '</div>\n'
extra_fields += '<div class="container">\n'
extra_fields += \
2021-12-29 21:55:09 +00:00
edit_currency_field(translate['Price'] + ':', 'itemPrice', '0.00',
'0.00', True)
2022-01-01 10:42:14 +00:00
extra_fields += '<br>'
extra_fields += \
2021-08-07 17:44:25 +00:00
'<label class="labels">' + translate['Currency'] + '</label><br>\n'
2021-12-26 17:29:09 +00:00
currencies = get_currencies()
2022-01-01 10:42:14 +00:00
extra_fields += ' <select id="themeDropdown" ' + \
2021-08-07 17:55:49 +00:00
'name="itemCurrency" class="theme">\n'
2022-01-01 10:42:14 +00:00
currency_list = []
for symbol, curr_name in currencies.items():
currency_list.append(curr_name + ' ' + symbol)
currency_list.sort()
default_currency = get_config_param(base_dir, 'defaultCurrency')
if not default_currency:
default_currency = "EUR"
for curr_name in currency_list:
if default_currency not in curr_name:
extra_fields += ' <option value="' + \
curr_name + '">' + curr_name + '</option>\n'
2021-08-07 18:07:08 +00:00
else:
2022-01-01 10:42:14 +00:00
extra_fields += ' <option value="' + \
curr_name + '" selected="selected">' + \
curr_name + '</option>\n'
extra_fields += ' </select>\n'
2021-08-07 17:44:25 +00:00
2022-01-01 10:42:14 +00:00
extra_fields += '</div>\n'
2021-08-09 18:41:05 +00:00
elif path.endswith('/newwanted'):
2022-01-01 10:42:14 +00:00
scope_icon = 'scope_wanted.png'
scope_description = translate['Wanted']
placeholder_subject = translate['Name of the wanted item'] + '...'
placeholder_message = \
2021-08-09 18:41:05 +00:00
translate['Description of the item wanted'] + '...'
endpoint = 'newwanted'
2022-01-01 10:42:14 +00:00
extra_fields = '<div class="container">\n'
extra_fields += \
2021-12-29 21:55:09 +00:00
edit_number_field(translate['Quantity'],
'itemQty', 1, 1, 999999, 1)
2022-01-01 10:42:14 +00:00
extra_fields += '<br>' + \
2021-12-29 21:55:09 +00:00
edit_text_field(translate['Type of wanted item. eg. hat'] + ':',
'itemType', '', '', True)
2022-01-01 10:42:14 +00:00
category_types = get_category_types(base_dir)
cat_str = translate['Category of wanted item. eg. clothes']
extra_fields += '<label class="labels">' + cat_str + '</label><br>\n'
2021-08-09 18:41:05 +00:00
2022-01-01 10:42:14 +00:00
extra_fields += ' <select id="themeDropdown" ' + \
2021-08-09 18:41:05 +00:00
'name="category" class="theme">\n'
2022-01-01 10:42:14 +00:00
for cat in category_types:
translated_category = "food"
if translate.get(cat):
translated_category = translate[cat]
extra_fields += ' <option value="' + \
translated_category + '">' + \
translated_category + '</option>\n'
extra_fields += ' </select><br>\n'
extra_fields += \
2021-12-29 21:55:09 +00:00
edit_number_field(translate['Duration of listing in days'],
'duration', 14, 1, 365, 1)
2022-01-01 10:42:14 +00:00
extra_fields += '</div>\n'
extra_fields += '<div class="container">\n'
city_or_loc_str = translate['City or location of the wanted item']
extra_fields += edit_text_field(city_or_loc_str + ':', 'location', '')
extra_fields += '</div>\n'
extra_fields += '<div class="container">\n'
extra_fields += \
2021-12-29 21:55:09 +00:00
edit_currency_field(translate['Maximum Price'] + ':',
'itemPrice', '0.00', '0.00', True)
2022-01-01 10:42:14 +00:00
extra_fields += '<br>'
extra_fields += \
2021-08-09 18:41:05 +00:00
'<label class="labels">' + translate['Currency'] + '</label><br>\n'
2021-12-26 17:29:09 +00:00
currencies = get_currencies()
2022-01-01 10:42:14 +00:00
extra_fields += ' <select id="themeDropdown" ' + \
2021-08-09 18:41:05 +00:00
'name="itemCurrency" class="theme">\n'
2022-01-01 10:42:14 +00:00
currency_list = []
for symbol, curr_name in currencies.items():
currency_list.append(curr_name + ' ' + symbol)
currency_list.sort()
default_currency = get_config_param(base_dir, 'defaultCurrency')
if not default_currency:
default_currency = "EUR"
for curr_name in currency_list:
if default_currency not in curr_name:
extra_fields += ' <option value="' + \
curr_name + '">' + curr_name + '</option>\n'
2021-08-09 18:41:05 +00:00
else:
2022-01-01 10:42:14 +00:00
extra_fields += ' <option value="' + \
curr_name + '" selected="selected">' + \
curr_name + '</option>\n'
extra_fields += ' </select>\n'
2021-08-09 18:41:05 +00:00
2022-01-01 10:42:14 +00:00
extra_fields += '</div>\n'
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
citations_str = ''
2020-11-09 22:57:12 +00:00
if endpoint == 'newblog':
2022-01-01 10:42:14 +00:00
citations_filename = \
2021-12-26 12:02:29 +00:00
acct_dir(base_dir, nickname, domain) + '/.citations.txt'
2022-01-01 10:42:14 +00:00
if os.path.isfile(citations_filename):
citations_str = '<div class="container">\n'
citations_str += '<p><label class="labels">' + \
2020-11-09 22:57:12 +00:00
translate['Citations'] + ':</label></p>\n'
2022-01-01 10:42:14 +00:00
citations_str += ' <ul>\n'
citations_separator = '#####'
2022-06-09 14:46:30 +00:00
with open(citations_filename, 'r', encoding='utf-8') as cit_file:
2022-01-01 10:42:14 +00:00
citations = cit_file.readlines()
2020-11-09 22:57:12 +00:00
for line in citations:
2022-01-01 10:42:14 +00:00
if citations_separator not in line:
2020-11-09 22:57:12 +00:00
continue
2022-01-01 10:42:14 +00:00
sections = line.strip().split(citations_separator)
2020-11-09 22:57:12 +00:00
if len(sections) != 3:
continue
title = sections[1]
link = sections[2]
2022-01-01 10:42:14 +00:00
citations_str += \
2020-11-09 22:57:12 +00:00
' <li><a href="' + link + '"><cite>' + \
title + '</cite></a></li>'
2022-01-01 10:42:14 +00:00
citations_str += ' </ul>\n'
citations_str += '</div>\n'
2020-11-09 22:57:12 +00:00
2022-04-15 13:04:16 +00:00
replies_section = ''
2022-01-01 10:42:14 +00:00
date_and_location = ''
if endpoint not in ('newshare', 'newwanted', 'newreport', 'newquestion'):
2021-11-03 13:44:19 +00:00
2022-01-01 10:42:14 +00:00
if not is_new_reminder:
2022-04-15 13:04:16 +00:00
replies_section = \
2021-11-03 13:28:35 +00:00
'<div class="container">\n'
if category != 'accommodation':
2022-04-15 13:04:16 +00:00
replies_section += \
2021-11-03 13:28:35 +00:00
'<p><input type="checkbox" class="profilecheckbox" ' + \
'name="commentsEnabled" ' + \
'checked><label class="labels"> ' + \
translate['Allow replies.'] + '</label></p>\n'
else:
2022-04-15 13:04:16 +00:00
replies_section += \
2021-11-03 13:28:35 +00:00
'<input type="hidden" name="commentsEnabled" ' + \
'value="true">\n'
2022-04-15 19:18:59 +00:00
supported_languages = get_supported_languages(base_dir)
languages_dropdown = '<select id="themeDropdown" ' + \
'name="languagesDropdown" class="theme">'
for lang_name in supported_languages:
translated_lang_name = lang_name
if translate.get('lang_' + lang_name):
translated_lang_name = translate['lang_' + lang_name]
languages_dropdown += ' <option value="' + \
lang_name.lower() + '">' + \
translated_lang_name + '</option>'
languages_dropdown += ' </select><br>'
languages_dropdown = \
languages_dropdown.replace('<option value="' +
system_language + '">',
'<option value="' +
system_language +
'" selected>')
replies_section += \
' <label class="labels">' + \
translate['Language used'] + '</label>\n'
replies_section += languages_dropdown
2022-04-15 13:04:16 +00:00
replies_section += '</div>\n'
2021-11-03 13:28:35 +00:00
2022-04-15 13:04:16 +00:00
date_and_location = \
2022-04-15 13:46:25 +00:00
begin_edit_section('🗓️ ' + translate['Set a place and time'])
if endpoint == 'newpost':
2022-01-01 10:42:14 +00:00
date_and_location += \
2021-11-03 13:28:35 +00:00
'<p><input type="checkbox" class="profilecheckbox" ' + \
'name="pinToProfile"><label class="labels"> ' + \
translate['Pin this post to your profile.'] + \
'</label></p>\n'
2022-06-08 09:23:34 +00:00
if not in_reply_to:
2022-01-01 10:42:14 +00:00
date_and_location += \
2021-11-03 13:28:35 +00:00
'<p><input type="checkbox" class="profilecheckbox" ' + \
'name="schedulePost"><label class="labels"> ' + \
translate['This is a scheduled post.'] + '</label></p>\n'
2022-01-01 10:42:14 +00:00
date_and_location += date_and_time_str
2021-07-24 10:13:40 +00:00
2022-05-22 12:37:57 +00:00
maps_url = get_map_preferences_url(base_dir, nickname, domain)
2022-05-22 10:51:45 +00:00
if not maps_url:
maps_url = 'https://www.openstreetmap.org'
2022-05-22 10:56:19 +00:00
if '://' not in maps_url:
maps_url = 'https://' + maps_url
2022-05-22 12:37:57 +00:00
maps_latitude, maps_longitude, maps_zoom = \
get_map_preferences_coords(base_dir, nickname, domain)
if maps_latitude and maps_longitude and maps_zoom:
if 'openstreetmap.org' in maps_url:
maps_url = \
'https://www.openstreetmap.org/#map=' + \
str(maps_zoom) + '/' + \
str(maps_latitude) + '/' + \
str(maps_longitude)
elif '.google.co' in maps_url:
maps_url = \
'https://www.google.com/maps/@' + \
str(maps_latitude) + ',' + \
str(maps_longitude) + ',' + \
str(maps_zoom) + 'z'
elif '.bing.co' in maps_url:
maps_url = \
'https://www.bing.com/maps?cp=' + \
str(maps_latitude) + '~' + \
str(maps_longitude) + '&amp;lvl=' + \
str(maps_zoom)
elif '.waze.co' in maps_url:
maps_url = \
'https://ul.waze.com/ul?ll=' + \
str(maps_latitude) + '%2C' + \
str(maps_longitude) + '&zoom=' + \
str(maps_zoom)
elif 'wego.here.co' in maps_url:
maps_url = \
'https://wego.here.com/?x=ep&map=' + \
str(maps_latitude) + ',' + \
str(maps_longitude) + ',' + \
str(maps_zoom) + ',normal'
2022-05-22 10:51:45 +00:00
location_label_with_link = \
'<a href="' + maps_url + '" ' + \
2022-06-05 10:01:41 +00:00
'rel="nofollow noopener noreferrer" target="_blank">🗺️ ' + \
2022-05-22 10:51:45 +00:00
translate['Location'] + '</a>'
2022-06-05 09:54:54 +00:00
date_and_location += '<br><p>\n' + \
2022-05-22 10:51:45 +00:00
edit_text_field(location_label_with_link, 'location', '',
2022-05-23 19:23:23 +00:00
'https://www.openstreetmap.org/#map=') + '</p>\n'
date_and_location += end_edit_section()
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
instance_title = get_config_param(base_dir, 'instanceTitle')
new_post_form = html_header_with_external_style(css_filename,
instance_title, None)
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += \
2020-12-27 16:57:15 +00:00
'<header>\n' + \
2021-12-31 23:50:29 +00:00
'<a href="/users/' + nickname + '/' + default_timeline + \
'" title="' + \
2020-11-09 22:57:12 +00:00
translate['Switch to timeline view'] + '" alt="' + \
2021-04-23 17:04:37 +00:00
translate['Switch to timeline view'] + '" ' + \
2021-12-31 21:18:12 +00:00
'accesskey="' + access_keys['menuTimeline'] + '">\n'
2022-03-28 08:47:53 +00:00
new_post_form += '<img loading="lazy" decoding="async" ' + \
'class="timeline-banner" src="' + \
2021-12-31 21:18:12 +00:00
'/users/' + nickname + '/' + banner_file + '" alt="" /></a>\n' + \
2020-12-27 16:57:15 +00:00
'</header>\n'
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
mentions_str = ''
for ment in mentions:
mention_nickname = get_nickname_from_actor(ment)
if not mention_nickname:
2020-11-09 22:57:12 +00:00
continue
2022-01-01 10:42:14 +00:00
mention_domain, mention_port = get_domain_from_actor(ment)
if not mention_domain:
2020-11-09 22:57:12 +00:00
continue
2022-01-01 10:42:14 +00:00
if mention_port:
mentions_handle = \
'@' + mention_nickname + '@' + \
mention_domain + ':' + str(mention_port)
2020-11-09 22:57:12 +00:00
else:
2022-01-01 10:42:14 +00:00
mentions_handle = '@' + mention_nickname + '@' + mention_domain
if mentions_handle not in mentions_str:
mentions_str += mentions_handle + ' '
2020-11-09 22:57:12 +00:00
# build suffixes so that any replies or mentions are
# preserved when switching between scopes
2022-01-01 10:42:14 +00:00
dropdown_new_post_suffix = '/newpost'
dropdown_new_blog_suffix = '/newblog'
dropdown_unlisted_suffix = '/newunlisted'
dropdown_followers_suffix = '/newfollowers'
dropdown_dm_suffix = '/newdm'
dropdown_reminder_suffix = '/newreminder'
dropdown_report_suffix = '/newreport'
2022-06-08 09:23:34 +00:00
if in_reply_to or mentions:
2022-01-01 10:42:14 +00:00
dropdown_new_post_suffix = ''
dropdown_new_blog_suffix = ''
dropdown_unlisted_suffix = ''
dropdown_followers_suffix = ''
dropdown_dm_suffix = ''
dropdown_reminder_suffix = ''
dropdown_report_suffix = ''
2022-06-08 09:23:34 +00:00
if in_reply_to:
dropdown_new_post_suffix += '?replyto=' + in_reply_to
dropdown_new_blog_suffix += '?replyto=' + in_reply_to
dropdown_unlisted_suffix += '?replyunlisted=' + in_reply_to
dropdown_followers_suffix += '?replyfollowers=' + in_reply_to
if reply_is_chat:
2022-06-08 09:23:34 +00:00
dropdown_dm_suffix += '?replychat=' + in_reply_to
else:
2022-06-08 09:23:34 +00:00
dropdown_dm_suffix += '?replydm=' + in_reply_to
2022-01-01 10:42:14 +00:00
for mentioned_actor in mentions:
dropdown_new_post_suffix += '?mention=' + mentioned_actor
dropdown_new_blog_suffix += '?mention=' + mentioned_actor
dropdown_unlisted_suffix += '?mention=' + mentioned_actor
dropdown_followers_suffix += '?mention=' + mentioned_actor
dropdown_dm_suffix += '?mention=' + mentioned_actor
dropdown_report_suffix += '?mention=' + mentioned_actor
2022-06-08 09:23:34 +00:00
if conversation_id and in_reply_to:
dropdown_new_post_suffix += '?conversationId=' + conversation_id
dropdown_new_blog_suffix += '?conversationId=' + conversation_id
dropdown_unlisted_suffix += '?conversationId=' + conversation_id
dropdown_followers_suffix += '?conversationId=' + conversation_id
dropdown_dm_suffix += '?conversationId=' + conversation_id
2022-01-01 10:42:14 +00:00
drop_down_content = ''
if not report_url and not share_description:
drop_down_content = \
_html_new_post_drop_down(scope_icon, scope_description,
reply_str,
2021-12-29 21:55:09 +00:00
translate,
2022-01-01 10:42:14 +00:00
show_public_on_dropdown,
2021-12-31 23:50:29 +00:00
default_timeline,
2022-01-01 10:42:14 +00:00
path_base,
dropdown_new_post_suffix,
dropdown_new_blog_suffix,
dropdown_unlisted_suffix,
dropdown_followers_suffix,
dropdown_dm_suffix,
dropdown_reminder_suffix,
dropdown_report_suffix,
no_drop_down, access_keys)
2020-11-09 22:57:12 +00:00
else:
2022-01-01 10:42:14 +00:00
if not share_description:
2020-12-07 10:39:45 +00:00
# reporting a post to moderator
2022-01-01 10:42:14 +00:00
mentions_str = 'Re: ' + report_url + '\n\n' + mentions_str
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += \
2020-11-09 22:57:12 +00:00
'<form enctype="multipart/form-data" method="POST" ' + \
'accept-charset="UTF-8" action="' + \
2022-01-01 10:42:14 +00:00
path + '?' + endpoint + '?page=' + str(page_number) + '">\n'
if reply_is_chat:
new_post_form += \
' <input type="hidden" name="replychatmsg" value="yes">\n'
2022-06-08 09:23:34 +00:00
if conversation_id:
2022-01-01 10:42:14 +00:00
new_post_form += \
2021-08-08 16:52:32 +00:00
' <input type="hidden" name="conversationId" value="' + \
2022-06-08 09:23:34 +00:00
conversation_id + '">\n'
2022-01-01 10:42:14 +00:00
new_post_form += ' <div class="vertical-center">\n'
new_post_form += \
' <label for="nickname"><b>' + new_post_text + '</b></label>\n'
new_post_form += ' <div class="containerNewPost">\n'
new_post_form += ' <table style="width:100%" border="0">\n'
new_post_form += ' <colgroup>\n'
new_post_form += ' <col span="1" style="width:70%">\n'
new_post_form += ' <col span="1" style="width:10%">\n'
2020-12-21 14:55:24 +00:00
if newswire and path.endswith('/newblog'):
2022-01-01 10:42:14 +00:00
new_post_form += ' <col span="1" style="width:10%">\n'
new_post_form += ' <col span="1" style="width:10%">\n'
2020-12-21 14:55:24 +00:00
else:
2022-01-01 10:42:14 +00:00
new_post_form += ' <col span="1" style="width:20%">\n'
new_post_form += ' </colgroup>\n'
new_post_form += '<tr>\n'
new_post_form += '<td>' + drop_down_content + '</td>\n'
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += \
' <td><a href="' + path_base + \
2022-03-28 08:47:53 +00:00
'/searchemoji"><img loading="lazy" decoding="async" ' + \
'class="emojisearch" src="/emoji/1F601.png" title="' + \
2020-11-09 22:57:12 +00:00
translate['Search for emoji'] + '" alt="' + \
translate['Search for emoji'] + '"/></a></td>\n'
2020-12-21 14:44:56 +00:00
# for a new blog if newswire items exist then add a citations button
if newswire and path.endswith('/newblog'):
2022-01-01 10:42:14 +00:00
new_post_form += \
2020-12-21 14:44:56 +00:00
' <td><input type="submit" name="submitCitations" value="' + \
translate['Citations'] + '"></td>\n'
2022-05-23 18:48:45 +00:00
submit_text = translate['Publish']
2022-01-01 10:42:14 +00:00
if custom_submit_text:
submit_text = custom_submit_text
new_post_form += \
2020-12-21 14:44:56 +00:00
' <td><input type="submit" name="submitPost" value="' + \
2022-01-01 10:42:14 +00:00
submit_text + '" ' + \
2021-12-31 21:18:12 +00:00
'accesskey="' + access_keys['submitButton'] + '"></td>\n'
2020-12-21 14:44:56 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += ' </tr>\n</table>\n'
new_post_form += ' </div>\n'
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += ' <div class="containerSubmitNewPost"><center>\n'
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += ' </center></div>\n'
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += reply_str
if media_instance and not reply_str:
new_post_form += new_post_image_section
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
if not share_description:
share_description = ''
# for reminders show the date and time at the top
2022-01-01 10:42:14 +00:00
if is_new_reminder:
new_post_form += '<div class="containerNoOverflow">\n'
new_post_form += date_and_time_str
new_post_form += '</div>\n'
2022-01-01 10:42:14 +00:00
new_post_form += \
edit_text_field(placeholder_subject, 'subject', share_description)
new_post_form += ''
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
selected_str = ' selected'
2022-06-08 09:23:34 +00:00
if in_reply_to or endpoint == 'newdm':
if in_reply_to:
2022-01-01 10:42:14 +00:00
new_post_form += \
2022-07-11 09:41:25 +00:00
' <br><label class="labels">' + placeholder_mentions + \
2020-11-09 22:57:12 +00:00
'</label><br>\n'
else:
2022-01-01 10:42:14 +00:00
new_post_form += \
2022-07-11 09:41:25 +00:00
' <br><a href="/users/' + nickname + \
2020-11-09 22:57:12 +00:00
'/followingaccounts" title="' + \
translate['Show a list of addresses to send to'] + '">' \
'<label class="labels">' + \
translate['Send to'] + ':' + '</label> 📄</a><br>\n'
2022-01-01 10:42:14 +00:00
new_post_form += \
2020-11-09 22:57:12 +00:00
' <input type="text" name="mentions" ' + \
2022-01-01 10:42:14 +00:00
'list="followingHandles" value="' + mentions_str + '" selected>\n'
new_post_form += \
2021-12-29 21:55:09 +00:00
_html_following_data_list(base_dir, nickname, domain, domain_full)
2022-01-01 10:42:14 +00:00
new_post_form += ''
selected_str = ''
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += \
' <br><label class="labels">' + placeholder_message + '</label>'
2021-12-25 20:25:07 +00:00
if media_instance:
2022-01-01 10:42:14 +00:00
message_box_height = 200
2020-11-09 22:57:12 +00:00
if endpoint == 'newquestion':
2022-01-01 10:42:14 +00:00
message_box_height = 100
2020-11-09 22:57:12 +00:00
elif endpoint == 'newblog':
2022-01-01 10:42:14 +00:00
message_box_height = 800
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += \
2020-11-09 22:57:12 +00:00
' <textarea id="message" name="message" style="height:' + \
2022-01-01 10:42:14 +00:00
str(message_box_height) + 'px"' + selected_str + \
2021-02-28 14:48:41 +00:00
' spellcheck="true" autocomplete="on">' + \
2021-02-28 13:44:16 +00:00
'</textarea>\n'
2022-04-15 13:04:16 +00:00
new_post_form += \
extra_fields + citations_str + replies_section + date_and_location
2022-01-01 10:42:14 +00:00
if not media_instance or reply_str:
new_post_form += new_post_image_section
new_post_form += new_post_emoji_section
2021-05-30 14:06:28 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += \
2021-07-05 20:24:43 +00:00
' <div class="container">\n' + \
' <input type="submit" name="submitPost" value="' + \
2022-01-01 10:42:14 +00:00
submit_text + '">\n' + \
2021-07-05 20:24:43 +00:00
' </div>\n' + \
' </div>\n' + \
'</form>\n'
2020-11-09 22:57:12 +00:00
2022-01-01 10:42:14 +00:00
new_post_form += html_footer()
return new_post_form