Open link using post index

merge-requests/30/head
Bob Mottram 2021-03-15 15:14:54 +00:00
parent b6795e8325
commit e41f6c1456
1 changed files with 27 additions and 7 deletions

View File

@ -297,11 +297,8 @@ def _notificationNewPost(session,
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak) _sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
def _readLocalBoxPost(boxName: str, index: int, def _getSpeakerJsonFromIndex(boxName: str, index: int) -> {}:
systemLanguage: str, """Returns the json for the given post index
screenreader: str, espeak) -> {}:
"""Reads a post from the given timeline
Returns the speaker json
""" """
homeDir = str(Path.home()) homeDir = str(Path.home())
if not os.path.isdir(homeDir + '/.config'): if not os.path.isdir(homeDir + '/.config'):
@ -332,7 +329,18 @@ def _readLocalBoxPost(boxName: str, index: int,
publishedYear + '/' + publishedYear + '/' +
publishedMonth + '/' + publishedMonth + '/' +
indexList[index]) indexList[index])
speakerJson = loadJson(speakerJsonFilename) return loadJson(speakerJsonFilename)
def _readLocalBoxPost(boxName: str, index: int,
systemLanguage: str,
screenreader: str, espeak) -> {}:
"""Reads a post from the given timeline
Returns the speaker json
"""
speakerJson = _getSpeakerJsonFromIndex(boxName, index)
if not speakerJson:
return
nameStr = speakerJson['name'] nameStr = speakerJson['name']
gender = 'They/Them' gender = 'They/Them'
@ -1142,7 +1150,19 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
else: else:
print('No --screenreader option was specified') print('No --screenreader option was specified')
elif keyPress.startswith('open'): elif keyPress.startswith('open'):
currIndex = currInboxIndex
if currTimeline == 'dm':
currIndex = currDMIndex
elif currTimeline == 'sent':
currIndex = currSentIndex
speakerJson = \
_getSpeakerJsonFromIndex(currTimeline, currIndex)
if speakerJson.get('detectedLinks'): if speakerJson.get('detectedLinks'):
if ' ' in keyPress:
index = keyPress.split(' ')[1]
if index.isdigit():
speakerJson = \
_getSpeakerJsonFromIndex(currTimeline, index)
sayStr = 'Opening web links in browser.' sayStr = 'Opening web links in browser.'
_sayCommand(sayStr, sayStr, originalScreenReader, _sayCommand(sayStr, sayStr, originalScreenReader,
systemLanguage, espeak) systemLanguage, espeak)