Show a sending screen when post is sent

main
Bob Mottram 2020-09-28 10:55:28 +01:00
parent 74b78a01f9
commit 526ccad163
4 changed files with 128 additions and 7 deletions

View File

@ -152,6 +152,7 @@ from webinterface import rssHashtagSearch
from webinterface import htmlModerationInfo
from webinterface import htmlSearchSharedItems
from webinterface import htmlHashtagBlocked
from webinterface import htmlSendingPost
from shares import getSharesFeedForPerson
from shares import addShare
from shares import removeShare
@ -921,6 +922,7 @@ class PubServer(BaseHTTPRequestHandler):
if postToNickname:
print('Posting to nickname ' + postToNickname)
self.postToNickname = postToNickname
return postMessageToOutbox(messageJson, self.postToNickname,
self.server, self.server.baseDir,
self.server.httpPrefix,
@ -4048,7 +4050,8 @@ class PubServer(BaseHTTPRequestHandler):
if '?page=' in hashtag:
hashtag = hashtag.split('?page=')[0]
if isBlockedHashtag(baseDir, hashtag):
msg = htmlHashtagBlocked(baseDir).encode('utf-8')
msg = htmlHashtagBlocked(baseDir,
self.server.translate).encode('utf-8')
self._login_headers('text/html', len(msg), callingDomain)
self._write(msg)
self.server.GETbusy = False
@ -9114,7 +9117,8 @@ class PubServer(BaseHTTPRequestHandler):
etag, callingDomain)
def _receiveNewPostProcess(self, postType: str, path: str, headers: {},
length: int, postBytes, boundary: str) -> int:
length: int, postBytes, boundary: str,
callingDomain: str) -> int:
# Note: this needs to happen synchronously
# 0=this is not a new post
# 1=new post success
@ -9255,6 +9259,14 @@ class PubServer(BaseHTTPRequestHandler):
privateEvent = False
else:
privateEvent = True
# show a sending post screen
msg = \
htmlSendingPost(self.server.baseDir,
self.server.translate).encode('utf-8')
self._login_headers('text/html', len(msg), callingDomain)
self._write(msg)
if postType == 'newpost':
messageJson = \
createPublicPost(self.server.baseDir,
@ -9274,6 +9286,7 @@ class PubServer(BaseHTTPRequestHandler):
if messageJson:
if fields['schedulePost']:
return 1
if self._postToOutbox(messageJson, __version__, nickname):
populateReplies(self.server.baseDir,
self.server.httpPrefix,
@ -9668,7 +9681,8 @@ class PubServer(BaseHTTPRequestHandler):
return 1
return -1
def _receiveNewPost(self, postType: str, path: str) -> int:
def _receiveNewPost(self, postType: str, path: str,
callingDomain: str) -> int:
"""A new post has been created
This creates a thread to send the new post
"""
@ -9769,7 +9783,8 @@ class PubServer(BaseHTTPRequestHandler):
print('Creating new post from: ' + newPostThreadName)
self._receiveNewPostProcess(postType,
path, headers, length,
postBytes, boundary)
postBytes, boundary,
callingDomain)
return pageNumber
def _cryptoAPIreadHandle(self):
@ -10229,7 +10244,8 @@ class PubServer(BaseHTTPRequestHandler):
elif currPostType == 'newevent':
postRedirect = 'tlevents'
pageNumber = self._receiveNewPost(currPostType, self.path)
pageNumber = \
self._receiveNewPost(currPostType, self.path, callingDomain)
if pageNumber:
nickname = self.path.split('/users/')[1]
if '/' in nickname:

86
epicyon-send.css 100644
View File

@ -0,0 +1,86 @@
@charset "UTF-8";
:root {
--main-bg-color: #282c37;
--link-bg-color: #282c37;
--main-bg-color-darker: #232c37;
--main-bg-color-report: #221c27;
--main-header-color-roles: #282237;
--main-fg-color: #dddddd;
--main-link-color: #999;
--main-visited-color: #888;
--border-color: #505050;
--font-size-header: 18px;
--font-color-header: #ccc;
--font-size: 22px;
--text-entry-foreground: #ccc;
--text-entry-background: #111;
--time-color: #aaa;
--button-text: #FFFFFF;
--button-background: #999;
--button-selected: #666;
--focus-color: white;
}
@font-face {
font-family: 'Bedstead';
font-style: italic;
font-weight: normal;
font-display: block;
src: url('./fonts/bedstead.otf') format('opentype');
}
@font-face {
font-family: 'Bedstead';
font-style: normal;
font-weight: normal;
font-display: block;
src: url('./fonts/bedstead.otf') format('opentype');
}
body, html {
background-color: var(--main-bg-color);
color: var(--main-fg-color);
height: 100%;
font-family: Arial, Helvetica, sans-serif;
max-width: 80%;
min-width: 600px;
margin: 0 auto;
font-size: var(--font-size);
}
a, u {
color: var(--main-fg-color);
}
a:visited{
color: var(--main-visited-color);
background: var(--link-bg-color);
font-weight: bold;
}
a:link {
color: var(--main-link-color);
background: var(--link-bg-color);
font-weight: bold;
}
a:focus {
border: 2px solid var(--focus-color);
}
.screentitle {
font-size: 30px;
font-family: Arial, Helvetica, sans-serif;
}
div {
height: 300px;
width: 400px;
background: var(--main-bg-color);
position: fixed;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -200px;
}

View File

@ -15,7 +15,7 @@ from shutil import copyfile
def getThemeFiles() -> []:
return ('epicyon.css', 'login.css', 'follow.css',
'suspended.css', 'calendar.css', 'blog.css',
'options.css', 'search.css')
'options.css', 'search.css', 'send.css')
def getThemesList() -> []:

View File

@ -1984,7 +1984,7 @@ def htmlAbout(baseDir: str, httpPrefix: str,
return aboutForm
def htmlHashtagBlocked(baseDir: str) -> str:
def htmlHashtagBlocked(baseDir: str, translate: {}) -> str:
"""Show the screen for a blocked hashtag
"""
blockedHashtagForm = ''
@ -2003,6 +2003,25 @@ def htmlHashtagBlocked(baseDir: str) -> str:
return blockedHashtagForm
def htmlSendingPost(baseDir: str, translate: {}) -> str:
"""A wait screen while sending a post
"""
sendForm = ''
cssFilename = baseDir + '/epicyon-send.css'
if os.path.isfile(baseDir + '/send.css'):
cssFilename = baseDir + '/send.css'
with open(cssFilename, 'r') as cssFile:
blockedHashtagCSS = cssFile.read()
sendForm = htmlHeader(cssFilename, blockedHashtagCSS)
sendForm += '<div><center>\n'
sendForm += ' <p class="screentitle">Sending Post</p>\n'
sendForm += \
' <p>Please wait</p>\n'
sendForm += '</center></div>\n'
sendForm += htmlFooter()
return sendForm
def htmlSuspended(baseDir: str) -> str:
"""Show the screen for suspended accounts
"""