mirror of https://gitlab.com/bashrc2/epicyon
Final welcome screen
parent
a2dc870296
commit
6dd4e43354
64
daemon.py
64
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 \
|
||||
|
|
|
@ -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.
|
|
@ -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',
|
||||
|
|
|
@ -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 += '<div class="container">' + finalText + '</div>\n'
|
||||
finalForm += \
|
||||
'<form enctype="multipart/form-data" method="POST" ' + \
|
||||
'accept-charset="UTF-8" ' + \
|
||||
'action="/users/' + nickname + '/profiledata">\n'
|
||||
finalForm += '<div class="container next">\n'
|
||||
finalForm += \
|
||||
' <button type="submit" class="button" ' + \
|
||||
'name="previewAvatar">' + translate['Go Back'] + '</button>\n'
|
||||
finalForm += \
|
||||
' <button type="submit" class="button" ' + \
|
||||
'name="welcomeCompleteButton">' + translate['Next'] + '</button>\n'
|
||||
finalForm += '</div>\n'
|
||||
|
||||
finalForm += '</form>\n'
|
||||
finalForm += htmlFooter()
|
||||
return finalForm
|
|
@ -100,10 +100,10 @@ def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str,
|
|||
profileForm += '<div class="container next">\n'
|
||||
profileForm += \
|
||||
' <button type="submit" class="button" ' + \
|
||||
'name="prevWelcomeScreen">' + translate['Go Back'] + '</button> '
|
||||
'name="initialWelcomeScreen">' + translate['Go Back'] + '</button> '
|
||||
profileForm += \
|
||||
' <button type="submit" class="button" ' + \
|
||||
'name="nextWelcomeScreen">' + translate['Next'] + '</button>\n'
|
||||
'name="finalWelcomeScreen">' + translate['Next'] + '</button>\n'
|
||||
profileForm += '</div>\n'
|
||||
|
||||
profileForm += '</form>\n'
|
||||
|
|
Loading…
Reference in New Issue