Shared components library for Export Directory.
Project description
# directory-components
[![code-climate-image]][code-climate]
[![circle-ci-image]][circle-ci]
[![codecov-image]][codecov]
[![gemnasium-image]][gemnasium]
**Reusable components used across the directory applications for the Department for International Trade.**
---
## Installation
```shell
pip install directory-components
```
## Development
$ git clone https://github.com/uktrade/directory-components
$ cd directory-components
## Demo
To view the components in the browser run the following command:
$ make run_demo
and go to `0.0.0.0:9000` in your browser
## 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 |
|------------|-------|
| `RobotsIndexControlHeaderMiddlware` | Informs the webcrawlers to not index the service if `FEATURE_SEARCH_ENGINE_INDEXING_DISABLED` is `true`. |
| `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. |
### 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. |
## 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
[code-climate-image]: https://codeclimate.com/github/uktrade/directory-components/badges/issue_count.svg
[code-climate]: https://codeclimate.com/github/uktrade/directory-components
[circle-ci-image]: https://circleci.com/gh/uktrade/directory-components/tree/master.svg?style=svg
[circle-ci]: https://circleci.com/gh/uktrade/directory-components/tree/master
[codecov-image]: https://codecov.io/gh/uktrade/directory-components/branch/master/graph/badge.svg
[codecov]: https://codecov.io/gh/uktrade/directory-components
[gemnasium-image]: https://gemnasium.com/badges/github.com/uktrade/directory-components.svg
[gemnasium]: https://gemnasium.com/github.com/uktrade/directory-components
[![code-climate-image]][code-climate]
[![circle-ci-image]][circle-ci]
[![codecov-image]][codecov]
[![gemnasium-image]][gemnasium]
**Reusable components used across the directory applications for the Department for International Trade.**
---
## Installation
```shell
pip install directory-components
```
## Development
$ git clone https://github.com/uktrade/directory-components
$ cd directory-components
## Demo
To view the components in the browser run the following command:
$ make run_demo
and go to `0.0.0.0:9000` in your browser
## 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 |
|------------|-------|
| `RobotsIndexControlHeaderMiddlware` | Informs the webcrawlers to not index the service if `FEATURE_SEARCH_ENGINE_INDEXING_DISABLED` is `true`. |
| `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. |
### 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. |
## 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
[code-climate-image]: https://codeclimate.com/github/uktrade/directory-components/badges/issue_count.svg
[code-climate]: https://codeclimate.com/github/uktrade/directory-components
[circle-ci-image]: https://circleci.com/gh/uktrade/directory-components/tree/master.svg?style=svg
[circle-ci]: https://circleci.com/gh/uktrade/directory-components/tree/master
[codecov-image]: https://codecov.io/gh/uktrade/directory-components/branch/master/graph/badge.svg
[codecov]: https://codecov.io/gh/uktrade/directory-components
[gemnasium-image]: https://gemnasium.com/badges/github.com/uktrade/directory-components.svg
[gemnasium]: https://gemnasium.com/github.com/uktrade/directory-components
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
Close
Hashes for directory_components-2.14.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d8837c3df80ce3d6a6b47dea71af09ead0d03377507410e5dc21da22b754c2 |
|
MD5 | d956c81b690f8c3450b0f0099f7208db |
|
BLAKE2b-256 | af5ebaef4b6c6f08a97591dfb2c955ec5e988b98ab6d7c24633cc41db09d849c |