From 47788d5a43f2fccbfc2336a81ca2e092c6d1df61 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 24 Feb 2021 19:04:51 +0000 Subject: [PATCH] Formatting of welcome text --- defaultwelcome/en.txt | 5 +++++ defaultwelcome/en.txt~ | 1 + webapp_utils.py | 20 ++++++++++++++++++++ webapp_welcome.py | 4 ++-- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 defaultwelcome/en.txt create mode 100644 defaultwelcome/en.txt~ diff --git a/defaultwelcome/en.txt b/defaultwelcome/en.txt new file mode 100644 index 000000000..9e8186fe8 --- /dev/null +++ b/defaultwelcome/en.txt @@ -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. + + diff --git a/defaultwelcome/en.txt~ b/defaultwelcome/en.txt~ new file mode 100644 index 000000000..334cab178 --- /dev/null +++ b/defaultwelcome/en.txt~ @@ -0,0 +1 @@ +Welcome to Epicyon diff --git a/webapp_utils.py b/webapp_utils.py index 64b1cae89..1ab1afd40 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -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('#####', '
').strip() + '
' + elif line.startswith('####'): + line = line.replace('####', '

').strip() + '

' + elif line.startswith('###'): + line = line.replace('###', '

').strip() + '

' + elif line.startswith('##'): + line = line.replace('##', '

').strip() + '

' + elif line.startswith('#'): + line = line.replace('#', '

').strip() + '

' + htmlStr += line + return htmlStr + + def getBrokenLinkSubstitute() -> str: """Returns html used to show a default image if the link to an image is broken diff --git a/webapp_welcome.py b/webapp_welcome.py index 0cdecfe11..41f0f4d8f 100644 --- a/webapp_welcome.py +++ b/webapp_welcome.py @@ -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', '
') + welcomeText = markdownToHtml(welcomeFile.read()) welcomeForm = '' cssFilename = baseDir + '/epicyon-welcome.css'