A collection of various Django utilities. It includes:
muckraking.middleware.SpacelessMiddleware
- Removes spaces and line breaks between html tags. Leaves <script> blocks intact
muckraking.middleware.LegacyURLRedirectMiddleware
An apache-like approach to redirects.
Specify your redirects in settings.py like this:
LEGACY_URL_REDIRECTS = ( (r'^/about/news-events\.php(.+)?', '/news-events/$1',), (r'^/about/(?!index\.php)', '/about/',), )
muckraking.template.context_processors.debug_context
- Add a
{{ DEBUG }}
variable Django templates. The value is a boolean
To use the following tags, add {% load muckraking_tags %}
to your template.
{% version_hash %}
- Outputs either the Git HEAD commit hash, or a hash of the atime value of the Django settings module. It first tries to output the Git commit hash. If unsuccessful, it falls back to the settings module file time hash.
{% git_commit_hash %}
- Outputs the commit hash of the HEAD commit in a git repo. Useful for cache-busting strings.
{% settings_file_time_hash %}
- Outputs a hash of the atime meta value of the Django settings module file. Useful for cache-busting strings.
To use the following tags, add {% load muckraking_cms_tags %}
to your template.
{% page_url_by_slug "foobar-page" %}
- Allows you to perform reverse lookups on pages by slug:
- import_redirects
Allows you to import a csv file of redirect urls into the redicet app:
./manage.py import_redirects ~/path/to/redirects.csv