From 91981c795343888640157e8d2ef5e38f11d055ff Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 26 Aug 2019 17:02:47 +0100 Subject: [PATCH] About screen --- daemon.py | 10 ++++++++++ default_about.txt | 13 +++++++++++++ webinterface.py | 27 +++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 default_about.txt diff --git a/daemon.py b/daemon.py index e36b79f3d..5afc296c9 100644 --- a/daemon.py +++ b/daemon.py @@ -76,6 +76,7 @@ from roles import setRole from roles import clearModeratorStatus from skills import outboxSkills from availability import outboxAvailability +from webinterface import htmlAbout from webinterface import htmlRemoveSharedItem from webinterface import htmlInboxDMs from webinterface import htmlUnblockConfirm @@ -792,6 +793,15 @@ class PubServer(BaseHTTPRequestHandler): self.server.GETbusy=False return + if self.path.startswith('/about'): + msg=htmlAbout(self.server.baseDir, \ + self.server.httpPrefix, \ + self.server.domainFull).encode() + self._login_headers('text/html',len(msg)) + self.wfile.write(msg) + self.server.GETbusy=False + return + if self.path.startswith('/login') or self.path=='/': # request basic auth msg=htmlLogin(self.server.baseDir).encode('utf-8') diff --git a/default_about.txt b/default_about.txt new file mode 100644 index 000000000..a1e535820 --- /dev/null +++ b/default_about.txt @@ -0,0 +1,13 @@ +

About this Instance

+ +

Origin Story

+ +

How your instance began.

+ +

Lore

+ +

Customs and rituals.

+ +

Epic Tales

+ +

Heroic deeds and dastardly foes.

diff --git a/webinterface.py b/webinterface.py index ee17d7c39..9254b3c26 100644 --- a/webinterface.py +++ b/webinterface.py @@ -523,6 +523,33 @@ def htmlTermsOfService(baseDir: str,httpPrefix: str,domainFull: str) -> str: TOSForm+=htmlFooter() return TOSForm +def htmlAbout(baseDir: str,httpPrefix: str,domainFull: str) -> str: + """Show the about screen + """ + adminNickname = getConfigParam(baseDir,'admin') + if not os.path.isfile(baseDir+'/accounts/about.txt'): + copyfile(baseDir+'/default_about.txt',baseDir+'/accounts/about.txt') + if os.path.isfile(baseDir+'/img/login-background.png'): + if not os.path.isfile(baseDir+'/accounts/login-background.png'): + copyfile(baseDir+'/img/login-background.png',baseDir+'/accounts/login-background.png') + + aboutText='Information about this instance goes here.' + if os.path.isfile(baseDir+'/accounts/about.txt'): + with open(baseDir+'/accounts/about.txt', 'r') as file: + aboutText = file.read() + + aboutForm='' + with open(baseDir+'/epicyon-profile.css', 'r') as cssFile: + termsCSS = cssFile.read() + + aboutForm=htmlHeader(termsCSS) + aboutForm+='
'+aboutText+'
' + if adminNickname: + adminActor=httpPrefix+'://'+domainFull+'/users/'+adminNickname + aboutForm+='

Administered by '+adminNickname+'

' + aboutForm+=htmlFooter() + return aboutForm + def htmlHashtagBlocked(baseDir: str) -> str: """Show the screen for a blocked hashtag """