Skip to main content

Shared components library for Great services.

Project description

directory-components

circle-ci-image codecov-image pypi-image

Reusable components used across the directory applications for the Department for International Trade.


Installation

pip install directory-components

Development

$ git clone https://github.com/uktrade/directory-components
$ cd directory-components

Demo

Install the demo requirements:

$ make demo_requirements

To view the components in the browser run the following command:

$ make run_demo

and go to 0.0.0.0:9013 in your browser

To test cookies locally add this to your /etc/hosts:

127.0.0.1       components.trade.great

Then visit the demo at components.trade.great:9013

Features

Environment variables

Environment variable Notes
FEATURE_SEARCH_ENGINE_INDEXING_DISABLED Controls RobotsIndexControlHeaderMiddlware.
FEATURE_MAINTENANCE_MODE_ENABLED Controls MaintenanceModeMiddleware.
FEATURE_FLAGS Place to store the service's feature flags.

Middleware

Middleware can be found in directory_components.middleware.FooBar.

Middleware Notes
MaintenanceModeMiddleware Redirects to http://sorry.great.gov.uk if FEATURE_MAINTENANCE_MODE_ENABLED is true.
NoCacheMiddlware Prevents any page in the service from caching pages of logged in users.
PrefixUrlMiddleware Redirects use from unprefixed url to prefixed url if FEATURE_URL_PREFIX_ENABLED is true.

Context processors

Middleware can be found in directory_components.context_processors.foo_bar.

Processor Context variable name Notes
sso_processor Exposes the state of the SSO user.
analytics directory_components_analytics GA details. Used by base template.
header_footer_processor header_footer_urls Urls used by base template's header and footer.
urls_processor directory_components_urls More urls used by base template's header and footer.
feature_flags feature_flags Exposes the service's feature flags.

Exception handlers

Add the following to your urls.py for directory components templates to be used on 404 and 500

handler404 = 'directory_components.views.handler404'

handler500 = 'directory_components.views.handler500'

Without doing this the 500 and 400 pages would not receive context data provided by context processors

Auto update services dependency

To automatically update the dependences of services that use this library call the following command:

$ make update

Publish to PyPI

The package should be published to PyPI on merge to master. If you need to do it locally then get the credentials from rattic and add the environment variables to your host machine:

Setting
DIRECTORY_PYPI_USERNAME
DIRECTORY_PYPI_PASSWORD

Then run the following command:

make publish

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

directory_components-27.0.0-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file directory_components-27.0.0-py3-none-any.whl.

File metadata

  • Download URL: directory_components-27.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.1 setuptools/38.7.0 requests-toolbelt/0.8.0 tqdm/4.32.2 CPython/3.6.6

File hashes

Hashes for directory_components-27.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37bcd0674f1f3fa18aadb57cc12517cd3a4935615f13d334c56475d56f42e74b
MD5 035305999df0de25521f1f6a0d89b316
BLAKE2b-256 ff1277dac27f66434909f4c12d5ef570ecc572bcedae1adff7f04507992be0c2

See more details on using hashes here.

Supported by

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