From 8b3b71d9421f4fa1d6126969ce322779d3fbada8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 21 Jul 2019 12:20:49 +0100 Subject: [PATCH] Showing image attachments --- epicyon.css | 8 ++++++++ epicyon.py | 4 ++-- webinterface.py | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/epicyon.css b/epicyon.css index 6fe4884e..4bb83452 100644 --- a/epicyon.css +++ b/epicyon.css @@ -1,3 +1,5 @@ +@charset "UTF-8"; + body { margin: 0 auto; max-width: 800px; @@ -31,6 +33,12 @@ body { border-radius: 50%; } +.container img.attachment { + max-width: 100%; + margin-left: 25%; + width: 50%; + border-radius: 0%; +} .container img.right { float: right; margin-left: 20px; diff --git a/epicyon.py b/epicyon.py index df5e6ac6..75dfe7a5 100644 --- a/epicyon.py +++ b/epicyon.py @@ -1056,8 +1056,8 @@ if args.testdata: createPublicPost(baseDir,nickname,domain,port,httpPrefix,"like, this is totally just a test, man",False,True,False,None,None,useBlurhash) createPublicPost(baseDir,nickname,domain,port,httpPrefix,"Zoiks!!!",False,True,False,None,None,useBlurhash) createPublicPost(baseDir,nickname,domain,port,httpPrefix,"Hey scoob we need like a hundred more milkshakes",False,True,False,None,None,useBlurhash) - createPublicPost(baseDir,nickname,domain,port,httpPrefix,"Getting kinda spooky around here",False,True,False,None,None,useBlurhash) - createPublicPost(baseDir,nickname,domain,port,httpPrefix,"And they would have gotten away with it too if it wasn't for those pesky hackers",False,True,False,None,None,useBlurhash) + createPublicPost(baseDir,nickname,domain,port,httpPrefix,"Getting kinda spooky around here",False,True,False,None,None,useBlurhash,'someone') + createPublicPost(baseDir,nickname,domain,port,httpPrefix,"And they would have gotten away with it too if it wasn't for those pesky hackers",False,True,False,'img/logo.png','Description of image',useBlurhash) createPublicPost(baseDir,nickname,domain,port,httpPrefix,"man, these centralized sites are, like, the worst!",False,True,False,None,None,useBlurhash) createPublicPost(baseDir,nickname,domain,port,httpPrefix,"another mystery solved hey",False,True,False,None,None,useBlurhash) createPublicPost(baseDir,nickname,domain,port,httpPrefix,"let's go bowling",False,True,False,None,None,useBlurhash) diff --git a/webinterface.py b/webinterface.py index 80b3550f..17c9d7f6 100644 --- a/webinterface.py +++ b/webinterface.py @@ -41,11 +41,42 @@ def htmlFollowers(followersJson: {}) -> str: return htmlHeader()+"

Followers collection

"+htmlFooter() def individualPostAsHtml(postJsonObject: {}) -> str: + avatarPosition='' + containerClass='container' + timeClass='time-right' + if postJsonObject['object']['inReplyTo']: + containerClass='container darker' + avatarPosition=' class="right"' + timeClass='time-left' + attachmentStr='' + if postJsonObject['object']['attachment']: + if isinstance(postJsonObject['object']['attachment'], list): + attachmentCtr=0 + for attach in postJsonObject['object']['attachment']: + if attach.get('mediaType') and attach.get('url'): + mediaType=attach['mediaType'] + imageDescription='' + if attach.get('name'): + imageDescription=attach['name'] + if mediaType=='image/png' or \ + mediaType=='image/jpeg' or \ + mediaType=='image/gif': + if attach['url'].endswith('.png') or \ + attach['url'].endswith('.jpg') or \ + attach['url'].endswith('.jpeg') or \ + attach['url'].endswith('.gif'): + if attachmentCtr>0: + attachmentStr+='
' + attachmentStr+= \ + ''+imageDescription+'\n' + attachmentCtr+=1 + return \ - '
\n' \ - 'Avatar\n'+ \ + '
\n' \ + 'Avatar\n'+ \ postJsonObject['object']['content']+'\n'+ \ - ''+postJsonObject['object']['published']+'\n' \ + attachmentStr+ \ + ''+postJsonObject['object']['published']+'\n'+ \ '
\n' def htmlTimeline(timelineJson: {}) -> str: