mirror of https://gitlab.com/bashrc2/epicyon
Left column share links to individual post
parent
dcf3dedd2d
commit
46985b4f0d
32
daemon.py
32
daemon.py
|
@ -147,6 +147,7 @@ from webapp_utils import getAvatarImageUrl
|
||||||
from webapp_utils import htmlHashtagBlocked
|
from webapp_utils import htmlHashtagBlocked
|
||||||
from webapp_utils import htmlFollowingList
|
from webapp_utils import htmlFollowingList
|
||||||
from webapp_utils import setBlogAddress
|
from webapp_utils import setBlogAddress
|
||||||
|
from webapp_utils import htmlShowShare
|
||||||
from webapp_calendar import htmlCalendarDeleteConfirm
|
from webapp_calendar import htmlCalendarDeleteConfirm
|
||||||
from webapp_calendar import htmlCalendar
|
from webapp_calendar import htmlCalendar
|
||||||
from webapp_about import htmlAbout
|
from webapp_about import htmlAbout
|
||||||
|
@ -11254,6 +11255,37 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'person options done',
|
'person options done',
|
||||||
'blog post 2 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
|
# remove a shared item
|
||||||
if htmlGET and '?rmshare=' in self.path:
|
if htmlGET and '?rmshare=' in self.path:
|
||||||
itemID = self.path.split('?rmshare=')[1]
|
itemID = self.path.split('?rmshare=')[1]
|
||||||
|
|
|
@ -53,9 +53,9 @@ def _getLeftColumnShares(baseDir: str,
|
||||||
sharedesc = item['displayName']
|
sharedesc = item['displayName']
|
||||||
if '<' in sharedesc or '?' in sharedesc:
|
if '<' in sharedesc or '?' in sharedesc:
|
||||||
continue
|
continue
|
||||||
contactActor = item['actor']
|
shareId = item['shareId']
|
||||||
shareLink = actor + '?replydm=sharedesc:' + \
|
# selecting this link calls htmlShowShare
|
||||||
sharedesc.replace(' ', '_') + '?mention=' + contactActor
|
shareLink = actor + '?showshare=' + shareId
|
||||||
linksList.append(sharedesc + ' ' + shareLink)
|
linksList.append(sharedesc + ' ' + shareLink)
|
||||||
ctr += 1
|
ctr += 1
|
||||||
if ctr >= maxSharesInLeftColumn:
|
if ctr >= maxSharesInLeftColumn:
|
||||||
|
|
|
@ -25,7 +25,6 @@ from utils import firstParagraphFromString
|
||||||
from utils import searchBoxPosts
|
from utils import searchBoxPosts
|
||||||
from utils import getAltPath
|
from utils import getAltPath
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
from utils import isfloat
|
|
||||||
from skills import noOfActorSkills
|
from skills import noOfActorSkills
|
||||||
from skills import getSkillsFromList
|
from skills import getSkillsFromList
|
||||||
from categories import getHashtagCategory
|
from categories import getHashtagCategory
|
||||||
|
@ -36,6 +35,7 @@ from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
from webapp_utils import htmlFooter
|
from webapp_utils import htmlFooter
|
||||||
from webapp_utils import getSearchBannerFile
|
from webapp_utils import getSearchBannerFile
|
||||||
from webapp_utils import htmlPostSeparator
|
from webapp_utils import htmlPostSeparator
|
||||||
|
from webapp_utils import htmlSearchResultShare
|
||||||
from webapp_post import individualPostAsHtml
|
from webapp_post import individualPostAsHtml
|
||||||
from webapp_hashtagswarm import htmlHashTagSwarm
|
from webapp_hashtagswarm import htmlHashTagSwarm
|
||||||
|
|
||||||
|
@ -120,60 +120,6 @@ def _matchSharedItem(searchStrLowerList: [],
|
||||||
return False
|
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 = '<div class="container">\n'
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<p class="share-title">' + sharedItem['displayName'] + '</p>\n'
|
|
||||||
if sharedItem.get('imageUrl'):
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<a href="' + sharedItem['imageUrl'] + '">\n'
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<img loading="lazy" src="' + sharedItem['imageUrl'] + \
|
|
||||||
'" alt="Item image"></a>\n'
|
|
||||||
sharedItemsForm += '<p>' + sharedItem['summary'] + '</p>\n<p>'
|
|
||||||
if sharedItem.get('itemQty'):
|
|
||||||
if sharedItem['itemQty'] > 1:
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<b>' + translate['Quantity'] + \
|
|
||||||
':</b> ' + str(sharedItem['itemQty']) + '<br>'
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<b>' + translate['Type'] + ':</b> ' + sharedItem['itemType'] + '<br>'
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<b>' + translate['Category'] + ':</b> ' + \
|
|
||||||
sharedItem['category'] + '<br>'
|
|
||||||
if sharedItem.get('location'):
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<b>' + translate['Location'] + ':</b> ' + \
|
|
||||||
sharedItem['location'] + '<br>'
|
|
||||||
if sharedItem.get('itemPrice') and \
|
|
||||||
sharedItem.get('itemCurrency'):
|
|
||||||
if isfloat(sharedItem['itemPrice']):
|
|
||||||
if float(sharedItem['itemPrice']) > 0:
|
|
||||||
sharedItemsForm += \
|
|
||||||
' <b>' + translate['Price'] + \
|
|
||||||
':</b> ' + sharedItem['itemPrice'] + \
|
|
||||||
' ' + sharedItem['itemCurrency']
|
|
||||||
sharedItemsForm += '</p>\n'
|
|
||||||
contactActor = \
|
|
||||||
httpPrefix + '://' + domainFull + '/users/' + contactNickname
|
|
||||||
sharedItemsForm += \
|
|
||||||
'<p><a href="' + actor + '?replydm=sharedesc:' + \
|
|
||||||
sharedItem['displayName'] + '?mention=' + contactActor + \
|
|
||||||
'"><button class="button">' + translate['Contact'] + '</button></a>\n'
|
|
||||||
if actor.endswith('/users/' + contactNickname):
|
|
||||||
sharedItemsForm += \
|
|
||||||
' <a href="' + actor + '?rmshare=' + \
|
|
||||||
name + '"><button class="button">' + \
|
|
||||||
translate['Remove'] + '</button></a>\n'
|
|
||||||
sharedItemsForm += '</p></div>\n'
|
|
||||||
return sharedItemsForm
|
|
||||||
|
|
||||||
|
|
||||||
def _htmlSearchResultSharePage(actor: str, domainFull: str,
|
def _htmlSearchResultSharePage(actor: str, domainFull: str,
|
||||||
callingDomain: str, pageNumber: int,
|
callingDomain: str, pageNumber: int,
|
||||||
searchStrLower: str, translate: {},
|
searchStrLower: str, translate: {},
|
||||||
|
@ -227,10 +173,10 @@ def _htmlSharesResult(sharesJson: {}, pageNumber: int, resultsPerPage: int,
|
||||||
if currPage == pageNumber:
|
if currPage == pageNumber:
|
||||||
# show individual search result
|
# show individual search result
|
||||||
sharedItemsForm += \
|
sharedItemsForm += \
|
||||||
_htmlSearchResultShare(sharedItem, translate,
|
htmlSearchResultShare(sharedItem, translate,
|
||||||
httpPrefix, domainFull,
|
httpPrefix, domainFull,
|
||||||
contactNickname,
|
contactNickname,
|
||||||
name, actor)
|
name, actor)
|
||||||
if not resultsExist and currPage > 1:
|
if not resultsExist and currPage > 1:
|
||||||
# show the previous page button
|
# show the previous page button
|
||||||
sharedItemsForm += \
|
sharedItemsForm += \
|
||||||
|
|
119
webapp_utils.py
119
webapp_utils.py
|
@ -18,6 +18,8 @@ from utils import loadJson
|
||||||
from utils import getCachedPostFilename
|
from utils import getCachedPostFilename
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
from utils import getNicknameFromActor
|
||||||
|
from utils import isfloat
|
||||||
from cache import storePersonInCache
|
from cache import storePersonInCache
|
||||||
from content import addHtmlTags
|
from content import addHtmlTags
|
||||||
from content import replaceEmojiFromTags
|
from content import replaceEmojiFromTags
|
||||||
|
@ -1249,3 +1251,120 @@ def editTextArea(label: str, name: str, value: str = "",
|
||||||
text += 'spellcheck="' + str(spellcheck).lower() + '">'
|
text += 'spellcheck="' + str(spellcheck).lower() + '">'
|
||||||
text += value + '</textarea>\n'
|
text += value + '</textarea>\n'
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def htmlSearchResultShare(sharedItem: {}, translate: {},
|
||||||
|
httpPrefix: str, domainFull: str,
|
||||||
|
contactNickname: str, name: str,
|
||||||
|
actor: str) -> str:
|
||||||
|
"""Returns the html for an individual shared item
|
||||||
|
"""
|
||||||
|
sharedItemsForm = '<div class="container">\n'
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<p class="share-title">' + sharedItem['displayName'] + '</p>\n'
|
||||||
|
if sharedItem.get('imageUrl'):
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<a href="' + sharedItem['imageUrl'] + '">\n'
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<img loading="lazy" src="' + sharedItem['imageUrl'] + \
|
||||||
|
'" alt="Item image"></a>\n'
|
||||||
|
sharedItemsForm += '<p>' + sharedItem['summary'] + '</p>\n<p>'
|
||||||
|
if sharedItem.get('itemQty'):
|
||||||
|
if sharedItem['itemQty'] > 1:
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<b>' + translate['Quantity'] + \
|
||||||
|
':</b> ' + str(sharedItem['itemQty']) + '<br>'
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<b>' + translate['Type'] + ':</b> ' + sharedItem['itemType'] + '<br>'
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<b>' + translate['Category'] + ':</b> ' + \
|
||||||
|
sharedItem['category'] + '<br>'
|
||||||
|
if sharedItem.get('location'):
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<b>' + translate['Location'] + ':</b> ' + \
|
||||||
|
sharedItem['location'] + '<br>'
|
||||||
|
if sharedItem.get('itemPrice') and \
|
||||||
|
sharedItem.get('itemCurrency'):
|
||||||
|
if isfloat(sharedItem['itemPrice']):
|
||||||
|
if float(sharedItem['itemPrice']) > 0:
|
||||||
|
sharedItemsForm += \
|
||||||
|
' <b>' + translate['Price'] + \
|
||||||
|
':</b> ' + sharedItem['itemPrice'] + \
|
||||||
|
' ' + sharedItem['itemCurrency']
|
||||||
|
sharedItemsForm += '</p>\n'
|
||||||
|
contactActor = \
|
||||||
|
httpPrefix + '://' + domainFull + '/users/' + contactNickname
|
||||||
|
sharedItemsForm += \
|
||||||
|
'<p><a href="' + actor + '?replydm=sharedesc:' + \
|
||||||
|
sharedItem['displayName'] + '?mention=' + contactActor + \
|
||||||
|
'"><button class="button">' + translate['Contact'] + '</button></a>\n'
|
||||||
|
if actor.endswith('/users/' + contactNickname):
|
||||||
|
sharedItemsForm += \
|
||||||
|
' <a href="' + actor + '?rmshare=' + \
|
||||||
|
name + '"><button class="button">' + \
|
||||||
|
translate['Remove'] + '</button></a>\n'
|
||||||
|
sharedItemsForm += '</p></div>\n'
|
||||||
|
return sharedItemsForm
|
||||||
|
|
||||||
|
|
||||||
|
def htmlShowShare(baseDir: str, domain: str, nickname: str,
|
||||||
|
httpPrefix: str, domainFull: str,
|
||||||
|
itemID: str, translate: {},
|
||||||
|
sharedItemsFederatedDomains: []) -> str:
|
||||||
|
"""Shows an individual shared item after selecting it from the left column
|
||||||
|
"""
|
||||||
|
sharesJson = None
|
||||||
|
|
||||||
|
shareUrl = itemID.replace('___', '://').replace('--', '/')
|
||||||
|
contactNickname = getNicknameFromActor(shareUrl)
|
||||||
|
if not contactNickname:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if '://' + domainFull + '/' in shareUrl:
|
||||||
|
# shared item on this instance
|
||||||
|
sharesFilename = \
|
||||||
|
acctDir(baseDir, contactNickname, domain) + '/shares.json'
|
||||||
|
if not os.path.isfile(sharesFilename):
|
||||||
|
return None
|
||||||
|
sharesJson = loadJson(sharesFilename)
|
||||||
|
else:
|
||||||
|
# federated shared item
|
||||||
|
catalogsDir = baseDir + '/cache/catalogs'
|
||||||
|
if not os.path.isdir(catalogsDir):
|
||||||
|
return None
|
||||||
|
for subdir, dirs, files in os.walk(catalogsDir):
|
||||||
|
for f in files:
|
||||||
|
if '#' in f:
|
||||||
|
continue
|
||||||
|
if not f.endswith('.shares.json'):
|
||||||
|
continue
|
||||||
|
federatedDomain = f.split('.')[0]
|
||||||
|
if federatedDomain not in sharedItemsFederatedDomains:
|
||||||
|
continue
|
||||||
|
sharesFilename = catalogsDir + '/' + f
|
||||||
|
sharesJson = loadJson(sharesFilename)
|
||||||
|
if not sharesJson:
|
||||||
|
continue
|
||||||
|
if sharesJson.get(itemID):
|
||||||
|
break
|
||||||
|
break
|
||||||
|
|
||||||
|
if not sharesJson:
|
||||||
|
return None
|
||||||
|
if not sharesJson.get(itemID):
|
||||||
|
return None
|
||||||
|
sharedItem = sharesJson[itemID]
|
||||||
|
actor = httpPrefix + '://' + domainFull + '/users/' + nickname
|
||||||
|
shareStr = \
|
||||||
|
htmlSearchResultShare(sharedItem, translate, httpPrefix,
|
||||||
|
domainFull, contactNickname, itemID,
|
||||||
|
actor)
|
||||||
|
|
||||||
|
cssFilename = baseDir + '/epicyon-profile.css'
|
||||||
|
if os.path.isfile(baseDir + '/epicyon.css'):
|
||||||
|
cssFilename = baseDir + '/epicyon.css'
|
||||||
|
instanceTitle = \
|
||||||
|
getConfigParam(baseDir, 'instanceTitle')
|
||||||
|
|
||||||
|
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \
|
||||||
|
shareStr + htmlFooter()
|
||||||
|
|
Loading…
Reference in New Issue