Formatting of welcome text

merge-requests/21/head
Bob Mottram 2021-02-24 19:04:51 +00:00
parent 28deeff775
commit 47788d5a43
4 changed files with 28 additions and 2 deletions

View File

@ -0,0 +1,5 @@
# Welcome
Epicyon is an ActivityPub server designed for self-hosting of a few people on low power systems such as single board computers or old laptops. It's intended to be as easy as possible to install and maintain.

View File

@ -0,0 +1 @@
Welcome to Epicyon

View File

@ -21,6 +21,26 @@ from content import addHtmlTags
from content import replaceEmojiFromTags
def markdownToHtml(markdown: str) -> str:
"""Converts markdown formatted text to html
"""
linesList = markdown.split('\n')
htmlStr = ''
for line in linesList:
if line.startswith('#####'):
line = line.replace('#####', '<h5>').strip() + '</h5>'
elif line.startswith('####'):
line = line.replace('####', '<h4>').strip() + '</h4>'
elif line.startswith('###'):
line = line.replace('###', '<h3>').strip() + '</h3>'
elif line.startswith('##'):
line = line.replace('##', '<h2>').strip() + '</h2>'
elif line.startswith('#'):
line = line.replace('#', '<h1>').strip() + '</h1>'
htmlStr += line
return htmlStr
def getBrokenLinkSubstitute() -> str:
"""Returns html used to show a default image if the link to
an image is broken

View File

@ -11,6 +11,7 @@ from shutil import copyfile
from utils import getConfigParam
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_utils import markdownToHtml
def welcomeScreenShown(baseDir: str, nickname: str, domain: str):
@ -41,8 +42,7 @@ def htmlWelcomeScreen(baseDir: str, nickname: str, domain: str,
copyfile(defaultFilename, welcomeFilename)
if os.path.isfile(welcomeFilename):
with open(baseDir + '/accounts/welcome.txt', 'r') as welcomeFile:
welcomeText = welcomeFile.read()
welcomeText = welcomeText.replace('\n', '<br>')
welcomeText = markdownToHtml(welcomeFile.read())
welcomeForm = ''
cssFilename = baseDir + '/epicyon-welcome.css'