diff --git a/epicyon-calendar.css b/epicyon-calendar.css index da05317b..807ac1bc 100644 --- a/epicyon-calendar.css +++ b/epicyon-calendar.css @@ -92,8 +92,8 @@ tr:nth-child(even) > .calendar__day__cell:nth-child(even) { } .calendar__day__cell[data-event] { - background-color: blue; - color: blue; + background-color: var(--lines-color); + color: var(--main-bg-color); } .calendar__day__cell[data-today] { @@ -102,3 +102,11 @@ tr:nth-child(even) > .calendar__day__cell:nth-child(even) { color: var(--today-circle); text-align: center; } + +.calendar__day__cell[data-today-event] { + border-radius: 50%; + background-color: var(--lines-color); + border: 4px solid var(--main-bg-color); + color: var(--main-bg-color); + text-align: center; +} diff --git a/webinterface.py b/webinterface.py index dc40e9ff..5f3b18b7 100644 --- a/webinterface.py +++ b/webinterface.py @@ -2751,12 +2751,12 @@ def weekDayOfMonthStart(monthNumber: int,year: int) -> int: firstDayOfMonth=datetime(year, monthNumber, 1, 0, 0) return int(firstDayOfMonth.strftime("%w"))+1 -def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumber: int) -> []: +def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumber: int) -> {}: """Retrieves calendar events - Returns a list of lists containing Event and Place activities + Returns a dictionary indexed by day number of lists containing Event and Place activities """ calendarFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/calendar/'+str(year)+'/'+str(monthNumber)+'.txt' - events=[] + events={} if not os.path.isfile(calendarFilename): return events calendarPostIds=[] @@ -2776,14 +2776,28 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str,year: int,monthNumb if isinstance(postJsonObject['object'], dict): if postJsonObject['object'].get('tag'): postEvent=[] + dayOfMonth=None for tag in postJsonObject['object']['tag']: if tag.get('type'): if tag['type']=='Event' or tag['type']=='Place': - postEvent.append(tag) - if postEvent: + if tag['type']=='Event': + # tag is an event + if tag.get('startTime'): + eventTime= \ + datetime.strptime(tag['startTime'], \ + "%Y-%m-%dT%H:%M:%SZ") + if int(eventTime.strftime("%Y"))==year and \ + int(eventTime.strftime("%m"))==monthNumber: + dayOfMonth=str(int(eventTime.strftime("%d"))) + postEvent.append(tag) + else: + # tag is a place + postEvent.append(tag) + if postEvent and dayOfMonth: calendarPostIds.append(postId) - # TODO this should be in a calendar-like format - events.append(postEvent) + if not events.get(dayOfMonth): + events[dayOfMonth]=[] + events[dayOfMonth].append(postEvent) else: recreateEventsFile=True @@ -2881,10 +2895,25 @@ def htmlCalendar(translate: {}, \ if currDate.month==monthNumber: if dayOfMonth==currDate.day: isToday=True - if not isToday: - calendarStr+=' '+str(dayOfMonth)+'\n' + if dayOfMonth==5: + events['5']=[{"test": 1},{"test2": 2},{"test3": 3},{"test4": 4}] + if events.get(str(dayOfMonth)): + eventDots='' + for i in range(1,len(events[str(dayOfMonth)])): + eventDots+='.' + if eventDots=='...': + break + # there are events for this day + if not isToday: + calendarStr+=' '+str(dayOfMonth)+'\n' + else: + calendarStr+=' '+str(dayOfMonth)+'\n' else: - calendarStr+=' '+str(dayOfMonth)+'\n' + # No events today + if not isToday: + calendarStr+=' '+str(dayOfMonth)+'\n' + else: + calendarStr+=' '+str(dayOfMonth)+'\n' else: calendarStr+=' \n' calendarStr+=' \n'