"""Bundled dashboard: calendar."""
import json


def register(ctx):
    from dashboard_bundled.feeds import feed_calendar

    ctx.register_dashboard_tile(
        {
            "id": "calendar",
            "title": "Calendar",
            "path": "/tile",
            "refresh_seconds": 900,
            "priority": 2,
        }
    )

    def route_handler(req):
        body = json.dumps(feed_calendar(), ensure_ascii=False)
        return {
            "status": 200,
            "headers": {"Content-Type": "application/json; charset=utf-8"},
            "body": body,
        }

    ctx.register_route_handler(route_handler)
