From 33909e83bfc7591261055eefa8a8881c6c9b83ef Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 7 Aug 2019 22:36:54 +0100 Subject: [PATCH] Unfollow/block buttons on profile --- epicyon-profile.css | 17 +++++++++++++++++ webinterface.py | 36 +++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/epicyon-profile.css b/epicyon-profile.css index 077163ed0..2108e8942 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -110,6 +110,23 @@ body, html { margin: 5px; } +.buttonunfollow { + border-radius: 4px; + background-color: #999; + border: none; + color: #FFFFFF; + text-align: center; + font-size: 18px; + padding: 10px; + width: 20%; + max-width: 200px; + min-width: 100px; + transition: all 0.5s; + cursor: pointer; + margin: 5px; + float: right; +} + .buttonhighlighted { border-radius: 4px; background-color: green; diff --git a/webinterface.py b/webinterface.py index d70f49fce..467217fca 100644 --- a/webinterface.py +++ b/webinterface.py @@ -341,12 +341,15 @@ def htmlProfileFollowing(baseDir: str,httpPrefix: str, \ authorized: bool,ocapAlways: bool, \ nickname: str,domain: str,port: int, \ session,wfRequest: {},personCache: {}, \ - followingJson: {}) -> str: + followingJson: {}, \ + buttons: []) -> str: """Shows following on the profile screen """ profileStr='' for item in followingJson['orderedItems']: - profileStr+=individualFollowAsHtml(session,wfRequest,personCache,domain,item) + profileStr+= \ + individualFollowAsHtml(session,wfRequest,personCache, \ + domain,item,authorized,buttons) return profileStr def htmlProfileRoles(nickname: str,domain: str,rolesJson: {}) -> str: @@ -510,12 +513,20 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool, \ htmlProfilePosts(baseDir,httpPrefix,authorized, \ ocapAlways,nickname,domain,port, \ session,wfRequest,personCache) - if selected=='following' or selected=='followers': + if selected=='following': profileStr+= \ htmlProfileFollowing(baseDir,httpPrefix, \ authorized,ocapAlways,nickname, \ domain,port,session, \ - wfRequest,personCache,extraJson) + wfRequest,personCache,extraJson, \ + ["unfollow"]) + if selected=='followers': + profileStr+= \ + htmlProfileFollowing(baseDir,httpPrefix, \ + authorized,ocapAlways,nickname, \ + domain,port,session, \ + wfRequest,personCache,extraJson, \ + ["block"]) if selected=='roles': profileStr+= \ htmlProfileRoles(nickname,domainFull,extraJson) @@ -530,7 +541,9 @@ def htmlProfile(baseDir: str,httpPrefix: str,authorized: bool, \ def individualFollowAsHtml(session,wfRequest: {}, \ personCache: {},domain: str, \ - followUrl: str) -> str: + followUrl: str, \ + authorized: bool, \ + buttons=[]) -> str: nickname=getNicknameFromActor(followUrl) domain,port=getDomainFromActor(followUrl) titleStr='@'+nickname+'@'+domain @@ -542,11 +555,20 @@ def individualFollowAsHtml(session,wfRequest: {}, \ avatarUrl=avatarUrl2 if preferredName: titleStr=preferredName+' '+titleStr + + buttonsStr='' + if authorized: + for b in buttons: + if b=='block': + buttonsStr+='' + if b=='unfollow': + buttonsStr+='' + return \ '
\n' \ '' \ - 'Avatar\n'+ \ - '

'+titleStr+'

'+ \ + '

Avatar\n'+ \ + titleStr+''+buttonsStr+'

' \ '
\n' def contentWarningScript() -> str: