mirror of https://gitlab.com/bashrc2/epicyon
Welcome profile screen
parent
75249cf554
commit
5787565961
27
daemon.py
27
daemon.py
|
@ -183,6 +183,7 @@ from webapp_hashtagswarm import getHashtagCategoriesFeed
|
|||
from webapp_hashtagswarm import htmlSearchHashtagCategory
|
||||
from webapp_welcome import htmlWelcomeScreen
|
||||
from webapp_welcome import isWelcomeScreenComplete
|
||||
from webapp_welcome_profile import htmlWelcomeProfile
|
||||
from shares import getSharesFeedForPerson
|
||||
from shares import addShare
|
||||
from shares import removeShare
|
||||
|
@ -10695,6 +10696,32 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self.path = self.path.replace('/welcome', '')
|
||||
|
||||
if htmlGET and authorized and \
|
||||
'/users/' in self.path and self.path.endswith('/welcome_profile'):
|
||||
nickname = self.path.split('/users/')[1]
|
||||
if '/' in nickname:
|
||||
nickname = nickname.split('/')[0]
|
||||
if not isWelcomeScreenComplete(self.server.baseDir,
|
||||
nickname,
|
||||
self.server.domain):
|
||||
msg = \
|
||||
htmlWelcomeProfile(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 screen',
|
||||
'show welcome profile screen')
|
||||
return
|
||||
else:
|
||||
self.path = self.path.replace('/welcome_profile', '')
|
||||
|
||||
# if not authorized then show the login screen
|
||||
if htmlGET and self.path != '/login' and \
|
||||
not self._pathIsImage(self.path) and \
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# Account Setup
|
||||
## Account Setup
|
||||
|
||||
Add your avatar image, name and description. Use a small avatar image (eg. 128x128 pixels) so that it's quick to download.
|
||||
Select your avatar image and add your name and description. Use a small avatar image (eg. 128x128 pixels) so that it's quick to download.
|
||||
|
|
|
@ -24,19 +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',
|
||||
|
|
|
@ -8,8 +8,10 @@ __status__ = "Production"
|
|||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from utils import loadJson
|
||||
from utils import getConfigParam
|
||||
from utils import getImageExtensions
|
||||
from utils import getImageFormats
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
from webapp_utils import htmlFooter
|
||||
from webapp_utils import markdownToHtml
|
||||
|
@ -17,8 +19,7 @@ from webapp_utils import markdownToHtml
|
|||
|
||||
def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str,
|
||||
httpPrefix: str, domainFull: str,
|
||||
language: str, translate: {},
|
||||
prevScreen='welcome') -> str:
|
||||
language: str, translate: {}) -> str:
|
||||
"""Returns the welcome profile screen to set avatar and bio
|
||||
"""
|
||||
# set a custom background for the welcome screen
|
||||
|
@ -58,16 +59,46 @@ def htmlWelcomeProfile(baseDir: str, nickname: str, domain: str,
|
|||
httpPrefix + '://' + domainFull + \
|
||||
'/users/' + nickname + '/avatar.' + ext
|
||||
|
||||
imageFormats = getImageFormats()
|
||||
profileForm += \
|
||||
'<form enctype="multipart/form-data" method="POST" ' + \
|
||||
'accept-charset="UTF-8" ' + \
|
||||
'action="/users/' + nickname + '/welcomeprofile">\n'
|
||||
profileForm += '<center>\n'
|
||||
profileForm += '<img class="welcomeavatar" src="' + avatarUrl + '">\n'
|
||||
profileForm += ' <img class="welcomeavatar" src="'
|
||||
profileForm += avatarUrl + '"><br>\n'
|
||||
profileForm += ' <input type="file" id="avatar" name="avatar" '
|
||||
profileForm += 'accept="' + imageFormats + '">\n'
|
||||
|
||||
profileForm += '</center>\n'
|
||||
profileForm += '<div class="container">' + profileText + '</div>\n'
|
||||
profileForm += ' <div class="container next">\n'
|
||||
profileForm += ' <a href="/' + prevScreen + '">\n'
|
||||
profileForm += ' <button>' + translate['Go Back'] + '</button></a>\n'
|
||||
profileForm += ' <a href="/welcome_complete">\n'
|
||||
profileForm += ' <button>' + translate['Next'] + '</button></a>\n'
|
||||
profileForm += \
|
||||
' <button type="submit" class="button" ' + \
|
||||
'name="prevWelcomeScreen">' + translate['Go Back'] + '</button>\n'
|
||||
profileForm += \
|
||||
' <button type="submit" class="button" ' + \
|
||||
'name="nextWelcomeScreen">' + translate['Next'] + '</button>\n'
|
||||
profileForm += ' </div>\n'
|
||||
profileForm += '</div>\n'
|
||||
|
||||
actorFilename = baseDir + '/accounts/' + nickname + '@' + domain + '.json'
|
||||
actorJson = loadJson(actorFilename)
|
||||
displayNickname = actorJson['name']
|
||||
profileForm += ' <label class="labels">' + \
|
||||
translate['Nickname'] + '</label>\n'
|
||||
profileForm += ' <input type="text" name="displayNickname" value="' + \
|
||||
displayNickname + '"><br>\n'
|
||||
|
||||
profileForm += '<center>\n'
|
||||
bioStr = \
|
||||
actorJson['summary'].replace('<p>', '').replace('</p>', '')
|
||||
profileForm += ' <label class="labels">' + \
|
||||
translate['Your bio'] + '</label>\n'
|
||||
profileForm += ' <textarea id="message" name="bio" ' + \
|
||||
'style="height:200px">' + bioStr + '</textarea>\n'
|
||||
|
||||
profileForm += '</center>\n'
|
||||
profileForm += '</form>\n'
|
||||
profileForm += htmlFooter()
|
||||
return profileForm
|
||||
|
|
Loading…
Reference in New Issue