Shared item category icons

main
Bob Mottram 2021-09-19 14:59:31 +01:00
parent 418897b7ce
commit 4b63bd9b60
3 changed files with 22 additions and 1 deletions

View File

@ -12587,6 +12587,8 @@ class PubServer(BaseHTTPRequestHandler):
# after selecting a shared item from the left column then show it
if htmlGET and '?showshare=' in self.path and '/users/' in self.path:
itemID = self.path.split('?showshare=')[1]
if ';' in itemID:
itemID = itemID.split(';')[0]
usersPath = self.path.split('?showshare=')[0]
nickname = usersPath.replace('/users/', '')
itemID = urllib.parse.unquote_plus(itemID.strip())

View File

@ -1840,3 +1840,17 @@ def _dfcToSharesFormat(catalogJson: {},
"itemCurrency": item['DFC:price'].split(' ')[1]
}
return sharesJson
def shareCategoryIcon(category: str) -> str:
"""Returns unicode icon for the given category
"""
categoryIcons = {
'accommodation': '🏠',
'clothes': '👚',
'tools': '🔧',
'food': '🍏'
}
if categoryIcons.get(category):
return categoryIcons[category]
return ''

View File

@ -20,6 +20,7 @@ from webapp_utils import headerButtonsFrontScreen
from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
from webapp_utils import getBannerFile
from shares import shareCategoryIcon
def _linksExist(baseDir: str) -> bool:
@ -57,7 +58,11 @@ def _getLeftColumnShares(baseDir: str,
shareId = item['shareId']
# selecting this link calls htmlShowShare
shareLink = actor + '?showshare=' + shareId
linksList.append(sharedesc + ' ' + shareLink)
if item.get('category'):
shareLink += ';category=' + item['category']
shareCategory = shareCategoryIcon(item['category'])
linksList.append(shareCategory + sharedesc + ' ' + shareLink)
ctr += 1
if ctr >= maxSharesInLeftColumn:
break