From 4b63bd9b603f2d3ddc7941e6ae37b9aa8ebbac01 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 19 Sep 2021 14:59:31 +0100 Subject: [PATCH] Shared item category icons --- daemon.py | 2 ++ shares.py | 14 ++++++++++++++ webapp_column_left.py | 7 ++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index 56b7669d9..07a33e571 100644 --- a/daemon.py +++ b/daemon.py @@ -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()) diff --git a/shares.py b/shares.py index 7fddad6a9..947427361 100644 --- a/shares.py +++ b/shares.py @@ -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 '' diff --git a/webapp_column_left.py b/webapp_column_left.py index f6068e7d0..79e710476 100644 --- a/webapp_column_left.py +++ b/webapp_column_left.py @@ -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