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_search import htmlSearch
|
||||||
from webapp_hashtagswarm import getHashtagCategoriesFeed
|
from webapp_hashtagswarm import getHashtagCategoriesFeed
|
||||||
from webapp_hashtagswarm import htmlSearchHashtagCategory
|
from webapp_hashtagswarm import htmlSearchHashtagCategory
|
||||||
|
from webapp_welcome import welcomeScreenIsComplete
|
||||||
from webapp_welcome import htmlWelcomeScreen
|
from webapp_welcome import htmlWelcomeScreen
|
||||||
from webapp_welcome import isWelcomeScreenComplete
|
from webapp_welcome import isWelcomeScreenComplete
|
||||||
from webapp_welcome_profile import htmlWelcomeProfile
|
from webapp_welcome_profile import htmlWelcomeProfile
|
||||||
|
from webapp_welcome_final import htmlWelcomeFinal
|
||||||
from shares import getSharesFeedForPerson
|
from shares import getSharesFeedForPerson
|
||||||
from shares import addShare
|
from shares import addShare
|
||||||
from shares import removeShare
|
from shares import removeShare
|
||||||
|
@ -4046,13 +4048,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
postImageFilename)
|
postImageFilename)
|
||||||
|
|
||||||
postBytesStr = postBytes.decode('utf-8')
|
postBytesStr = postBytes.decode('utf-8')
|
||||||
print('postBytesStr: ' + postBytesStr)
|
redirectPath = ''
|
||||||
if '&previewAvatar=' in postBytesStr:
|
checkNameAndBio = False
|
||||||
print('previewAvatar in postBytes')
|
if 'name="previewAvatar"' in postBytesStr:
|
||||||
if '&prevWelcomeScreen=' in postBytesStr:
|
redirectPath = '/welcome_profile'
|
||||||
print('prevWelcomeScreen in postBytes')
|
elif 'name="initialWelcomeScreen"' in postBytesStr:
|
||||||
if '&nextWelcomeScreen=' in postBytesStr:
|
redirectPath = '/welcome'
|
||||||
print('nextWelcomeScreen in postBytes')
|
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
|
# extract all of the text fields into a dict
|
||||||
fields = \
|
fields = \
|
||||||
|
@ -4184,7 +4192,12 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actorJson['name'] = displayName
|
actorJson['name'] = displayName
|
||||||
else:
|
else:
|
||||||
actorJson['name'] = nickname
|
actorJson['name'] = nickname
|
||||||
|
if checkNameAndBio:
|
||||||
|
redirectPath = 'previewAvatar'
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
else:
|
||||||
|
if checkNameAndBio:
|
||||||
|
redirectPath = 'previewAvatar'
|
||||||
|
|
||||||
# change media instance status
|
# change media instance status
|
||||||
if fields.get('mediaInstance'):
|
if fields.get('mediaInstance'):
|
||||||
|
@ -4548,6 +4561,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actorJson['tag'].append(tag)
|
actorJson['tag'].append(tag)
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
else:
|
else:
|
||||||
|
if checkNameAndBio:
|
||||||
|
redirectPath = 'previewAvatar'
|
||||||
|
else:
|
||||||
|
if checkNameAndBio:
|
||||||
|
redirectPath = 'previewAvatar'
|
||||||
if actorJson['summary']:
|
if actorJson['summary']:
|
||||||
actorJson['summary'] = ''
|
actorJson['summary'] = ''
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
@ -5034,7 +5052,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
i2pDomain):
|
i2pDomain):
|
||||||
actorStr = \
|
actorStr = \
|
||||||
'http://' + i2pDomain + usersPath
|
'http://' + i2pDomain + usersPath
|
||||||
self._redirect_headers(actorStr, cookie, callingDomain)
|
self._redirect_headers(actorStr + redirectPath,
|
||||||
|
cookie, callingDomain)
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
|
|
||||||
def _progressiveWebAppManifest(self, callingDomain: str,
|
def _progressiveWebAppManifest(self, callingDomain: str,
|
||||||
|
@ -10682,6 +10701,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'show about screen done',
|
'show about screen done',
|
||||||
'robots txt')
|
'robots txt')
|
||||||
|
|
||||||
|
# the initial welcome screen after first logging in
|
||||||
if htmlGET and authorized and \
|
if htmlGET and authorized and \
|
||||||
'/users/' in self.path and self.path.endswith('/welcome'):
|
'/users/' in self.path and self.path.endswith('/welcome'):
|
||||||
nickname = self.path.split('/users/')[1]
|
nickname = self.path.split('/users/')[1]
|
||||||
|
@ -10705,6 +10725,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
self.path = self.path.replace('/welcome', '')
|
self.path = self.path.replace('/welcome', '')
|
||||||
|
|
||||||
|
# the welcome screen which allows you to set an avatar image
|
||||||
if htmlGET and authorized and \
|
if htmlGET and authorized and \
|
||||||
'/users/' in self.path and self.path.endswith('/welcome_profile'):
|
'/users/' in self.path and self.path.endswith('/welcome_profile'):
|
||||||
nickname = self.path.split('/users/')[1]
|
nickname = self.path.split('/users/')[1]
|
||||||
|
@ -10731,6 +10752,33 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
self.path = self.path.replace('/welcome_profile', '')
|
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 not authorized then show the login screen
|
||||||
if htmlGET and self.path != '/login' and \
|
if htmlGET and self.path != '/login' and \
|
||||||
not self._pathIsImage(self.path) 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)
|
return os.path.isfile(completeFilename)
|
||||||
|
|
||||||
|
|
||||||
# def welcomeScreenIsComplete(baseDir: str,
|
def welcomeScreenIsComplete(baseDir: str,
|
||||||
# nickname: str, domain: str) -> None:
|
nickname: str, domain: str) -> None:
|
||||||
# """Indicates that the welcome screen has been shown for a given account
|
"""Indicates that the welcome screen has been shown for a given account
|
||||||
# """
|
"""
|
||||||
# accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
# if not os.path.isdir(accountPath):
|
if not os.path.isdir(accountPath):
|
||||||
# return
|
return
|
||||||
# completeFilename = accountPath + '/.welcome_complete'
|
completeFilename = accountPath + '/.welcome_complete'
|
||||||
# completeFile = open(completeFilename, 'w+')
|
completeFile = open(completeFilename, 'w+')
|
||||||
# if completeFile:
|
if completeFile:
|
||||||
# completeFile.write('\n')
|
completeFile.write('\n')
|
||||||
# completeFile.close()
|
completeFile.close()
|
||||||
#
|
|
||||||
#
|
|
||||||
def htmlWelcomeScreen(baseDir: str,
|
def htmlWelcomeScreen(baseDir: str,
|
||||||
language: str, translate: {},
|
language: str, translate: {},
|
||||||
currScreen='welcome',
|
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 += '<div class="container next">\n'
|
||||||
profileForm += \
|
profileForm += \
|
||||||
' <button type="submit" class="button" ' + \
|
' <button type="submit" class="button" ' + \
|
||||||
'name="prevWelcomeScreen">' + translate['Go Back'] + '</button> '
|
'name="initialWelcomeScreen">' + translate['Go Back'] + '</button> '
|
||||||
profileForm += \
|
profileForm += \
|
||||||
' <button type="submit" class="button" ' + \
|
' <button type="submit" class="button" ' + \
|
||||||
'name="nextWelcomeScreen">' + translate['Next'] + '</button>\n'
|
'name="finalWelcomeScreen">' + translate['Next'] + '</button>\n'
|
||||||
profileForm += '</div>\n'
|
profileForm += '</div>\n'
|
||||||
|
|
||||||
profileForm += '</form>\n'
|
profileForm += '</form>\n'
|
||||||
|
|
Loading…
Reference in New Issue