Happening today button on inbox timeline

main
Bob Mottram 2020-02-22 17:56:34 +00:00
parent 26ebd73b0e
commit 256cc737e4
16 changed files with 90 additions and 15 deletions

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "إزالة المشاركات المجدولة", "Remove scheduled posts": "إزالة المشاركات المجدولة",
"Remove Twitter posts": "إزالة مشاركات Twitter", "Remove Twitter posts": "إزالة مشاركات Twitter",
"Sensitive": "حساس", "Sensitive": "حساس",
"Word Replacements": "استبدال الكلمات" "Word Replacements": "استبدال الكلمات",
"Happening Today": "يحدث اليوم"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Elimineu les publicacions programades", "Remove scheduled posts": "Elimineu les publicacions programades",
"Remove Twitter posts": "Elimina les publicacions de Twitter", "Remove Twitter posts": "Elimina les publicacions de Twitter",
"Sensitive": "Sensible", "Sensitive": "Sensible",
"Word Replacements": "Substitucions de paraula" "Word Replacements": "Substitucions de paraula",
"Happening Today": "Passant avui"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Tynnwch y swyddi a drefnwyd", "Remove scheduled posts": "Tynnwch y swyddi a drefnwyd",
"Remove Twitter posts": "Dileu postiadau Twitter", "Remove Twitter posts": "Dileu postiadau Twitter",
"Sensitive": "Sensitif", "Sensitive": "Sensitif",
"Word Replacements": "Amnewidiadau Geiriau" "Word Replacements": "Amnewidiadau Geiriau",
"Happening Today": "Digwydd Heddiw"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Geplante Posts entfernen", "Remove scheduled posts": "Geplante Posts entfernen",
"Remove Twitter posts": "Entfernen Sie Twitter-Posts", "Remove Twitter posts": "Entfernen Sie Twitter-Posts",
"Sensitive": "Empfindlich", "Sensitive": "Empfindlich",
"Word Replacements": "Wortersetzungen" "Word Replacements": "Wortersetzungen",
"Happening Today": "Heute passiert"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Remove scheduled posts", "Remove scheduled posts": "Remove scheduled posts",
"Remove Twitter posts": "Remove Twitter posts", "Remove Twitter posts": "Remove Twitter posts",
"Sensitive": "Sensitive", "Sensitive": "Sensitive",
"Word Replacements": "Word Replacements" "Word Replacements": "Word Replacements",
"Happening Today": "Happening Today"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Eliminar publicaciones programadas", "Remove scheduled posts": "Eliminar publicaciones programadas",
"Remove Twitter posts": "Eliminar publicaciones de Twitter", "Remove Twitter posts": "Eliminar publicaciones de Twitter",
"Sensitive": "Sensible", "Sensitive": "Sensible",
"Word Replacements": "Reemplazos de palabras" "Word Replacements": "Reemplazos de palabras",
"Happening Today": "Sucediendo hoy"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Supprimer les messages planifiés", "Remove scheduled posts": "Supprimer les messages planifiés",
"Remove Twitter posts": "Supprimer les messages Twitter", "Remove Twitter posts": "Supprimer les messages Twitter",
"Sensitive": "Sensible", "Sensitive": "Sensible",
"Word Replacements": "Remplacements de mots" "Word Replacements": "Remplacements de mots",
"Happening Today": "Se passe aujourd'hui"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Bain na poist sceidealta", "Remove scheduled posts": "Bain na poist sceidealta",
"Remove Twitter posts": "Bain poist Twitter", "Remove Twitter posts": "Bain poist Twitter",
"Sensitive": "Íogair", "Sensitive": "Íogair",
"Word Replacements": "Athchur Focal" "Word Replacements": "Athchur Focal",
"Happening Today": "Ag tarlú inniu"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "अनुसूचित पदों को हटा दें", "Remove scheduled posts": "अनुसूचित पदों को हटा दें",
"Remove Twitter posts": "ट्विटर पोस्ट हटाएं", "Remove Twitter posts": "ट्विटर पोस्ट हटाएं",
"Sensitive": "संवेदनशील", "Sensitive": "संवेदनशील",
"Word Replacements": "शब्द प्रतिस्थापन" "Word Replacements": "शब्द प्रतिस्थापन",
"Happening Today": "आज हो रहा है"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Rimuovi i post programmati", "Remove scheduled posts": "Rimuovi i post programmati",
"Remove Twitter posts": "Rimuovi i post di Twitter", "Remove Twitter posts": "Rimuovi i post di Twitter",
"Sensitive": "Sensibile", "Sensitive": "Sensibile",
"Word Replacements": "Sostituzioni di parole" "Word Replacements": "Sostituzioni di parole",
"Happening Today": "Succede oggi"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "スケジュールされた投稿を削除する", "Remove scheduled posts": "スケジュールされた投稿を削除する",
"Remove Twitter posts": "Twitterの投稿を削除する", "Remove Twitter posts": "Twitterの投稿を削除する",
"Sensitive": "敏感", "Sensitive": "敏感",
"Word Replacements": "単語の置換" "Word Replacements": "単語の置換",
"Happening Today": "今日の出来事"
} }

