diff --git a/translations/ar.json b/translations/ar.json index 438105c10..83d909f8d 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "إزالة المشاركات المجدولة", "Remove Twitter posts": "إزالة مشاركات Twitter", "Sensitive": "حساس", - "Word Replacements": "استبدال الكلمات" + "Word Replacements": "استبدال الكلمات", + "Happening Today": "يحدث اليوم" } diff --git a/translations/ca.json b/translations/ca.json index 3bba014ce..c41a76435 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Elimineu les publicacions programades", "Remove Twitter posts": "Elimina les publicacions de Twitter", "Sensitive": "Sensible", - "Word Replacements": "Substitucions de paraula" + "Word Replacements": "Substitucions de paraula", + "Happening Today": "Passant avui" } diff --git a/translations/cy.json b/translations/cy.json index dced09697..7d492fd8b 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Tynnwch y swyddi a drefnwyd", "Remove Twitter posts": "Dileu postiadau Twitter", "Sensitive": "Sensitif", - "Word Replacements": "Amnewidiadau Geiriau" + "Word Replacements": "Amnewidiadau Geiriau", + "Happening Today": "Digwydd Heddiw" } diff --git a/translations/de.json b/translations/de.json index a3c281597..792a8eabc 100644 --- a/translations/de.json +++ b/translations/de.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Geplante Posts entfernen", "Remove Twitter posts": "Entfernen Sie Twitter-Posts", "Sensitive": "Empfindlich", - "Word Replacements": "Wortersetzungen" + "Word Replacements": "Wortersetzungen", + "Happening Today": "Heute passiert" } diff --git a/translations/en.json b/translations/en.json index 0b55cfecf..863a4fd8f 100644 --- a/translations/en.json +++ b/translations/en.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Remove scheduled posts", "Remove Twitter posts": "Remove Twitter posts", "Sensitive": "Sensitive", - "Word Replacements": "Word Replacements" + "Word Replacements": "Word Replacements", + "Happening Today": "Happening Today" } diff --git a/translations/es.json b/translations/es.json index 824216cdc..e936d6c82 100644 --- a/translations/es.json +++ b/translations/es.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Eliminar publicaciones programadas", "Remove Twitter posts": "Eliminar publicaciones de Twitter", "Sensitive": "Sensible", - "Word Replacements": "Reemplazos de palabras" + "Word Replacements": "Reemplazos de palabras", + "Happening Today": "Sucediendo hoy" } diff --git a/translations/fr.json b/translations/fr.json index ef87fb1a7..bf25dd4e1 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Supprimer les messages planifiés", "Remove Twitter posts": "Supprimer les messages Twitter", "Sensitive": "Sensible", - "Word Replacements": "Remplacements de mots" + "Word Replacements": "Remplacements de mots", + "Happening Today": "Se passe aujourd'hui" } diff --git a/translations/ga.json b/translations/ga.json index e284ec9b1..e3da6d270 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Bain na poist sceidealta", "Remove Twitter posts": "Bain poist Twitter", "Sensitive": "Íogair", - "Word Replacements": "Athchur Focal" + "Word Replacements": "Athchur Focal", + "Happening Today": "Ag tarlú inniu" } diff --git a/translations/hi.json b/translations/hi.json index 69cf3c91b..8fcef6bff 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "अनुसूचित पदों को हटा दें", "Remove Twitter posts": "ट्विटर पोस्ट हटाएं", "Sensitive": "संवेदनशील", - "Word Replacements": "शब्द प्रतिस्थापन" + "Word Replacements": "शब्द प्रतिस्थापन", + "Happening Today": "आज हो रहा है" } diff --git a/translations/it.json b/translations/it.json index 8855d12ae..9b8bf7024 100644 --- a/translations/it.json +++ b/translations/it.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Rimuovi i post programmati", "Remove Twitter posts": "Rimuovi i post di Twitter", "Sensitive": "Sensibile", - "Word Replacements": "Sostituzioni di parole" + "Word Replacements": "Sostituzioni di parole", + "Happening Today": "Succede oggi" } diff --git a/translations/ja.json b/translations/ja.json index 704feaf30..617cf782b 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "スケジュールされた投稿を削除する", "Remove Twitter posts": "Twitterの投稿を削除する", "Sensitive": "敏感", - "Word Replacements": "単語の置換" + "Word Replacements": "単語の置換", + "Happening Today": "今日の出来事" } diff --git a/translations/oc.json b/translations/oc.json index 1f92f6774..e22c79ed8 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -205,5 +205,6 @@ "Remove scheduled posts": "Remove scheduled posts", "Remove Twitter posts": "Remove Twitter posts", "Sensitive": "Sensitive", - "Word Replacements": "Word Replacements" + "Word Replacements": "Word Replacements", + "Happening Today": "Happening Today" } diff --git a/translations/pt.json b/translations/pt.json index 24e54503e..0f97c66f2 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Remover postagens agendadas", "Remove Twitter posts": "Remover postagens do Twitter", "Sensitive": "Sensível", - "Word Replacements": "Substituições do Word" + "Word Replacements": "Substituições do Word", + "Happening Today": "Acontecendo hoje" } diff --git a/translations/ru.json b/translations/ru.json index d3a37f76c..1f4aa3206 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "Удалить запланированные сообщения", "Remove Twitter posts": "Удалить сообщения из Твиттера", "Sensitive": "чувствительный", - "Word Replacements": "Замены слов" + "Word Replacements": "Замены слов", + "Happening Today": "Происходит сегодня" } diff --git a/translations/zh.json b/translations/zh.json index 0af1bf723..15fb923f9 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -209,5 +209,6 @@ "Remove scheduled posts": "删除预定的帖子", "Remove Twitter posts": "删除Twitter帖子", "Sensitive": "敏感", - "Word Replacements": "单词替换" + "Word Replacements": "单词替换", + "Happening Today": "今天发生" } diff --git a/webinterface.py b/webinterface.py index 74c974542..064ef5632 100644 --- a/webinterface.py +++ b/webinterface.py @@ -2960,6 +2960,11 @@ def htmlTimeline(defaultTimeline: str, \ # add the javascript for content warnings tlStr+='' + # show todays events button + if boxName=='inbox': + if todaysEventsCheck(baseDir,nickname,domain): + tlStr+='
' + # page up arrow if pageNumber>1: tlStr+='
'+translate['Page up']+'
' @@ -3752,6 +3757,61 @@ def getTodaysEvents(baseDir: str,nickname: str,domain: str, \ 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) -> {}: """Retrieves calendar events for this week Returns a dictionary indexed by day number of lists containing Event and Place activities