Skip to main content

django-umd-lib-style

Django app that provides theming for UMD Libraries applications.

Installation

pip install django-umd-lib-style

Setup

Add umd_lib_style to the INSTALLED_APPS list in your Django project's settings.py file:

INSTALLED_APPS = [
    ...,
    'umd_lib_style',
    ...,
]

To get some useful values (application name and version, navigation links) in the context for every request, add this context processor to your project's settings.py:

TEMPLATES = [
    {
        'OPTIONS': {
            'context_processors': [
                ...,
                'umd_lib_style.context_processors.app_info',
            ],
        },
    },
]

Templates

This app comes with a base template that provides the basic layout for the page (header with environment banner, logo, application name, navigation links, and a footer with the application name and version, and the UMD web accessibility link).

The easiest way to get the default page layout on your app's pages is to create a base.html template for your views that extends the umd_lib_style/base.html template:

{% extends 'umd_lib_style/base.html' %}
{% block head %}
... any HTML that should go into every page's <head> element ...
{% endblock %}
{% block main %}
... any HTML that should precede a specific page's content ...
{% block content %}{% endblock %}
... any HTML that should follow a specific page's content ...
{% endblock %}

Then, your individual page templates would extend this template, and supply their content in the content block:

{% extends 'my_app/base.html` %}
{% block content %}
<p>Hello, world!</p>
{% endblock %}

The umd-lib-style base template includes an h1 element whose content is taken from the value of the title context variable. It will also render any messages in the context. Both of these are rendered before the main block.

Context Values

If you have enabled the umd_lib_style.context_processors.app_info context processor, then you will have access to the following variables in all of your templates:

  • application_name (str)
  • application_version (str)
  • navigation_links (dict)
  • footer_links (dict)

Many of these are controlled by settings from your settings.py file.

Settings

There are some additional values you should set in your settings.py:

PROJECT_PACKAGE_NAME

  • Type: String
  • Default value: None

The application version is taken from this package's version using importlib.metadata.version(PROJECT_PACKAGE_NAME). That version is available in templates as application_version.

APPLICATION_NAME

  • Type: String
  • Default value: "App"

Application name to be displayed in the header and footer. Available in templates as application_name.

  • Type: Dictionary or string
  • Default value: {}

Dictionary mapping view names to labels. It is used to generate the navigation links in the header. Available in templates as navigation_links.

If a string is given, it is interpreted as the fully qualified name for a callable that will be run to generate the navigation links dictionary at request time. It must accept a single argument, a django.http.HttpRequest object representing the current request.

  • Type: Dictionary or string
  • Default value: {}

Dictionary mapping view names to labels. It is used to generate the navigation links in the footer. Available in templates as footer_links.

If a string is given, it is interpreted as the fully qualified name for a callable that will be run to generate the navigation links dictionary at request time. It must accept a single argument, a django.http.HttpRequest object representing the current request.

ENVIRONMENT

  • Type: String
  • Default value: "development"

Used to trigger the display of the standard environment banner at the top of every page. Should be one of "development", "test", or "qa". Any other value will suppress the display of the environment banner.

CSS

Custom Properties (a.k.a."Variables")

The included stylesheet defines a number of values using CSS custom properties. Many of these are color values, but a few deal with fonts and layout. They are all applied using the :root pseudo-element. See umd_lib_style.css for the full list.

Button Styles

In addition to providing basic thematic and layout styling in accordance with UMD's brand guidelines and the design of the UMD Libraries' other web UIs, the included CSS also provides some semantic classes for styling individual button or a.button elements.

Class name Use for buttons that ...
create ... immediately create or add a resource.
edit ... display a form or other method of modifying a resource.
update ... immediately save an already existing resource.
delete ... immediately remove a resource.
login ... send the user to a login form.
publish ... immediately publish a resource.

Form Styles

For forms that consist of a single button (plus, optionally, one or more hidden fields), use the .button class on the form element to display that form as an inline element. This allows it, for instance, to sit in the regular content flow next to links or other inline content.

Table Styles

There are two included table styles that can be selected by adding one of these classes to the table element:

Class name Description
grid Full borders around all cells, zebra striping, dark background for headers
lined Only a single line between rows, headers bold

License

See the LICENSE file for license rights and limitations (Apache 2.0).

Metadata

Release files for django-umd-lib-style 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-umd-lib-style 1.2.0
File Size Uploaded Provenance Actions
django_umd_lib_style-1.2.0.tar.gz 197.7 kB Without provenance Details for django_umd_lib_style-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-umd-lib-style 1.2.0
File Interpreter ABI Platform Actions
django_umd_lib_style-1.2.0-py3-none-any.whl Python 3 none any Details for django_umd_lib_style-1.2.0-py3-none-any.whl

Total release size: 395.1 kB

Release files / django_umd_lib_style-1.2.0.tar.gz

Download URL django_umd_lib_style-1.2.0.tar.gz
Size 197.7 kB
Tags Source
SHA-256 checksum
How to use checksums
249fccf235da37ee7532cba0c0d5783d9cd33e675105b3bb554bcec6cfe160b6
BLAKE2b-256 checksum
How to use checksums
41846e6be708c4cc1a06cda1cd4ff890ab8186bff546e03bc9e68c598d87d78d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release files / django_umd_lib_style-1.2.0-py3-none-any.whl

Download URL django_umd_lib_style-1.2.0-py3-none-any.whl
Size 197.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8df179efa7a34e9170b27bbeb9f74c1a37a57270e3e2518f1082fd89bd0a297c
BLAKE2b-256 checksum
How to use checksums
471b237311c96a63c038330cbbb329e413e49a797908611072048107d716d4f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Security for django-umd-lib-style 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page