View File

@ -205,5 +205,6 @@
"Remove scheduled posts": "Remove scheduled posts", "Remove scheduled posts": "Remove scheduled posts",
"Remove Twitter posts": "Remove Twitter posts", "Remove Twitter posts": "Remove Twitter posts",
"Sensitive": "Sensitive", "Sensitive": "Sensitive",
"Word Replacements": "Word Replacements" "Word Replacements": "Word Replacements",
"Happening Today": "Happening Today"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Remover postagens agendadas", "Remove scheduled posts": "Remover postagens agendadas",
"Remove Twitter posts": "Remover postagens do Twitter", "Remove Twitter posts": "Remover postagens do Twitter",
"Sensitive": "Sensível", "Sensitive": "Sensível",
"Word Replacements": "Substituições do Word" "Word Replacements": "Substituições do Word",
"Happening Today": "Acontecendo hoje"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "Удалить запланированные сообщения", "Remove scheduled posts": "Удалить запланированные сообщения",
"Remove Twitter posts": "Удалить сообщения из Твиттера", "Remove Twitter posts": "Удалить сообщения из Твиттера",
"Sensitive": "чувствительный", "Sensitive": "чувствительный",
"Word Replacements": "Замены слов" "Word Replacements": "Замены слов",
"Happening Today": "Происходит сегодня"
} }

View File

@ -209,5 +209,6 @@
"Remove scheduled posts": "删除预定的帖子", "Remove scheduled posts": "删除预定的帖子",
"Remove Twitter posts": "删除Twitter帖子", "Remove Twitter posts": "删除Twitter帖子",
"Sensitive": "敏感", "Sensitive": "敏感",
"Word Replacements": "单词替换" "Word Replacements": "单词替换",
"Happening Today": "今天发生"
} }

View File

@ -2960,6 +2960,11 @@ def htmlTimeline(defaultTimeline: str, \
# add the javascript for content warnings # add the javascript for content warnings
tlStr+='<script>'+contentWarningScript()+'</script>' tlStr+='<script>'+contentWarningScript()+'</script>'
# show todays events button
if boxName=='inbox':
if todaysEventsCheck(baseDir,nickname,domain):
tlStr+='<center><a href="'+actor+'/todaysevents"><button class="button">'+translate['Happening Today']+'</button></a></center>'
# page up arrow # page up arrow
if pageNumber>1: if pageNumber>1:
tlStr+='<center><a href="'+actor+'/'+boxName+'?page='+str(pageNumber-1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pageup.png" title="'+translate['Page up']+'" alt="'+translate['Page up']+'"></a></center>' tlStr+='<center><a href="'+actor+'/'+boxName+'?page='+str(pageNumber-1)+'"><img loading="lazy" class="pageicon" src="/'+iconsDir+'/pageup.png" title="'+translate['Page up']+'" alt="'+translate['Page up']+'"></a></center>'
@ -3752,6 +3757,61 @@ def getTodaysEvents(baseDir: str,nickname: str,domain: str, \
return events return events
def todaysEventsCheck(baseDir: str,nickname: str,domain: str) -> bool:
"""Are there calendar events today?
"""
now=datetime.now()
if not currYear:
year=now.year
else:
year=currYear
if not currMonthNumber:
monthNumber=now.month
else:
monthNumber=currMonthNumber
if not currDayOfMonth:
dayNumber=now.day
else:
dayNumber=currDayOfMonth
calendarFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/calendar/'+str(year)+'/'+str(monthNumber)+'.txt'
if not os.path.isfile(calendarFilename):
return False
eventsExist=False
with open(calendarFilename,'r') as eventsFile:
for postId in eventsFile:
postId=postId.replace('\n','')
postFilename=locatePost(baseDir,nickname,domain,postId)
if postFilename:
postJsonObject=loadJson(postFilename)
if not postJsonObject:
continue
if not postJsonObject.get('object'):
continue
if not isinstance(postJsonObject['object'], dict):
continue
if not postJsonObject['object'].get('tag'):
continue
for tag in postJsonObject['object']['tag']:
if not tag.get('type'):
continue
if tag['type']!='Event' and tag['type']!='Place':
continue
if tag['type']=='Event':
# tag is an event
if not tag.get('startTime'):
continue
eventTime= \
datetime.strptime(tag['startTime'], \
"%Y-%m-%dT%H:%M:%S%z")
if int(eventTime.strftime("%Y"))==year and \
int(eventTime.strftime("%m"))==monthNumber and \
int(eventTime.strftime("%d"))==dayNumber:
eventsExist=True
break
return eventsExist
def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}: def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}:
"""Retrieves calendar events for this week """Retrieves calendar events for this week
Returns a dictionary indexed by day number of lists containing Event and Place activities Returns a dictionary indexed by day number of lists containing Event and Place activities