diff --git a/webapp_search.py b/webapp_search.py index d9d822ea5..f7b87c1d8 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -119,6 +119,56 @@ 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 = '
\n' + sharedItemsForm += \ + '

' + sharedItem['displayName'] + '

\n' + if sharedItem.get('imageUrl'): + sharedItemsForm += \ + '\n' + sharedItemsForm += \ + 'Item image\n' + sharedItemsForm += '

' + sharedItem['summary'] + '

\n

' + if sharedItem.get('itemQty'): + sharedItemsForm += \ + '' + translate['Quantity'] + \ + ': ' + str(sharedItem['itemQty']) + ' ' + sharedItemsForm += \ + '' + translate['Type'] + ': ' + sharedItem['itemType'] + ' ' + sharedItemsForm += \ + '' + translate['Category'] + ': ' + sharedItem['category'] + ' ' + 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' + contactActor = \ + httpPrefix + '://' + domainFull + '/users/' + contactNickname + sharedItemsForm += \ + '

\n' + if actor.endswith('/users/' + contactNickname): + sharedItemsForm += \ + ' \n' + sharedItemsForm += '

\n' + return sharedItemsForm + + def htmlSearchSharedItems(cssCache: {}, translate: {}, baseDir: str, searchStr: str, pageNumber: int, @@ -165,58 +215,11 @@ def htmlSearchSharedItems(cssCache: {}, translate: {}, for name, sharedItem in sharesJson.items(): if _matchSharedItem(searchStrLowerList, sharedItem): if currPage == pageNumber: - sharedItemsForm += '
\n' sharedItemsForm += \ - '

' + \ - sharedItem['displayName'] + '

\n' - if sharedItem.get('imageUrl'): - sharedItemsForm += \ - '\n' - sharedItemsForm += \ - 'Item image\n' - sharedItemsForm += \ - '

' + sharedItem['summary'] + '

\n

' - if sharedItem.get('itemQty'): - sharedItemsForm += \ - '' + translate['Quantity'] + \ - ': ' + str(sharedItem['itemQty']) + ' ' - sharedItemsForm += \ - '' + translate['Type'] + \ - ': ' + sharedItem['itemType'] + ' ' - sharedItemsForm += \ - '' + translate['Category'] + \ - ': ' + sharedItem['category'] + ' ' - 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' - contactActor = \ - httpPrefix + '://' + domainFull + \ - '/users/' + contactNickname - sharedItemsForm += \ - '

\n' - if actor.endswith('/users/' + contactNickname): - sharedItemsForm += \ - ' \n' - sharedItemsForm += '

\n' + _htmlSearchResultShare(sharedItem, translate, + httpPrefix, domainFull, + contactNickname, + name, actor) if not resultsExist and currPage > 1: postActor = \ getAltPath(actor, domainFull,