diff --git a/daemon.py b/daemon.py index 32bd672ce..78b6ca0bb 100644 --- a/daemon.py +++ b/daemon.py @@ -181,9 +181,11 @@ from webapp_search import htmlSearchEmojiTextEntry from webapp_search import htmlSearch from webapp_hashtagswarm import getHashtagCategoriesFeed from webapp_hashtagswarm import htmlSearchHashtagCategory +from webapp_welcome import welcomeScreenIsComplete from webapp_welcome import htmlWelcomeScreen from webapp_welcome import isWelcomeScreenComplete from webapp_welcome_profile import htmlWelcomeProfile +from webapp_welcome_final import htmlWelcomeFinal from shares import getSharesFeedForPerson from shares import addShare from shares import removeShare @@ -4046,13 +4048,19 @@ class PubServer(BaseHTTPRequestHandler): postImageFilename) postBytesStr = postBytes.decode('utf-8') - print('postBytesStr: ' + postBytesStr) - if '&previewAvatar=' in postBytesStr: - print('previewAvatar in postBytes') - if '&prevWelcomeScreen=' in postBytesStr: - print('prevWelcomeScreen in postBytes') - if '&nextWelcomeScreen=' in postBytesStr: - print('nextWelcomeScreen in postBytes') + redirectPath = '' + checkNameAndBio = False + if 'name="previewAvatar"' in postBytesStr: + redirectPath = '/welcome_profile' + elif 'name="initialWelcomeScreen"' in postBytesStr: + redirectPath = '/welcome' + elif 'name="finalWelcomeScreen"' in postBytesStr: + checkNameAndBio = True + redirectPath = '/welcome_final' + elif 'name="welcomeCompleteButton"' in postBytesStr: + redirectPath = '/' + self.server.defaultTimeline + welcomeScreenIsComplete(self.server.baseDir, nickname, + self.server.domain) # extract all of the text fields into a dict fields = \ @@ -4184,7 +4192,12 @@ class PubServer(BaseHTTPRequestHandler): actorJson['name'] = displayName else: actorJson['name'] = nickname + if checkNameAndBio: + redirectPath = 'previewAvatar' actorChanged = True + else: + if checkNameAndBio: + redirectPath = 'previewAvatar' # change media instance status if fields.get('mediaInstance'): @@ -4547,7 +4560,12 @@ class PubServer(BaseHTTPRequestHandler): for tagName, tag in actorTags.items(): actorJson['tag'].append(tag) actorChanged = True + else: + if checkNameAndBio: + redirectPath = 'previewAvatar' else: + if checkNameAndBio: + redirectPath = 'previewAvatar' if actorJson['summary']: actorJson['summary'] = '' actorChanged = True @@ -5034,7 +5052,8 @@ class PubServer(BaseHTTPRequestHandler): i2pDomain): actorStr = \ 'http://' + i2pDomain + usersPath - self._redirect_headers(actorStr, cookie, callingDomain) + self._redirect_headers(actorStr + redirectPath, + cookie, callingDomain) self.server.POSTbusy = False def _progressiveWebAppManifest(self, callingDomain: str, @@ -10682,6 +10701,7 @@ class PubServer(BaseHTTPRequestHandler): 'show about screen done', 'robots txt') + # the initial welcome screen after first logging in if htmlGET and authorized and \ '/users/' in self.path and self.path.endswith('/welcome'): nickname = self.path.split('/users/')[1] @@ -10705,6 +10725,7 @@ class PubServer(BaseHTTPRequestHandler): else: self.path = self.path.replace('/welcome', '') + # the welcome screen which allows you to set an avatar image if htmlGET and authorized and \ '/users/' in self.path and self.path.endswith('/welcome_profile'): nickname = self.path.split('/users/')[1] @@ -10731,6 +10752,33 @@ class PubServer(BaseHTTPRequestHandler): else: self.path = self.path.replace('/welcome_profile', '') + # the final welcome screen + if htmlGET and authorized and \ + '/users/' in self.path and self.path.endswith('/welcome_final'): + nickname = self.path.split('/users/')[1] + if '/' in nickname: + nickname = nickname.split('/')[0] + if not isWelcomeScreenComplete(self.server.baseDir, + nickname, + self.server.domain): + msg = \ + htmlWelcomeFinal(self.server.baseDir, nickname, + self.server.domain, + self.server.httpPrefix, + self.server.domainFull, + self.server.systemLanguage, + self.server.translate) + msg = msg.encode('utf-8') + msglen = len(msg) + self._login_headers('text/html', msglen, callingDomain) + self._write(msg) + self._benchmarkGETtimings(GETstartTime, GETtimings, + 'show welcome profile screen', + 'show welcome final screen') + return + else: + self.path = self.path.replace('/welcome_final', '') + # if not authorized then show the login screen if htmlGET and self.path != '/login' and \ not self._pathIsImage(self.path) and \ diff --git a/defaultwelcome/final_en.md b/defaultwelcome/final_en.md new file mode 100644 index 000000000..fdfaf801b --- /dev/null +++ b/defaultwelcome/final_en.md @@ -0,0 +1,10 @@ +# Congratulations! +You are now ready to begin using Epicyon. This is a moderated social space, so please make sure to abide by our [terms of service](/terms), and have fun. + +### Hints + +Use the **magnifier** icon 🔍 to search for fediverse handles and follow people. + +Selecting the **banner at the top** of the screen switches between timeline view and your profile. + +The screen will not automatically refresh when posts arrive, so use **F5** or the **Inbox** button to refresh. diff --git a/webapp_welcome.py b/webapp_welcome.py index a7ed00635..f041e5a64 100644 --- a/webapp_welcome.py +++ b/webapp_welcome.py @@ -24,20 +24,20 @@ def isWelcomeScreenComplete(baseDir: str, nickname: str, domain: str) -> bool: return os.path.isfile(completeFilename) -# def welcomeScreenIsComplete(baseDir: str, -# nickname: str, domain: str) -> None: -# """Indicates that the welcome screen has been shown for a given account -# """ -# accountPath = baseDir + '/accounts/' + nickname + '@' + domain -# if not os.path.isdir(accountPath): -# return -# completeFilename = accountPath + '/.welcome_complete' -# completeFile = open(completeFilename, 'w+') -# if completeFile: -# completeFile.write('\n') -# completeFile.close() -# -# +def welcomeScreenIsComplete(baseDir: str, + nickname: str, domain: str) -> None: + """Indicates that the welcome screen has been shown for a given account + """ + accountPath = baseDir + '/accounts/' + nickname + '@' + domain + if not os.path.isdir(accountPath): + return + completeFilename = accountPath + '/.welcome_complete' + completeFile = open(completeFilename, 'w+') + if completeFile: + completeFile.write('\n') + completeFile.close() + + def htmlWelcomeScreen(baseDir: str, language: str, translate: {}, currScreen='welcome', diff --git a/webapp_welcome_final.py b/webapp_welcome_final.py new file mode 100644 index 000000000..2e3f6f293 --- /dev/null +++ b/webapp_welcome_final.py @@ -0,0 +1,65 @@ +__filename__ = "webapp_welcome_final.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.2.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@freedombone.net" +__status__ = "Production" + +import os +from shutil import copyfile +from utils import getConfigParam +from webapp_utils import htmlHeaderWithExternalStyle +from webapp_utils import htmlFooter +from webapp_utils import markdownToHtml + + +def htmlWelcomeFinal(baseDir: str, nickname: str, domain: str, + httpPrefix: str, domainFull: str, + language: str, translate: {}) -> str: + """Returns the final welcome screen after first login + """ + # set a custom background for the welcome screen + if os.path.isfile(baseDir + '/accounts/welcome-background-custom.jpg'): + if not os.path.isfile(baseDir + '/accounts/welcome-background.jpg'): + copyfile(baseDir + '/accounts/welcome-background-custom.jpg', + baseDir + '/accounts/welcome-background.jpg') + + finalText = 'Welcome to Epicyon' + finalFilename = baseDir + '/accounts/welcome_final.md' + if not os.path.isfile(finalFilename): + defaultFilename = \ + baseDir + '/defaultwelcome/final_' + language + '.md' + if not os.path.isfile(defaultFilename): + defaultFilename = baseDir + '/defaultwelcome/final_en.md' + copyfile(defaultFilename, finalFilename) + if os.path.isfile(finalFilename): + with open(finalFilename, 'r') as finalFile: + finalText = markdownToHtml(finalFile.read()) + + finalForm = '' + cssFilename = baseDir + '/epicyon-welcome.css' + if os.path.isfile(baseDir + '/welcome.css'): + cssFilename = baseDir + '/welcome.css' + + instanceTitle = \ + getConfigParam(baseDir, 'instanceTitle') + finalForm = htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + + finalForm += '
' + finalText + '
\n' + finalForm += \ + '
\n' + finalForm += '\n' + + finalForm += '
\n' + finalForm += htmlFooter() + return finalForm diff --git a/webapp_welcome_profile.py b/webapp_welcome_profile.py index b5c04827f..b84b474db 100644 --- a/webapp_welcome_profile.py +++ b/webapp_welcome_profile.py @@ -100,10 +100,10 @@ def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str, profileForm += '\n' profileForm += '\n'