mirror of https://gitlab.com/bashrc2/epicyon
Displaying welcome screen
parent
93f7aa7889
commit
b8ac29a515
25
daemon.py
25
daemon.py
|
@ -181,6 +181,8 @@ 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 htmlWelcomeScreen
|
||||||
|
from webapp_welcome import isWelcomeScreenComplete
|
||||||
from shares import getSharesFeedForPerson
|
from shares import getSharesFeedForPerson
|
||||||
from shares import addShare
|
from shares import addShare
|
||||||
from shares import removeShare
|
from shares import removeShare
|
||||||
|
@ -10670,6 +10672,29 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'show about screen done',
|
'show about screen done',
|
||||||
'robots txt')
|
'robots txt')
|
||||||
|
|
||||||
|
if htmlGET and authorized and \
|
||||||
|
'/users/' in self.path and self.path.endswith('/welcome'):
|
||||||
|
nickname = self.path.split('/users/')[1]
|
||||||
|
if '/' in nickname:
|
||||||
|
nickname = nickname.split('/')[0]
|
||||||
|
if not isWelcomeScreenComplete(self.server.baseDir,
|
||||||
|
nickname,
|
||||||
|
self.server.domain):
|
||||||
|
msg = \
|
||||||
|
htmlWelcomeScreen(self.server.baseDir,
|
||||||
|
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,
|
||||||
|
'following accounts done',
|
||||||
|
'show welcome screen')
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.path = self.path.replace('/welcome', '')
|
||||||
|
|
||||||
# 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 \
|
||||||
|
|
2
tests.py
2
tests.py
|
@ -3290,7 +3290,7 @@ def testMarkdownToHtml():
|
||||||
|
|
||||||
markdown = '# Title1\n### Title3\n## Title2\n'
|
markdown = '# Title1\n### Title3\n## Title2\n'
|
||||||
assert markdownToHtml(markdown) == \
|
assert markdownToHtml(markdown) == \
|
||||||
'<h1>Title1</h1><br><h3>Title3</h3><br><h2>Title2</h2><br>'
|
'<h1>Title1</h1><h3>Title3</h3><h2>Title2</h2>'
|
||||||
|
|
||||||
markdown = \
|
markdown = \
|
||||||
'This is [a link](https://something.somewhere) to something\n' + \
|
'This is [a link](https://something.somewhere) to something\n' + \
|
||||||
|
|
|
@ -56,18 +56,23 @@ def markdownToHtml(markdown: str) -> str:
|
||||||
if line.startswith('#####'):
|
if line.startswith('#####'):
|
||||||
line = line.replace('#####', '').strip()
|
line = line.replace('#####', '').strip()
|
||||||
line = '<h5>' + line + '</h5>'
|
line = '<h5>' + line + '</h5>'
|
||||||
|
ctr = -1
|
||||||
elif line.startswith('####'):
|
elif line.startswith('####'):
|
||||||
line = line.replace('####', '').strip()
|
line = line.replace('####', '').strip()
|
||||||
line = '<h4>' + line + '</h4>'
|
line = '<h4>' + line + '</h4>'
|
||||||
|
ctr = -1
|
||||||
elif line.startswith('###'):
|
elif line.startswith('###'):
|
||||||
line = line.replace('###', '').strip()
|
line = line.replace('###', '').strip()
|
||||||
line = '<h3>' + line + '</h3>'
|
line = '<h3>' + line + '</h3>'
|
||||||
|
ctr = -1
|
||||||
elif line.startswith('##'):
|
elif line.startswith('##'):
|
||||||
line = line.replace('##', '').strip()
|
line = line.replace('##', '').strip()
|
||||||
line = '<h2>' + line + '</h2>'
|
line = '<h2>' + line + '</h2>'
|
||||||
|
ctr = -1
|
||||||
elif line.startswith('#'):
|
elif line.startswith('#'):
|
||||||
line = line.replace('#', '').strip()
|
line = line.replace('#', '').strip()
|
||||||
line = '<h1>' + line + '</h1>'
|
line = '<h1>' + line + '</h1>'
|
||||||
|
ctr = -1
|
||||||
htmlStr += line
|
htmlStr += line
|
||||||
ctr += 1
|
ctr += 1
|
||||||
return htmlStr
|
return htmlStr
|
||||||
|
|
|
@ -14,17 +14,30 @@ from webapp_utils import htmlFooter
|
||||||
from webapp_utils import markdownToHtml
|
from webapp_utils import markdownToHtml
|
||||||
|
|
||||||
|
|
||||||
def welcomeScreenShown(baseDir: str, nickname: str, domain: str):
|
def isWelcomeScreenComplete(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
|
"""Returns true if the welcome screen is complete for the given account
|
||||||
|
"""
|
||||||
|
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
|
if not os.path.isdir(accountPath):
|
||||||
|
return
|
||||||
|
completeFilename = accountPath + '/.welcome_complete'
|
||||||
|
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
|
"""Indicates that the welcome screen has been shown for a given account
|
||||||
"""
|
"""
|
||||||
shownFilename = baseDir + '/accounts/.welcome_shown'
|
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
shownFile = open(shownFilename, 'w+')
|
if not os.path.isdir(accountPath):
|
||||||
if shownFile:
|
return
|
||||||
shownFile.write('\n')
|
completeFilename = accountPath + '/.welcome_complete'
|
||||||
shownFile.close()
|
completeFile = open(completeFilename, 'w+')
|
||||||
|
if completeFile:
|
||||||
|
completeFile.write('\n')
|
||||||
|
completeFile.close()
|
||||||
|
|
||||||
|
|
||||||
def htmlWelcomeScreen(baseDir: str, nickname: str, domain: str,
|
def htmlWelcomeScreen(baseDir: str,
|
||||||
language: str, translate: {}) -> str:
|
language: str, translate: {}) -> str:
|
||||||
"""Returns the welcome screen
|
"""Returns the welcome screen
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue