Skip to main content

html-calendar

Project description

This module has the simple purpose of building html calendar tables with links and formatting. It is totally framework agnostic.

The module provides the htmlcalendar Python function that takes an starting date and a number of months for rendering the HTML Tables containing the specified months with formated cells and HTML links on day’s numbers.

Formatting is provided by passing a callback function as the classes parameters that takes the date and returns a list of CSS classes that are applied to the date’s cell.

Linking dates to URLs is also provided by a callback function passed as the links parameter that takes the date and returns a fully qualified HTML link if required or None if not.

For formatting the headers and the table you can use css classes in a list with the options th_classes and table_classes.

Attributes dictionary is added for allowing further customization of the calendar with the keyword attrs. Then, for ensuring safety on the building of the calendar the safe option is added to escape all the variables that are rendered building the calendar when it is disabled.

It also supports North American calendar with the option caltype putting its value to 1.

from flask import Flask
from datetime import date
from htmlcalendar import htmlcalendar

app = Flask("party")

def links(date):
        if date.weekday() == 5:
                return "https://github.com/llou/html-calendar"

def css_class(date):
        if date.weekday() == 5:
                return ["party"]

def attrs(date):
    return {"onclick": f"whatever({date.year}, {date.month}, {date.day})"}

@app.route("/")
def party_calendar():
        return htmlcalendar(date.today(), months=1, links=links, classes=css_class)

You can read the documentation at https://html-calendar.readthedocs.io/en/latest/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

html_calendar-0.0.18.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

html_calendar-0.0.18-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file html_calendar-0.0.18.tar.gz.

File metadata

  • Download URL: html_calendar-0.0.18.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for html_calendar-0.0.18.tar.gz
Algorithm Hash digest
SHA256 60c316c8692c2508339508f4c2c4c94dc9bd8be1b746942062b8059cb58cd01e
MD5 80de7e11b83b0f969c527005829934bf
BLAKE2b-256 62e72ef8dbad90296851b0e2755a260a21325871003b2f330e75eb4c59d6bf56

See more details on using hashes here.

Provenance

File details

Details for the file html_calendar-0.0.18-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for html_calendar-0.0.18-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0d1188b58f2a6ea224e2172f12707a6bd106ce7069a47aad3a3cf8a3a4f38941
MD5 c659f9af3b02f1a6170a0be85382d132
BLAKE2b-256 3e2c29f652455b7dd6e897f6a4171c76c9ab007ba8cad1379c2b72213203365b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page