mirror of https://gitlab.com/bashrc2/epicyon
Tomorrow event notification button
parent
eeb2f98329
commit
45029d45d0
59
happening.py
59
happening.py
|
@ -259,13 +259,12 @@ def getTodaysEvents(baseDir: str, nickname: str, domain: str,
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
|
||||||
def todaysEventsCheck(baseDir: str, nickname: str, domain: str) -> bool:
|
def dayEventsCheck(baseDir: str, nickname: str, domain: str, currDate) -> bool:
|
||||||
"""Are there calendar events today?
|
"""Are there calendar events for the given date?
|
||||||
"""
|
"""
|
||||||
now = datetime.now()
|
year = currDate.year
|
||||||
year = now.year
|
monthNumber = currDate.month
|
||||||
monthNumber = now.month
|
dayNumber = currDate.day
|
||||||
dayNumber = now.day
|
|
||||||
|
|
||||||
calendarFilename = \
|
calendarFilename = \
|
||||||
baseDir + '/accounts/' + nickname + '@' + domain + \
|
baseDir + '/accounts/' + nickname + '@' + domain + \
|
||||||
|
@ -309,54 +308,6 @@ def todaysEventsCheck(baseDir: str, nickname: str, domain: str) -> bool:
|
||||||
return eventsExist
|
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', '').replace('\r', '')
|
|
||||||
postFilename = locatePost(baseDir, nickname, domain, postId)
|
|
||||||
if not postFilename:
|
|
||||||
continue
|
|
||||||
|
|
||||||
postJsonObject = loadJson(postFilename)
|
|
||||||
if not _isHappeningPost(postJsonObject):
|
|
||||||
continue
|
|
||||||
|
|
||||||
for tag in postJsonObject['object']['tag']:
|
|
||||||
if not _isHappeningEvent(tag):
|
|
||||||
continue
|
|
||||||
# this tag is an event or a place
|
|
||||||
if tag['type'] != 'Event':
|
|
||||||
continue
|
|
||||||
# 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) -> {}:
|
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
|
Returns a dictionary indexed by day number of lists containing
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "حساس",
|
"Sensitive": "حساس",
|
||||||
"Word Replacements": "استبدال الكلمات",
|
"Word Replacements": "استبدال الكلمات",
|
||||||
"Happening Today": "اليوم",
|
"Happening Today": "اليوم",
|
||||||
|
"Happening Tomorrow": "غدا",
|
||||||
"Happening This Week": "هكذا",
|
"Happening This Week": "هكذا",
|
||||||
"Blog": "مدونة",
|
"Blog": "مدونة",
|
||||||
"Blogs": "المدونات",
|
"Blogs": "المدونات",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Sensible",
|
"Sensitive": "Sensible",
|
||||||
"Word Replacements": "Substitucions de paraula",
|
"Word Replacements": "Substitucions de paraula",
|
||||||
"Happening Today": "Avui",
|
"Happening Today": "Avui",
|
||||||
|
"Happening Tomorrow": "Demà",
|
||||||
"Happening This Week": "Aviat",
|
"Happening This Week": "Aviat",
|
||||||
"Blog": "Bloc",
|
"Blog": "Bloc",
|
||||||
"Blogs": "Blocs",
|
"Blogs": "Blocs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Sensitif",
|
"Sensitive": "Sensitif",
|
||||||
"Word Replacements": "Amnewidiadau Geiriau",
|
"Word Replacements": "Amnewidiadau Geiriau",
|
||||||
"Happening Today": "Heddiw",
|
"Happening Today": "Heddiw",
|
||||||
|
"Happening Tomorrow": "Yfory",
|
||||||
"Happening This Week": "Yn fuan",
|
"Happening This Week": "Yn fuan",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Empfindlich",
|
"Sensitive": "Empfindlich",
|
||||||
"Word Replacements": "Wortersetzungen",
|
"Word Replacements": "Wortersetzungen",
|
||||||
"Happening Today": "Heute",
|
"Happening Today": "Heute",
|
||||||
|
"Happening Tomorrow": "Morgen",
|
||||||
"Happening This Week": "Demnächst",
|
"Happening This Week": "Demnächst",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Sensitive",
|
"Sensitive": "Sensitive",
|
||||||
"Word Replacements": "Word Replacements",
|
"Word Replacements": "Word Replacements",
|
||||||
"Happening Today": "Today",
|
"Happening Today": "Today",
|
||||||
|
"Happening Tomorrow": "Tomorrow",
|
||||||
"Happening This Week": "Soon",
|
"Happening This Week": "Soon",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Sensible",
|
"Sensitive": "Sensible",
|
||||||
"Word Replacements": "Reemplazos de palabras",
|
"Word Replacements": "Reemplazos de palabras",
|
||||||
"Happening Today": "Hoy",
|
"Happening Today": "Hoy",
|
||||||
|
"Happening Tomorrow": "Mañana",
|
||||||
"Happening This Week": "Pronto",
|
"Happening This Week": "Pronto",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Sensible",
|
"Sensitive": "Sensible",
|
||||||
"Word Replacements": "Remplacements de mots",
|
"Word Replacements": "Remplacements de mots",
|
||||||
"Happening Today": "Aujourd'hui",
|
"Happening Today": "Aujourd'hui",
|
||||||
|
"Happening Tomorrow": "Demain",
|
||||||
"Happening This Week": "Bientôt",
|
"Happening This Week": "Bientôt",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Íogair",
|
"Sensitive": "Íogair",
|
||||||
"Word Replacements": "Athchur Focal",
|
"Word Replacements": "Athchur Focal",
|
||||||
"Happening Today": "Inniu",
|
"Happening Today": "Inniu",
|
||||||
|
"Happening Tomorrow": "Amárach",
|
||||||
"Happening This Week": "Go gairid",
|
"Happening This Week": "Go gairid",
|
||||||
"Blog": "Blag",
|
"Blog": "Blag",
|
||||||
"Blogs": "Blaganna",
|
"Blogs": "Blaganna",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "संवेदनशील",
|
"Sensitive": "संवेदनशील",
|
||||||
"Word Replacements": "शब्द प्रतिस्थापन",
|
"Word Replacements": "शब्द प्रतिस्थापन",
|
||||||
"Happening Today": "आज",
|
"Happening Today": "आज",
|
||||||
|
"Happening Tomorrow": "आने वाला कल",
|
||||||
"Happening This Week": "जल्द ही",
|
"Happening This Week": "जल्द ही",
|
||||||
"Blog": "ब्लॉग",
|
"Blog": "ब्लॉग",
|
||||||
"Blogs": "ब्लॉग",
|
"Blogs": "ब्लॉग",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Sensibile",
|
"Sensitive": "Sensibile",
|
||||||
"Word Replacements": "Sostituzioni di parole",
|
"Word Replacements": "Sostituzioni di parole",
|
||||||
"Happening Today": "Oggi",
|
"Happening Today": "Oggi",
|
||||||
|
"Happening Tomorrow": "Domani",
|
||||||
"Happening This Week": "Presto",
|
"Happening This Week": "Presto",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blog",
|
"Blogs": "Blog",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "敏感",
|
"Sensitive": "敏感",
|
||||||
"Word Replacements": "単語の置換",
|
"Word Replacements": "単語の置換",
|
||||||
"Happening Today": "今日",
|
"Happening Today": "今日",
|
||||||
|
"Happening Tomorrow": "明日",
|
||||||
"Happening This Week": "すぐに",
|
"Happening This Week": "すぐに",
|
||||||
"Blog": "ブログ",
|
"Blog": "ブログ",
|
||||||
"Blogs": "ブログ",
|
"Blogs": "ブログ",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Pêketî",
|
"Sensitive": "Pêketî",
|
||||||
"Word Replacements": "Veguheztinên Peyvan",
|
"Word Replacements": "Veguheztinên Peyvan",
|
||||||
"Happening Today": "Îro",
|
"Happening Today": "Îro",
|
||||||
|
"Happening Tomorrow": "Sibê",
|
||||||
"Happening This Week": "Nêzda",
|
"Happening This Week": "Nêzda",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -208,7 +208,8 @@
|
||||||
"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",
|
"Happening Today": "Today",
|
||||||
|
"Happening Tomorrow": "Tomorrow",
|
||||||
"Happening This Week": "Soon",
|
"Happening This Week": "Soon",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "Sensível",
|
"Sensitive": "Sensível",
|
||||||
"Word Replacements": "Substituições do Word",
|
"Word Replacements": "Substituições do Word",
|
||||||
"Happening Today": "Hoje",
|
"Happening Today": "Hoje",
|
||||||
|
"Happening Tomorrow": "Amanhã",
|
||||||
"Happening This Week": "Em breve",
|
"Happening This Week": "Em breve",
|
||||||
"Blog": "Blog",
|
"Blog": "Blog",
|
||||||
"Blogs": "Blogs",
|
"Blogs": "Blogs",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "чувствительный",
|
"Sensitive": "чувствительный",
|
||||||
"Word Replacements": "Замены слов",
|
"Word Replacements": "Замены слов",
|
||||||
"Happening Today": "Cегодня",
|
"Happening Today": "Cегодня",
|
||||||
|
"Happening Tomorrow": "Завтра",
|
||||||
"Happening This Week": "Скоро",
|
"Happening This Week": "Скоро",
|
||||||
"Blog": "Блог",
|
"Blog": "Блог",
|
||||||
"Blogs": "Блоги",
|
"Blogs": "Блоги",
|
||||||
|
|
|
@ -213,6 +213,7 @@
|
||||||
"Sensitive": "敏感",
|
"Sensitive": "敏感",
|
||||||
"Word Replacements": "单词替换",
|
"Word Replacements": "单词替换",
|
||||||
"Happening Today": "今天",
|
"Happening Today": "今天",
|
||||||
|
"Happening Tomorrow": "明天",
|
||||||
"Happening This Week": "不久",
|
"Happening This Week": "不久",
|
||||||
"Blog": "博客",
|
"Blog": "博客",
|
||||||
"Blogs": "网志",
|
"Blogs": "网志",
|
||||||
|
|
|
@ -10,8 +10,8 @@ __status__ = "Production"
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from happening import todaysEventsCheck
|
from datetime import timedelta
|
||||||
from happening import thisWeeksEventsCheck
|
from happening import dayEventsCheck
|
||||||
from webapp_utils import htmlHighlightLabel
|
from webapp_utils import htmlHighlightLabel
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,9 +152,10 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
# show todays events buttons on the first inbox page
|
# show todays events buttons on the first inbox page
|
||||||
happeningStr = ''
|
happeningStr = ''
|
||||||
if boxName == 'inbox' and pageNumber == 1:
|
if boxName == 'inbox' and pageNumber == 1:
|
||||||
if todaysEventsCheck(baseDir, nickname, domain):
|
now = datetime.now()
|
||||||
now = datetime.now()
|
tomorrow = datetime.now() + timedelta(1)
|
||||||
|
twodays = datetime.now() + timedelta(2)
|
||||||
|
if dayEventsCheck(baseDir, nickname, domain, now):
|
||||||
# happening today button
|
# happening today button
|
||||||
if not iconsAsButtons:
|
if not iconsAsButtons:
|
||||||
happeningStr += \
|
happeningStr += \
|
||||||
|
@ -171,35 +172,35 @@ def headerButtonsTimeline(defaultTimeline: str,
|
||||||
'<button class="button">' + \
|
'<button class="button">' + \
|
||||||
translate['Happening Today'] + '</button></a>'
|
translate['Happening Today'] + '</button></a>'
|
||||||
|
|
||||||
# happening this week button
|
elif dayEventsCheck(baseDir, nickname, domain, tomorrow):
|
||||||
if thisWeeksEventsCheck(baseDir, nickname, domain):
|
# happening tomorrow button
|
||||||
if not iconsAsButtons:
|
if not iconsAsButtons:
|
||||||
happeningStr += \
|
happeningStr += \
|
||||||
'<a href="' + usersPath + \
|
'<a href="' + usersPath + '/calendar?year=' + \
|
||||||
'/calendar" tabindex="-1">' + \
|
str(tomorrow.year) + '?month=' + str(tomorrow.month) + \
|
||||||
'<button class="buttonevent">' + \
|
'?day=' + str(tomorrow.day) + '" tabindex="-1">' + \
|
||||||
translate['Happening This Week'] + '</button></a>'
|
'<button class="buttonevent">' + \
|
||||||
else:
|
translate['Happening Tomorrow'] + '</button></a>'
|
||||||
happeningStr += \
|
else:
|
||||||
'<a href="' + usersPath + \
|
happeningStr += \
|
||||||
'/calendar" tabindex="-1">' + \
|
'<a href="' + usersPath + '/calendar?year=' + \
|
||||||
'<button class="button">' + \
|
str(tomorrow.year) + '?month=' + str(tomorrow.month) + \
|
||||||
translate['Happening This Week'] + '</button></a>'
|
'?day=' + str(tomorrow.day) + '" tabindex="-1">' + \
|
||||||
else:
|
'<button class="button">' + \
|
||||||
# happening this week button
|
translate['Happening Tomorrow'] + '</button></a>'
|
||||||
if thisWeeksEventsCheck(baseDir, nickname, domain):
|
elif dayEventsCheck(baseDir, nickname, domain, twodays):
|
||||||
if not iconsAsButtons:
|
if not iconsAsButtons:
|
||||||
happeningStr += \
|
happeningStr += \
|
||||||
'<a href="' + usersPath + \
|
'<a href="' + usersPath + \
|
||||||
'/calendar" tabindex="-1">' + \
|
'/calendar" tabindex="-1">' + \
|
||||||
'<button class="buttonevent">' + \
|
'<button class="buttonevent">' + \
|
||||||
translate['Happening This Week'] + '</button></a>'
|
translate['Happening This Week'] + '</button></a>'
|
||||||
else:
|
else:
|
||||||
happeningStr += \
|
happeningStr += \
|
||||||
'<a href="' + usersPath + \
|
'<a href="' + usersPath + \
|
||||||
'/calendar" tabindex="-1">' + \
|
'/calendar" tabindex="-1">' + \
|
||||||
'<button class="button">' + \
|
'<button class="button">' + \
|
||||||
translate['Happening This Week'] + '</button></a>'
|
translate['Happening This Week'] + '</button></a>'
|
||||||
|
|
||||||
if not featuresHeader:
|
if not featuresHeader:
|
||||||
# button for the outbox
|
# button for the outbox
|
||||||
|
|
Loading…
Reference in New Issue