mirror of https://gitlab.com/bashrc2/epicyon
Initial html timeline
parent
2b02a1a442
commit
2b3a947265
|
@ -325,6 +325,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
print('DEBUG: GET from '+self.server.baseDir+ \
|
print('DEBUG: GET from '+self.server.baseDir+ \
|
||||||
' path: '+self.path+' busy: '+ \
|
' path: '+self.path+' busy: '+ \
|
||||||
str(self.server.GETbusy))
|
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:
|
if self.server.GETbusy:
|
||||||
currTimeGET=int(time.time())
|
currTimeGET=int(time.time())
|
||||||
if currTimeGET-self.server.lastGET<10:
|
if currTimeGET-self.server.lastGET<10:
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
3
posts.py
3
posts.py
|
@ -1196,6 +1196,9 @@ def createBoxBase(baseDir: str,boxname: str, \
|
||||||
# get the post as json
|
# get the post as json
|
||||||
with open(filePath, 'r') as fp:
|
with open(filePath, 'r') as fp:
|
||||||
p=commentjson.load(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
|
# Don't show likes or replies to unauthorized viewers
|
||||||
if not authorized:
|
if not authorized:
|
||||||
if p.get('object'):
|
if p.get('object'):
|
||||||
|
|
|
@ -40,20 +40,42 @@ def htmlFollowers(followersJson: {}) -> str:
|
||||||
"""
|
"""
|
||||||
return htmlHeader()+"<h1>Followers collection</h1>"+htmlFooter()
|
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:
|
def htmlInbox(inboxJson: {}) -> str:
|
||||||
"""Show the inbox as html
|
"""Show the inbox as html
|
||||||
"""
|
"""
|
||||||
return htmlHeader()+"<h1>Inbox</h1>"+htmlFooter()
|
return htmlTimeline(inboxJson)
|
||||||
|
|
||||||
def htmlOutbox(outboxJson: {}) -> str:
|
def htmlOutbox(outboxJson: {}) -> str:
|
||||||
"""Show the Outbox as html
|
"""Show the Outbox as html
|
||||||
"""
|
"""
|
||||||
return htmlHeader()+"<h1>Outbox</h1>"+htmlFooter()
|
return htmlTimeline(outboxJson)
|
||||||
|
|
||||||
def htmlIndividualPost(postJsonObject: {}) -> str:
|
def htmlIndividualPost(postJsonObject: {}) -> str:
|
||||||
"""Show an individual post as html
|
"""Show an individual post as html
|
||||||
"""
|
"""
|
||||||
return htmlHeader()+"<h1>Post</h1>"+htmlFooter()
|
return htmlHeader()+ \
|
||||||
|
individualPostAsHtml(postJsonObject)+ \
|
||||||
|
htmlFooter()
|
||||||
|
|
||||||
def htmlPostReplies(postJsonObject: {}) -> str:
|
def htmlPostReplies(postJsonObject: {}) -> str:
|
||||||
"""Show the replies to an individual post as html
|
"""Show the replies to an individual post as html
|
||||||
|
|
Loading…
Reference in New Issue