Initial html timeline

master
Bob Mottram 2019-07-21 10:09:28 +01:00
parent 2b02a1a442
commit 2b3a947265
4 changed files with 85 additions and 3 deletions

View File

@ -325,6 +325,15 @@ class PubServer(BaseHTTPRequestHandler):
print('DEBUG: GET from '+self.server.baseDir+ \
' path: '+self.path+' busy: '+ \
str(self.server.GETbusy))
# get css
# Note that this comes before the busy flag to avoid conflicts
if self.path.endswith('.css'):
if os.path.isfile('epicyon.css'):
with open('epicyon.css', 'r') as cssfile:
css = cssfile.read()
self._set_headers('text/css')
self.wfile.write(css.encode('utf-8'))
return
if self.server.GETbusy:
currTimeGET=int(time.time())
if currTimeGET-self.server.lastGET<10:

48
epicyon.css 100644
View File

@ -0,0 +1,48 @@
body {
margin: 0 auto;
max-width: 800px;
padding: 0 20px;
}
.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: 50%;
}
.container img.right {
float: right;
margin-left: 20px;
margin-right:0;
}
.time-right {
float: right;
color: #aaa;
}
.time-left {
float: left;
color: #999;
}

View File

@ -1196,6 +1196,9 @@ def createBoxBase(baseDir: str,boxname: str, \
# get the post as json
with open(filePath, 'r') as fp:
p=commentjson.load(fp)
# remove any capability so that it's not displayed
if p.get('capability'):
del p['capability']
# Don't show likes or replies to unauthorized viewers
if not authorized:
if p.get('object'):

View File

@ -40,20 +40,42 @@ def htmlFollowers(followersJson: {}) -> str:
"""
return htmlHeader()+"<h1>Followers collection</h1>"+htmlFooter()
def individualPostAsHtml(postJsonObject: {}) -> str:
return \
'<div class="container">\n' \
'<img src="'+postJsonObject['actor']+'/avatar.png" alt="Avatar">\n'+ \
postJsonObject['object']['content']+'\n'+ \
'<span class="time-right">'+postJsonObject['object']['published']+'</span>\n' \
'</div>\n'
def htmlTimeline(timelineJson: {}) -> str:
"""Show the timeline as html
"""
if not timelineJson.get('orderedItems'):
return ""
tlStr=htmlHeader()
for item in timelineJson['orderedItems']:
if item['type']=='Create':
tlStr+=individualPostAsHtml(item)
tlStr+=htmlFooter()
return tlStr
def htmlInbox(inboxJson: {}) -> str:
"""Show the inbox as html
"""
return htmlHeader()+"<h1>Inbox</h1>"+htmlFooter()
return htmlTimeline(inboxJson)
def htmlOutbox(outboxJson: {}) -> str:
"""Show the Outbox as html
"""
return htmlHeader()+"<h1>Outbox</h1>"+htmlFooter()
return htmlTimeline(outboxJson)
def htmlIndividualPost(postJsonObject: {}) -> str:
"""Show an individual post as html
"""
return htmlHeader()+"<h1>Post</h1>"+htmlFooter()
return htmlHeader()+ \
individualPostAsHtml(postJsonObject)+ \
htmlFooter()
def htmlPostReplies(postJsonObject: {}) -> str:
"""Show the replies to an individual post as html