From 37cb1680bb9f1ad57e3dfb14cdccd3abfbb0b6a1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 22 Feb 2020 18:32:12 +0000 Subject: [PATCH] Happening this week button --- translations/ar.json | 3 ++- translations/ca.json | 3 ++- translations/cy.json | 3 ++- translations/de.json | 3 ++- translations/en.json | 3 ++- translations/es.json | 3 ++- translations/fr.json | 3 ++- translations/ga.json | 3 ++- translations/hi.json | 3 ++- translations/it.json | 3 ++- translations/ja.json | 3 ++- translations/oc.json | 3 ++- translations/pt.json | 3 ++- translations/ru.json | 3 ++- translations/zh.json | 3 ++- webinterface.py | 53 ++++++++++++++++++++++++++++++++++++++++++++ 16 files changed, 83 insertions(+), 15 deletions(-) diff --git a/translations/ar.json b/translations/ar.json index 83d909f8..25c17ae6 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "إزالة مشاركات Twitter", "Sensitive": "حساس", "Word Replacements": "استبدال الكلمات", - "Happening Today": "يحدث اليوم" + "Happening Today": "يحدث اليوم", + "Happening This Week": "يحدث هذا الاسبوع" } diff --git a/translations/ca.json b/translations/ca.json index c41a7643..502b13ff 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Elimina les publicacions de Twitter", "Sensitive": "Sensible", "Word Replacements": "Substitucions de paraula", - "Happening Today": "Passant avui" + "Happening Today": "Passant avui", + "Happening This Week": "Passa aquesta setmana" } diff --git a/translations/cy.json b/translations/cy.json index 7d492fd8..cdc3c40e 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Dileu postiadau Twitter", "Sensitive": "Sensitif", "Word Replacements": "Amnewidiadau Geiriau", - "Happening Today": "Digwydd Heddiw" + "Happening Today": "Digwydd Heddiw", + "Happening This Week": "Yn Digwydd Yr Wythnos Hon" } diff --git a/translations/de.json b/translations/de.json index 792a8eab..554594ed 100644 --- a/translations/de.json +++ b/translations/de.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Entfernen Sie Twitter-Posts", "Sensitive": "Empfindlich", "Word Replacements": "Wortersetzungen", - "Happening Today": "Heute passiert" + "Happening Today": "Heute passiert", + "Happening This Week": "Diese Woche passiert" } diff --git a/translations/en.json b/translations/en.json index 863a4fd8..029f6e5a 100644 --- a/translations/en.json +++ b/translations/en.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Remove Twitter posts", "Sensitive": "Sensitive", "Word Replacements": "Word Replacements", - "Happening Today": "Happening Today" + "Happening Today": "Happening Today", + "Happening This Week": "Happening This Week" } diff --git a/translations/es.json b/translations/es.json index e936d6c8..bcb68b6e 100644 --- a/translations/es.json +++ b/translations/es.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Eliminar publicaciones de Twitter", "Sensitive": "Sensible", "Word Replacements": "Reemplazos de palabras", - "Happening Today": "Sucediendo hoy" + "Happening Today": "Sucediendo hoy", + "Happening This Week": "Sucediendo esta semana" } diff --git a/translations/fr.json b/translations/fr.json index bf25dd4e..7605cbd6 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Supprimer les messages Twitter", "Sensitive": "Sensible", "Word Replacements": "Remplacements de mots", - "Happening Today": "Se passe aujourd'hui" + "Happening Today": "Se passe aujourd'hui", + "Happening This Week": "Se passe cette semaine" } diff --git a/translations/ga.json b/translations/ga.json index e3da6d27..f1bc80b2 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Bain poist Twitter", "Sensitive": "Íogair", "Word Replacements": "Athchur Focal", - "Happening Today": "Ag tarlú inniu" + "Happening Today": "Ag tarlú inniu", + "Happening This Week": "Ag tarlú an tseachtain seo" } diff --git a/translations/hi.json b/translations/hi.json index 8fcef6bf..84537ccf 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "ट्विटर पोस्ट हटाएं", "Sensitive": "संवेदनशील", "Word Replacements": "शब्द प्रतिस्थापन", - "Happening Today": "आज हो रहा है" + "Happening Today": "आज हो रहा है", + "Happening This Week": "इस सप्ताह हो रहा है" } diff --git a/translations/it.json b/translations/it.json index 9b8bf702..26d0c5d5 100644 --- a/translations/it.json +++ b/translations/it.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Rimuovi i post di Twitter", "Sensitive": "Sensibile", "Word Replacements": "Sostituzioni di parole", - "Happening Today": "Succede oggi" + "Happening Today": "Succede oggi", + "Happening This Week": "Succede questa settimana" } diff --git a/translations/ja.json b/translations/ja.json index 617cf782..d44ae936 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Twitterの投稿を削除する", "Sensitive": "敏感", "Word Replacements": "単語の置換", - "Happening Today": "今日の出来事" + "Happening Today": "今日の出来事", + "Happening This Week": "今週の出来事" } diff --git a/translations/oc.json b/translations/oc.json index e22c79ed..39b8dc9a 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -206,5 +206,6 @@ "Remove Twitter posts": "Remove Twitter posts", "Sensitive": "Sensitive", "Word Replacements": "Word Replacements", - "Happening Today": "Happening Today" + "Happening Today": "Happening Today", + "Happening This Week": "Happening This Week" } diff --git a/translations/pt.json b/translations/pt.json index 0f97c66f..6e3544c1 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Remover postagens do Twitter", "Sensitive": "Sensível", "Word Replacements": "Substituições do Word", - "Happening Today": "Acontecendo hoje" + "Happening Today": "Acontecendo hoje", + "Happening This Week": "Acontecendo Esta Semana" } diff --git a/translations/ru.json b/translations/ru.json index 1f4aa320..b3d389bb 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "Удалить сообщения из Твиттера", "Sensitive": "чувствительный", "Word Replacements": "Замены слов", - "Happening Today": "Происходит сегодня" + "Happening Today": "Происходит сегодня", + "Happening This Week": "Происходит на этой неделе" } diff --git a/translations/zh.json b/translations/zh.json index 15fb923f..6536148f 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -210,5 +210,6 @@ "Remove Twitter posts": "删除Twitter帖子", "Sensitive": "敏感", "Word Replacements": "单词替换", - "Happening Today": "今天发生" + "Happening Today": "今天发生", + "Happening This Week": "本周发生" } diff --git a/webinterface.py b/webinterface.py index bca7ec59..ab96364b 100644 --- a/webinterface.py +++ b/webinterface.py @@ -2969,6 +2969,11 @@ def htmlTimeline(defaultTimeline: str, \ str(now.year)+'?month='+str(now.month)+ \ '?day='+str(now.day)+'">' + if thisWeeksEventsCheck(baseDir,nickname,domain): + now=datetime.now() + tlStr+= \ + '
' # page up arrow if pageNumber>1: @@ -3809,6 +3814,54 @@ def todaysEventsCheck(baseDir: str,nickname: str,domain: str) -> bool: return eventsExist +def thisWeeksEventsCheck(baseDir: str,nickname: str,domain: str) -> bool: + """Are there calendar events this week? + """ + now=datetime.now() + year=now.year + monthNumber=now.month + dayNumber=now.day + + 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 and \ + int(eventTime.strftime("%d"))<=dayNumber+6): + eventsExist=True + break + + return eventsExist + def getThisWeeksEvents(baseDir: str,nickname: str,domain: str) -> {}: """Retrieves calendar events for this week Returns a dictionary indexed by day number of lists containing Event and Place activities