-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add start of ical support * Remove ical files and add to gitignore * Add requirements.txt for netlify * Change build script for netlify * Change build preview command to generate ical files * Use python3.8 compatiable toml library for netlify * Add events feed links to site * fix make_event_ical * Add calendar widget * Update URI scheme * Update add to ical link * Add webcals to uri scheme * take out the s * Change to http for ical * Add missing slash * Add Google Calendar link * Clean up widget * Refactor * url encode google calendar feed * Update events.html * Remove link from individial events * Update mobile styles for calendar holder
- Loading branch information
Showing
12 changed files
with
129 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
public | ||
result | ||
result | ||
*.ical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
attrs==23.1.0 | ||
click==8.1.7 | ||
icalendar==5.0.10 | ||
jsonschema==4.19.0 | ||
jsonschema-specifications==2023.7.1 | ||
python-dateutil==2.8.2 | ||
pytz==2023.3.post1 | ||
referencing==0.30.2 | ||
rpds-py==0.10.3 | ||
six==1.16.0 | ||
toml==0.10.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.add-to-calendar { | ||
padding: 1em 0; | ||
display: flex; | ||
gap: 1em; | ||
|
||
.button { | ||
box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 2px 0px; | ||
} | ||
} | ||
|
||
@media screen and (max-width: 700px) { | ||
.add-to-calendar { | ||
flex-direction: column; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python | ||
import icalendar | ||
from pathlib import Path | ||
|
||
import toml | ||
import click | ||
|
||
import pytz | ||
from datetime import datetime | ||
|
||
@click.command() | ||
@click.argument('posts', nargs=-1) | ||
@click.option('--output', help='Output for iCal files') | ||
def validate_data(posts, output): | ||
all_events = icalendar.Calendar() | ||
|
||
for post in posts: | ||
if '_index.md' in post: | ||
continue | ||
|
||
with open(post, 'r') as f: | ||
data_content = f.read().strip() | ||
|
||
separator = '+++' | ||
front_matter = data_content.split(separator)[1].strip() | ||
data = toml.loads(front_matter) | ||
|
||
# Parse the date and times | ||
event_date = data["extra"]["event"]["date"] | ||
start_time_str = data["extra"]["event"]["start_time"] | ||
stop_time_str = data["extra"]["event"]["stop_time"] | ||
|
||
# Create datetime objects with timezone information (Assuming PST) | ||
timezone = pytz.timezone("America/Los_Angeles") | ||
start_datetime = timezone.localize(datetime.strptime(f"{event_date} {start_time_str}", "%Y-%m-%d %H:%M")) | ||
stop_datetime = timezone.localize(datetime.strptime(f"{event_date} {stop_time_str}", "%Y-%m-%d %H:%M")) | ||
|
||
# Create the calendar and event objects | ||
cal = icalendar.Calendar() | ||
event = icalendar.Event() | ||
|
||
event.add("summary", data["title"]) | ||
event.add("description", data["description"]) | ||
event.add("dtstart", start_datetime) | ||
event.add("dtend", stop_datetime) | ||
event.add("location", f"{data['extra']['venue']['name']}, {data['extra']['venue']['address_street']}, " | ||
f"{data['extra']['venue']['address_city']} {data['extra']['venue']['address_zip']}") | ||
event.add("organizer", data["extra"]["organizer"]) | ||
|
||
# Add the event to the calendar | ||
cal.add_component(event) | ||
all_events.add_component(event) | ||
|
||
output_path = Path(f'{output}/{event_date}/event.ics') | ||
with open(output_path, 'wb') as f: | ||
f.write(cal.to_ical()) | ||
|
||
with Path(f'{output}/calendar.ics').open('wb') as f: | ||
f.write(all_events.to_ical()) | ||
|
||
|
||
if __name__ == '__main__': | ||
validate_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters