\n' + \
+ ' \n' + \
+ ' ' + \
+ instanceTitle + ' inbox\n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
+ ' \n' + \
+ ' ' + content + '\n' + \
+ ' \n' + \
+ ' \n' + \
+ '
\n' + \
+ '\n'
+
+
+def getSSMLbox(baseDir: str, path: str,
+ domain: str,
+ systemLanguage: str,
+ instanceTitle: str,
+ boxName: str) -> str:
+ """Returns SSML for the given timeline
+ """
+ nickname = path.split('/users/')[1]
+ if '/' in nickname:
+ nickname = nickname.split('/')[0]
+ speakerFilename = \
+ baseDir + '/accounts/' + nickname + '@' + domain + '/speaker.json'
+ if not os.path.isfile(speakerFilename):
+ return None
+ speakerJson = loadJson(speakerFilename)
+ if not speakerJson:
+ return None
+ gender = None
+ if speakerJson.get('gender'):
+ gender = speakerJson['gender']
+ return _speakerEndpointSSML(speakerJson['name'],
+ speakerJson['summary'],
+ speakerJson['say'],
+ speakerJson['imageDescription'],
+ speakerJson['detectedLinks'],
+ systemLanguage,
+ instanceTitle, gender)
diff --git a/theme.py b/theme.py
index de444a90f..3a8d9c897 100644
--- a/theme.py
+++ b/theme.py
@@ -68,8 +68,9 @@ def _copyThemeHelpFiles(baseDir: str, themeName: str,
if destHelpMarkdownFile == 'profile.md' or \
destHelpMarkdownFile == 'final.md':
destHelpMarkdownFile = 'welcome_' + destHelpMarkdownFile
- copyfile(themeDir + '/' + helpMarkdownFile,
- baseDir + '/accounts/' + destHelpMarkdownFile)
+ if os.path.isdir(baseDir + '/accounts'):
+ copyfile(themeDir + '/' + helpMarkdownFile,
+ baseDir + '/accounts/' + destHelpMarkdownFile)
break
@@ -659,6 +660,8 @@ def _setClearCacheFlag(baseDir: str) -> None:
"""Sets a flag which can be used by an external system
(eg. a script in a cron job) to clear the browser cache
"""
+ if not os.path.isdir(baseDir + '/accounts'):
+ return
flagFilename = baseDir + '/accounts/.clear_cache'
with open(flagFilename, 'w+') as flagFile:
flagFile.write('\n')
diff --git a/translations/ar.json b/translations/ar.json
index 54f4adbac..0027e6346 100644
--- a/translations/ar.json
+++ b/translations/ar.json
@@ -381,5 +381,8 @@
"mentioning": "ذكر",
"sad face": "وجه حزين",
"thinking emoji": "التفكير الرموز التعبيرية",
- "laughing": "يضحك"
+ "laughing": "يضحك",
+ "gender": "جنس تذكير أو تأنيث",
+ "He/Him": "هو",
+ "She/Her": "هي"
}
diff --git a/translations/ca.json b/translations/ca.json
index 5112f57ab..5ad1772f0 100644
--- a/translations/ca.json
+++ b/translations/ca.json
@@ -381,5 +381,8 @@
"mentioning": "esmentant",
"sad face": "cara trista",
"thinking emoji": "emoji pensant",
- "laughing": "rient"
+ "laughing": "rient",
+ "gender": "gènere",
+ "He/Him": "Ell",
+ "She/Her": "Ella"
}
diff --git a/translations/cy.json b/translations/cy.json
index 8decbe17b..c8c2dfff5 100644
--- a/translations/cy.json
+++ b/translations/cy.json
@@ -381,5 +381,8 @@
"mentioning": "sôn",
"sad face": "wyneb trist",
"thinking emoji": "meddwl emoji",
- "laughing": "chwerthin"
+ "laughing": "chwerthin",
+ "gender": "rhyw",
+ "He/Him": "Ef",
+ "She/Her": "Hi/Ei"
}
diff --git a/translations/de.json b/translations/de.json
index 46bb450d8..aef2f428a 100644
--- a/translations/de.json
+++ b/translations/de.json
@@ -381,5 +381,8 @@
"mentioning": "Erwähnen",
"sad face": "trauriges Gesicht",
"thinking emoji": "Emowji denken",
- "laughing": "Lachen"
+ "laughing": "Lachen",
+ "gender": "geschlecht",
+ "He/Him": "Er/ihm",
+ "She/Her": "Sie"
}
diff --git a/translations/en.json b/translations/en.json
index 47997a169..eb8743f40 100644
--- a/translations/en.json
+++ b/translations/en.json
@@ -381,5 +381,8 @@
"mentioning": "mentioning",
"sad face": "sad face",
"thinking emoji": "thinking emowji",
- "laughing": "laughing"
+ "laughing": "laughing",
+ "gender": "gender",
+ "He/Him": "He/Him",
+ "She/Her": "She/Her"
}
diff --git a/translations/es.json b/translations/es.json
index bb12926f7..10c2729ea 100644
--- a/translations/es.json
+++ b/translations/es.json
@@ -381,5 +381,8 @@
"mentioning": "mencionar",
"sad face": "cara triste",
"thinking emoji": "pensando emowji",
- "laughing": "risa"
+ "laughing": "risa",
+ "gender": "género",
+ "He/Him": "El",
+ "She/Her": "Ella"
}
diff --git a/translations/fr.json b/translations/fr.json
index 84cd8b145..f959f284e 100644
--- a/translations/fr.json
+++ b/translations/fr.json
@@ -381,5 +381,8 @@
"mentioning": "mentionnant",
"sad face": "visage triste",
"thinking emoji": "penser emowji",
- "laughing": "en riant"
+ "laughing": "en riant",
+ "gender": "le genre",
+ "He/Him": "Il/Lui",
+ "She/Her": "Elle"
}
diff --git a/translations/ga.json b/translations/ga.json
index 123ef8c52..315448826 100644
--- a/translations/ga.json
+++ b/translations/ga.json
@@ -381,5 +381,8 @@
"mentioning": "ag lua",
"sad face": "aghaidh brónach",
"thinking emoji": "ag smaoineamh emowji",
- "laughing": "ag gáire"
+ "laughing": "ag gáire",
+ "gender": "inscne",
+ "He/Him": "Sé/Eisean",
+ "She/Her": "Sí"
}
diff --git a/translations/hi.json b/translations/hi.json
index ecb575420..f7ed05f0d 100644
--- a/translations/hi.json
+++ b/translations/hi.json
@@ -381,5 +381,8 @@
"mentioning": "उल्लेख",
"sad face": "उदास चेहरा",
"thinking emoji": "सोच रहे हैं इमोजी",
- "laughing": "हस रहा"
+ "laughing": "हस रहा",
+ "gender": "लिंग",
+ "He/Him": "वह/उसे",
+ "She/Her": "वह/उसकी"
}
diff --git a/translations/it.json b/translations/it.json
index e5a999fe6..52bb3e58f 100644
--- a/translations/it.json
+++ b/translations/it.json
@@ -381,5 +381,8 @@
"mentioning": "menzionando",
"sad face": "faccia triste",
"thinking emoji": "pensiero emoji",
- "laughing": "ridendo"
+ "laughing": "ridendo",
+ "gender": "genere",
+ "He/Him": "Lui",
+ "She/Her": "Lei"
}
diff --git a/translations/ja.json b/translations/ja.json
index efdc45a58..967673668 100644
--- a/translations/ja.json
+++ b/translations/ja.json
@@ -381,5 +381,8 @@
"mentioning": "言及する",
"sad face": "悲しい顔",
"thinking emoji": "絵文字を考える",
- "laughing": "笑い"
+ "laughing": "笑い",
+ "gender": "性別",
+ "He/Him": "彼",
+ "She/Her": "彼女"
}
diff --git a/translations/oc.json b/translations/oc.json
index 522ac2cdf..3d008db27 100644
--- a/translations/oc.json
+++ b/translations/oc.json
@@ -377,5 +377,8 @@
"mentioning": "mentioning",
"sad face": "sad face",
"thinking emoji": "thinking emowji",
- "laughing": "laughing"
+ "laughing": "laughing",
+ "gender": "gender",
+ "He/Him": "He/Him",
+ "She/Her": "She/Her"
}
diff --git a/translations/pt.json b/translations/pt.json
index 42414a9fc..e62387eec 100644
--- a/translations/pt.json
+++ b/translations/pt.json
@@ -381,5 +381,8 @@
"mentioning": "mencionando",
"sad face": "rosto triste",
"thinking emoji": "pensando emowji",
- "laughing": "rindo"
+ "laughing": "rindo",
+ "gender": "gênero",
+ "He/Him": "Ele",
+ "She/Her": "Ela"
}
diff --git a/translations/ru.json b/translations/ru.json
index a9e14625f..806da91da 100644
--- a/translations/ru.json
+++ b/translations/ru.json
@@ -381,5 +381,8 @@
"mentioning": "упоминание",
"sad face": "грустное лицо",
"thinking emoji": "думающий смайлик",
- "laughing": "смеющийся"
+ "laughing": "смеющийся",
+ "gender": "Пол",
+ "He/Him": "Он/Его",
+ "She/Her": "Она/Ее"
}
diff --git a/translations/zh.json b/translations/zh.json
index d7af314c0..5f149d144 100644
--- a/translations/zh.json
+++ b/translations/zh.json
@@ -381,5 +381,8 @@
"mentioning": "提及",
"sad face": "悲伤的脸",
"thinking emoji": "思维表情符号",
- "laughing": "笑"
+ "laughing": "笑",
+ "gender": "",
+ "He/Him": "",
+ "She/Her": ""
}
diff --git a/utils.py b/utils.py
index b0594c7ae..9ccef742a 100644
--- a/utils.py
+++ b/utils.py
@@ -669,6 +669,74 @@ def getDisplayName(baseDir: str, actor: str, personCache: {}) -> str:
return nameFound
+def getGenderFromBio(baseDir: str, actor: str, personCache: {},
+ translate: {}) -> str:
+ """Tries to ascertain gender from bio description
+ """
+ if '/statuses/' in actor:
+ actor = actor.split('/statuses/')[0]
+ if not personCache.get(actor):
+ return None
+ bioFound = None
+ if personCache[actor].get('actor'):
+ # is gender defined as a profile tag?
+ if personCache[actor]['actor'].get('attachment'):
+ tagsList = personCache[actor]['actor']['attachment']
+ if isinstance(tagsList, list):
+ for tag in tagsList:
+ if not isinstance(tag, dict):
+ continue
+ if not tag.get('name') or not tag.get('value'):
+ continue
+ if tag['name'].lower() == \
+ translate['gender'].lower():
+ bioFound = tag['value']
+ break
+ # if not then use the bio
+ if not bioFound and personCache[actor]['actor'].get('summary'):
+ bioFound = personCache[actor]['actor']['summary']
+ else:
+ # Try to obtain from the cached actors
+ cachedActorFilename = \
+ baseDir + '/cache/actors/' + (actor.replace('/', '#')) + '.json'
+ if os.path.isfile(cachedActorFilename):
+ actorJson = loadJson(cachedActorFilename, 1)
+ if actorJson:
+ # is gender defined as a profile tag?
+ if actorJson.get('attachment'):
+ tagsList = actorJson['attachment']
+ if isinstance(tagsList, list):
+ for tag in tagsList:
+ if not isinstance(tag, dict):
+ continue
+ if not tag.get('name') or not tag.get('value'):
+ continue
+ if tag['name'].lower() == \
+ translate['gender'].lower():
+ bioFound = tag['value']
+ break
+ # if not then use the bio
+ if not bioFound and actorJson.get('summary'):
+ bioFound = actorJson['summary']
+ if not bioFound:
+ return None
+ gender = 'They/Them'
+ bioFoundOrig = bioFound
+ bioFound = bioFound.lower()
+ if translate['He/Him'] in bioFound:
+ gender = 'He/Him'
+ elif translate['She/Her'] in bioFound:
+ gender = 'She/Her'
+ elif 'him' in bioFound or 'male' in bioFound:
+ gender = 'He/Him'
+ elif 'her' in bioFound or 'she' in bioFound or \
+ 'fem' in bioFound or 'woman' in bioFound:
+ gender = 'She/Her'
+ elif 'man' in bioFound or 'He' in bioFoundOrig:
+ gender = 'He/Him'
+ return gender
+
+
def getNicknameFromActor(actor: str) -> str:
"""Returns the nickname from an actor url
"""