Happening this week button

main
Bob Mottram 2020-02-22 18:32:12 +00:00
parent 0cb22bc2f1
commit 37cb1680bb
16 changed files with 83 additions and 15 deletions

View File

@ -210,5 +210,6 @@
"Remove Twitter posts": "إزالة مشاركات Twitter",
"Sensitive": "حساس",
"Word Replacements": "استبدال الكلمات",
"Happening Today": "يحدث اليوم"
"Happening Today": "يحدث اليوم",
"Happening This Week": "يحدث هذا الاسبوع"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -210,5 +210,6 @@
"Remove Twitter posts": "ट्विटर पोस्ट हटाएं",
"Sensitive": "संवेदनशील",
"Word Replacements": "शब्द प्रतिस्थापन",
"Happening Today": "आज हो रहा है"
"Happening Today": "आज हो रहा है",
"Happening This Week": "इस सप्ताह हो रहा है"
}

View File

@ -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"
}

View File

@ -210,5 +210,6 @@
"Remove Twitter posts": "Twitterの投稿を削除する",
"Sensitive": "敏感",
"Word Replacements": "単語の置換",
"Happening Today": "今日の出来事"
"Happening Today": "今日の出来事",
"Happening This Week": "今週の出来事"
}

View File

@ -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"
}

View File

@ -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"
}

View File

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

View File

@ -210,5 +210,6 @@
"Remove Twitter posts": "删除Twitter帖子",
"Sensitive": "敏感",
"Word Replacements": "单词替换",
"Happening Today": "今天发生"
"Happening Today": "今天发生",
"Happening This Week": "本周发生"
}

View File

@ -2969,6 +2969,11 @@ def htmlTimeline(defaultTimeline: str, \
str(now.year)+'?month='+str(now.month)+ \
'?day='+str(now.day)+'"><button class="buttonevent">'+ \
translate['Happening Today']+'</button></a></center>'
if thisWeeksEventsCheck(baseDir,nickname,domain):
now=datetime.now()
tlStr+= \
'<center><a href="'+actor+'/calendar"><button class="buttonevent">'+ \
translate['Happening This Week']+'</button></a></center>'
# 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