From 0f448553abfdfd585a8c7c2bcf60c60f20f2b9e0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 21 Jul 2019 23:38:44 +0100 Subject: [PATCH] Showing posts on profile --- daemon.py | 6 ++++- webinterface.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/daemon.py b/daemon.py index 463d70ca..9b66408c 100644 --- a/daemon.py +++ b/daemon.py @@ -670,7 +670,11 @@ class PubServer(BaseHTTPRequestHandler): if getPerson: if 'text/html' in self.headers['Accept']: self._set_headers('text/html') - self.wfile.write(htmlProfile(getPerson).encode('utf-8')) + self.wfile.write(htmlProfile(self.server.baseDir, \ + self.server.httpPrefix, \ + authorized, \ + self.server.ocapAlways, \ + getPerson).encode('utf-8')) else: self._set_headers('application/json') self.wfile.write(json.dumps(getPerson).encode('utf-8')) diff --git a/webinterface.py b/webinterface.py index 4e0e5239..236ca211 100644 --- a/webinterface.py +++ b/webinterface.py @@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net" __status__ = "Production" import json +from person import personBoxJson from utils import getNicknameFromActor from utils import getDomainFromActor @@ -35,7 +36,7 @@ def htmlFooter() -> str: '\n' return htmlStr -def htmlProfile(profileJson: {}) -> str: +def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool,ocapAlways: bool,profileJson: {}) -> str: """Show the profile page as html """ nickname=profileJson['name'] @@ -64,6 +65,9 @@ def htmlProfile(profileJson: {}) -> str: ' ' \ ' ' \ ' ' \ + ' ' \ + ' ' \ + ' ' \ ' ' \ '' @@ -159,7 +163,73 @@ def htmlProfile(profileJson: {}) -> str: ' border-radius: 5px;' \ ' padding: 10px;' \ ' margin: 10px 0;' \ + '}' \ + '' \ + '.container {' \ + ' border: 2px solid #dedede;' \ + ' background-color: #f1f1f1;' \ + ' border-radius: 5px;' \ + ' padding: 10px;' \ + ' margin: 10px 0;' \ + '}' \ + '' \ + '.darker {' \ + ' border-color: #ccc;' \ + ' background-color: #ddd;' \ + '}' \ + '' \ + '.container::after {' \ + ' content: "";' \ + ' clear: both;' \ + ' display: table;' \ + '}' \ + '' \ + '.container img {' \ + ' float: left;' \ + ' max-width: 60px;' \ + ' width: 100%;' \ + ' margin-right: 20px;' \ + ' border-radius: 10%;' \ + '}' \ + '' \ + '.container img.attachment {' \ + ' max-width: 100%;' \ + ' margin-left: 25%;' \ + ' width: 50%;' \ + ' border-radius: 10%;' \ + '}' \ + '.container img.right {' \ + ' float: right;' \ + ' margin-left: 20px;' \ + ' margin-right:0;' \ + '}' \ + '' \ + '.time-right {' \ + ' float: right;' \ + ' color: #aaa;' \ + '}' \ + '' \ + '.time-left {' \ + ' float: left;' \ + ' color: #999;' \ + '}' \ + '' \ + '.post-title {' \ + ' margin-top: 0px;' \ + ' color: #999;' \ '}' + + # show some posts + outboxFeed=personBoxJson(baseDir,domain, \ + port,'/users/'+nickname+'/outbox?page=1', \ + httpPrefix, \ + 4, 'outbox', \ + authorized, \ + ocapAlways) + for item in outboxFeed['orderedItems']: + if item['type']=='Create': + profileStr+=individualPostAsHtml(item) + profileStr=htmlHeader(profileStyle)+profileStr+htmlFooter() return profileStr