diff --git a/main.py b/main.py index 33e8639..a16b13a 100644 --- a/main.py +++ b/main.py @@ -1,122 +1,16 @@ import argparse import bottle -TEMPLATE_INDEX = ''' - - - - My calendar - - - -

August 2022

-
-
-
-
Monday
-
Tuesday
-
Wednesday
-
Thursday
-
Friday
-
Saturday
-
Sunday
- -% for day_info in days: -% if day_info['day_of_week'] == 1: -
-
W{{ day_info['week_of_year'] }}
-% end -
{{ day_info['day_of_month'] }}
-% for event_text in day_info['events']: -
{{ event_text }} -% end - -
-% end -
-
- - -''' - -## Paths -@bottle.route('/') -def reddit_index(): - events_map = { - 19: ['J: Spil Fredagsbar', 'L: Datbar'], - 20: ['F: Regatta'], - } +# Template rendering +def render_calendar(events_map, today): days = [] for day_of_month in range(1, 31 + 1): day_of_week = (day_of_month - 1) % 7 + 1 @@ -126,10 +20,29 @@ def reddit_index(): 'day_of_week': day_of_week, 'is_weekend': day_of_week == 6 or day_of_week == 7, 'week_of_year' : week_of_year, - 'today': day_of_month == 19, + 'today': day_of_month == today, + 'already_past': day_of_month < today, 'events': events_map.get(day_of_month, []), }) - return bottle.template(TEMPLATE_INDEX, days = days) + return bottle.template(templates.TEMPLATE_INDEX, days = days) + +## Paths + +@bottle.route('/static/') +def static(path): + return bottle.static_file(path, root = './static') + +@bottle.route('/') +def reddit_index(): + events_map = { + 15: ['J: Japansk 1'], + 19: ['J: Spil Fredagsbar', 'L: Datbar'], + 20: ['JL: Regatta'], + } + + today = 19 + + return render_calendar(events_map, today) ## Argument parsing diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..2dd475b --- /dev/null +++ b/static/style.css @@ -0,0 +1,96 @@ + +* { + box-sizing: border-box; + margin: 0; +} + +.week-counter { + width: 2%; + text-align: center; + border-right: 1px lightgray solid; + display: inline-block; + font-size: 0.5rem; +} + +.calendar-grid { + font-size: 0; + width: 100%; +} + +.calendar-weekday-header { + text-align: center; + font-weight: bold; + + border-bottom: 1px black solid; + font-size: 0.5rem; +} + +.calendar-day { + border-bottom: 1px lightgray solid; + border-right: 1px lightgray solid; + + min-height: 100px; + font-size: 0.5rem; + height: 18vh; +} + +.crossed-out { + position: relative; + overflow: hidden; +} + +.crossed-out:before, .crossed-out:after { + position: absolute; + content: ''; + background: grey; + display: block; + width: 100%; + height: 10px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + left: 0; + right: 0; + top: 0; + bottom: 0; + margin: auto; +} + +.crossed-out:after { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); +} + +.calendar-day.weekend-day { + background: yellow; +} + +.calendar-day .day-num { + text-align: right; + margin: 5px; +} + +.day-num.today { + background-color: red; + color: white; + padding-right: 4px; + border-radius: 7px; + margin: 5px 1px; + font-weight: bold; +} + +.event { + background: pink; + padding: 1px 5px; + border-radius: 7px; + margin: 5px; +} + +.calendar-day,.calendar-weekday-header { + width: 14%; + display: inline-block; +} + +.month-header { + text-align: center; +} + diff --git a/templates.py b/templates.py new file mode 100644 index 0000000..3ad801f --- /dev/null +++ b/templates.py @@ -0,0 +1,56 @@ +TEMPLATE_INDEX = ''' + + + + My calendar + + + + +

August 2022

+ + + + + + + + + + + + + + + +% for day_info in days: +% if day_info['day_of_week'] == 1: + + +% end + +% end + + +
MondayTuesdayWednesdayThursdayFridaySaturdaySunday
W{{ day_info['week_of_year'] }}
{{ day_info['day_of_month'] }}
+% for event_text in day_info['events']: +
{{ event_text }}
+% end +
+ + +''' + +