Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new updates #7

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/scripts/validate_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import yaml
from datetime import datetime

def validate_event(event):
required_fields = ['title', 'date', 'description', 'location']
for field in required_fields:
if field not in event:
raise ValueError(f"Missing required field: {field}")

# Validate date format
try:
datetime.strptime(event['date'], '%Y-%m-%d')
except ValueError:
raise ValueError(f"Invalid date format for event '{event['title']}'. Use YYYY-MM-DD.")

# Validate location (single word, no spaces)
if ' ' in event['location'] or not event['location'].isalnum():
raise ValueError(f"Invalid location for event '{event['title']}'. Location must be a single word with no spaces.")


def main():
with open('events.yaml', 'r') as file:
try:
events = yaml.safe_load(file)
except yaml.YAMLError as e:
print(f"Error parsing YAML: {e}")
exit(1)

if not isinstance(events, list):
print("Error: events.yaml should contain a list of events")
exit(1)

for event in events:
try:
validate_event(event)
except ValueError as e:
print(f"Validation error: {e}")
exit(1)

print("YAML validation successful")

if __name__ == "__main__":
main()
39 changes: 39 additions & 0 deletions .github/workflows/validate_event.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Validate Event YAML

on:
pull_request:
paths:
- 'events.yaml'

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml

- name: Validate YAML
run: |
python .github/scripts/validate_yaml.py

- name: Comment PR
uses: actions/github-script@v6
if: failure()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: 'The YAML validation failed. Please check the format of your event data.'
})
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# FastCalendar

This is a web-based calendar application built with FastHTML, providing an interactive and customizable event viewing experience.

It is primarily intended to be deployed directly from a Github repository, allowing event submission via PR.
FastCalendar is a lightweight, customizable web-based calendar application built with FastHTML. It's designed to be easily deployed directly from a GitHub repository, allowing event submissions via Pull Requests. This makes it ideal for community-driven event calendars or personal event tracking.

A live version can be viewed at https://tech-for-good.events/

Expand All @@ -16,6 +14,14 @@ A live version can be viewed at https://tech-for-good.events/
- Social media links integration
- Static logo display
- Markdown support for event descriptions and about section
- Easy event submission via GitHub Pull Requests

## Technology Stack

- Python 3.11+
- FastHTML
- SQLite
- YAML for configuration and event data

## Prerequisites

Expand Down Expand Up @@ -120,6 +126,43 @@ A live version can be viewed at https://tech-for-good.events/
- Edit the `events.yaml` file to add, remove, or modify events. Event descriptions support Markdown formatting.
- Replace the `logo.png` file in the `static` folder to change the application logo.

## Deployment

FastCalendar is designed to be deployed directly from a GitHub repository. You can use services like Vercel, Netlify, or GitHub Pages for easy deployment. Specific deployment instructions will depend on your chosen platform.

## Submitting Events

To submit a new event:

1. Fork the repository
2. Add your event to the `events.yaml` file
3. Create a Pull Request with your changes

The repository maintainer will review and merge your PR, updating the calendar.

## Updating the Application

To update the application or event data:

1. Pull the latest changes from the main repository
2. Update your `custom_settings.yaml` or `events.yaml` as needed
3. Redeploy your application

## Current Limitations

- Location names: The current version of FastCalendar only supports single-word location names. Multi-word location names may not function correctly for filtering and display purposes. We're working on improving this in future updates.

## Troubleshooting

If you encounter any issues:

- Ensure all dependencies are correctly installed
- Check that your `custom_settings.yaml` and `events.yaml` files are correctly formatted
- Verify that your Python version is 3.11 or higher
- Remember that location names should be single words

For more help, please open an issue on the GitHub repository.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
Expand Down
2 changes: 0 additions & 2 deletions events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

06:30pm - Doors open, food and drink served

07:00pm - Welcome

07:05pm - A short talk from our sponsor Daemon

07:10pm - John Sandall, CEO & Principal Data Scientist at Coefficient "Fairness Tales: Investigating the use of AI tools in hiring and recruitment"
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ requires-python = ">=3.11"
dependencies = [
"feedgen>=1.0.0",
"python-fasthtml>=0.6.4",
"pytz>=2024.2",
"pyyaml>=6.0.2",
]
Loading