QDCrumbs
Quick & Dirty Breadcrumbs
Description
This package provides a simple way to add dynamic breadcrumbs to a Flask application. The breadcrumbs can easily be used in a jinja2 template.
QDcrumbs work in both the main Flask application and in Flask Blueprints, and currently support a single variable page, simply import qdcrumb from qdcrumbs and follow the examples below.
Get started:
Getting started with qdcrumbs is easy! Import the qdcrumb object and follow the example below.
Examples
The following examples work both in the main Flask app and Blueprints!
Importing qdcrumbs:
from flask import Flask
from qdcrumbs import qdcrumb
Standard Usage:
@app.route('/')
def my_page():
x = qdcrumb.get_crumbs()
return render_template('/my_page.html', breadcrumbs=x)
With a variable name:
@app.route('/path/to/<var>')
def my_page(var):
x = qdcrumb.get_crumbs(var)
return render_template(f'/path/to/{var}.html', breadcrumbs=x)
IMPORTANT!
qdcrumb.get_crumbs() must be called from within a function that points to a resource's route: i.e. a function with the route decorator (@app.route | @blueprint.route). This is because the url is resolved via Flask using url_for() which takes the name of the function that was decorated.
Breadcrumbs are provided as a list of the Breadcrumb class and have the following attributes:
- url --> Path to the current page/resource & preceding pages.
- text --> Name of the current page/resource.
Changing app name
By default, QDcrumbs assumes your Flask application has the name 'app' and was initialized in the following manner:
app = Flask(__name__) #__name__ being 'app'
If your app uses a different name, you must change it on the qdcrumb object in your main python file:
qdcrumb.set_app_name('your_app_name')
HTML
The breadcrumbs do not provide the site's root directory, this can be added manually trivially (see html jinja2 template example below).
<div>
<!--
Include a static link to the site root (Index.html)
(The Application's root must be added manually)
-->
<a href="{{ url_for('index.html')}}">Index</a>
<!--Loop through the breadcrumbs to this resource-->
{%- for breadcrumb in breadcrumbs -%}
<a href="{{ breadcrumb.url }}"> / {{ breadcrumb.text }}</a>
{%- endfor -%}
</div>
Changelog
0.0.2
- Removed a print statement when accessing resources on a web page.
0.0.1
- First version released.
Metadata
Release files for qdcrumbs 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qdcrumbs-0.0.2.tar.gz | 4.2 kB | Without provenance | Details for qdcrumbs-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qdcrumbs-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for qdcrumbs-0.0.2-py3-none-any.whl |
Total release size: 8.6 kB
Release files / qdcrumbs-0.0.2.tar.gz
| Download URL | qdcrumbs-0.0.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
977fe69e1e13bb30d0025f083f736e7015690c846b9027a6b514f7c8c615f01c
|
|
BLAKE2b-256 checksum How to use checksums |
9f73a461ad391f51a8a65f46b723c8a5caa782aa62fb01c07876d304a7b47d50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / qdcrumbs-0.0.2-py3-none-any.whl
| Download URL | qdcrumbs-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b25803c566a0f58d311968459dbb9e9c90e4ac272662d6112d552db146c62805
|
|
BLAKE2b-256 checksum How to use checksums |
a6a1a00aa05e42661d94d324e7807e42c2218c8f415737c10967f5f8e76074ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for qdcrumbs 0.0.2
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.