diff --git a/daemon.py b/daemon.py index f42c15bec..38569277f 100644 --- a/daemon.py +++ b/daemon.py @@ -147,6 +147,7 @@ from webapp_utils import getAvatarImageUrl from webapp_utils import htmlHashtagBlocked from webapp_utils import htmlFollowingList from webapp_utils import setBlogAddress +from webapp_utils import htmlShowShare from webapp_calendar import htmlCalendarDeleteConfirm from webapp_calendar import htmlCalendar from webapp_about import htmlAbout @@ -11254,6 +11255,37 @@ class PubServer(BaseHTTPRequestHandler): 'person options done', 'blog post 2 done') + # after selecting a shared item from the left column then show it + if htmlGET and '?showshare=' in self.path: + itemID = self.path.split('?showshare=')[1] + usersPath = self.path.split('?showshare=')[0] + itemID = urllib.parse.unquote_plus(itemID.strip()) + msg = \ + htmlShowShare(self.server.baseDir, + self.server.domain, self.server.nickname, + self.server.httpPrefix, self.server.domainFull, + itemID, self.server.translate, + self.server.sharedItemsFederatedDomains) + if not msg: + if callingDomain.endswith('.onion') and \ + self.server.onionDomain: + actor = 'http://' + self.server.onionDomain + usersPath + elif (callingDomain.endswith('.i2p') and + self.server.i2pDomain): + actor = 'http://' + self.server.i2pDomain + usersPath + self._redirect_headers(actor + '/tlshares', + cookie, callingDomain) + return + msg = msg.encode('utf-8') + msglen = len(msg) + self._set_headers('text/html', msglen, + cookie, callingDomain) + self._write(msg) + self._benchmarkGETtimings(GETstartTime, GETtimings, + 'blog post 2 done', + 'htmlShowShare') + return + # remove a shared item if htmlGET and '?rmshare=' in self.path: itemID = self.path.split('?rmshare=')[1] diff --git a/webapp_column_left.py b/webapp_column_left.py index f804cfc4e..b13bf03a2 100644 --- a/webapp_column_left.py +++ b/webapp_column_left.py @@ -53,9 +53,9 @@ def _getLeftColumnShares(baseDir: str, sharedesc = item['displayName'] if '<' in sharedesc or '?' in sharedesc: continue - contactActor = item['actor'] - shareLink = actor + '?replydm=sharedesc:' + \ - sharedesc.replace(' ', '_') + '?mention=' + contactActor + shareId = item['shareId'] + # selecting this link calls htmlShowShare + shareLink = actor + '?showshare=' + shareId linksList.append(sharedesc + ' ' + shareLink) ctr += 1 if ctr >= maxSharesInLeftColumn: diff --git a/webapp_search.py b/webapp_search.py index aec4f78ba..31d03f1af 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -25,7 +25,6 @@ from utils import firstParagraphFromString from utils import searchBoxPosts from utils import getAltPath from utils import acctDir -from utils import isfloat from skills import noOfActorSkills from skills import getSkillsFromList from categories import getHashtagCategory @@ -36,6 +35,7 @@ from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlFooter from webapp_utils import getSearchBannerFile from webapp_utils import htmlPostSeparator +from webapp_utils import htmlSearchResultShare from webapp_post import individualPostAsHtml from webapp_hashtagswarm import htmlHashTagSwarm @@ -120,60 +120,6 @@ def _matchSharedItem(searchStrLowerList: [], return False -def _htmlSearchResultShare(sharedItem: {}, translate: {}, - httpPrefix: str, domainFull: str, - contactNickname: str, name: str, - actor: str) -> str: - """Returns the html for an individual shared item - """ - sharedItemsForm = '
' + sharedItem['summary'] + '
\n'
- if sharedItem.get('itemQty'):
- if sharedItem['itemQty'] > 1:
- sharedItemsForm += \
- '' + translate['Quantity'] + \
- ': ' + str(sharedItem['itemQty']) + '
'
- sharedItemsForm += \
- '' + translate['Type'] + ': ' + sharedItem['itemType'] + '
'
- sharedItemsForm += \
- '' + translate['Category'] + ': ' + \
- sharedItem['category'] + '
'
- if sharedItem.get('location'):
- sharedItemsForm += \
- '' + translate['Location'] + ': ' + \
- sharedItem['location'] + '
'
- if sharedItem.get('itemPrice') and \
- sharedItem.get('itemCurrency'):
- if isfloat(sharedItem['itemPrice']):
- if float(sharedItem['itemPrice']) > 0:
- sharedItemsForm += \
- ' ' + translate['Price'] + \
- ': ' + sharedItem['itemPrice'] + \
- ' ' + sharedItem['itemCurrency']
- sharedItemsForm += '
\n' - if actor.endswith('/users/' + contactNickname): - sharedItemsForm += \ - ' \n' - sharedItemsForm += '
' + sharedItem['summary'] + '
\n'
+ if sharedItem.get('itemQty'):
+ if sharedItem['itemQty'] > 1:
+ sharedItemsForm += \
+ '' + translate['Quantity'] + \
+ ': ' + str(sharedItem['itemQty']) + '
'
+ sharedItemsForm += \
+ '' + translate['Type'] + ': ' + sharedItem['itemType'] + '
'
+ sharedItemsForm += \
+ '' + translate['Category'] + ': ' + \
+ sharedItem['category'] + '
'
+ if sharedItem.get('location'):
+ sharedItemsForm += \
+ '' + translate['Location'] + ': ' + \
+ sharedItem['location'] + '
'
+ if sharedItem.get('itemPrice') and \
+ sharedItem.get('itemCurrency'):
+ if isfloat(sharedItem['itemPrice']):
+ if float(sharedItem['itemPrice']) > 0:
+ sharedItemsForm += \
+ ' ' + translate['Price'] + \
+ ': ' + sharedItem['itemPrice'] + \
+ ' ' + sharedItem['itemCurrency']
+ sharedItemsForm += '
\n' + if actor.endswith('/users/' + contactNickname): + sharedItemsForm += \ + ' \n' + sharedItemsForm += '