From 526ccad163118278d43f6a9171891fa67fb2e5ce Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 28 Sep 2020 10:55:28 +0100 Subject: [PATCH] Show a sending screen when post is sent --- daemon.py | 26 ++++++++++++--- epicyon-send.css | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ theme.py | 2 +- webinterface.py | 21 +++++++++++- 4 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 epicyon-send.css diff --git a/daemon.py b/daemon.py index 1f5d0d38a..6ef14f9a7 100644 --- a/daemon.py +++ b/daemon.py @@ -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: diff --git a/epicyon-send.css b/epicyon-send.css new file mode 100644 index 000000000..4a5d03304 --- /dev/null +++ b/epicyon-send.css @@ -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; +} diff --git a/theme.py b/theme.py index 1c092e630..c32d64a76 100644 --- a/theme.py +++ b/theme.py @@ -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() -> []: diff --git a/webinterface.py b/webinterface.py index 6a07bd8d8..2f814981d 100644 --- a/webinterface.py +++ b/webinterface.py @@ -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 += '
\n' + sendForm += '

Sending Post

\n' + sendForm += \ + '

Please wait

\n' + sendForm += '
\n' + sendForm += htmlFooter() + return sendForm + + def htmlSuspended(baseDir: str) -> str: """Show the screen for suspended accounts """