Copyblock
Copyblock came out of a desire of mine to separate the copy for a site I’m working on from the site templates. Things like welcome messages, intro copy for forms, etc. This is copy I’d like to be able to tweak easily over time without having to redeploy the entire site to make it happen. What I wanted was a system kindof like gettext, but without .po files, the weird syntax, and a separete app to generate the right files.
What I wanted was really simple: a directory of text files, optionally in Markdown, that could be inserted into my app templates with a template tag. That’s what Copyblock does.
Installation
From Pypi:
% pip install django-copyblock
From Github:
% pip install -e git://github.com/sivy/django-copyblock.git#egg=copyblock
Usage
Create a root directory for your copyblock files:
% mkdir copy/dir
Add this path to your settings file:
COPYBLOCK_ROOT='path/to/your/copy/dir'
In your templates:
{% copyblock filename %}
This will do the following:
Look for copy/dir/filename.markdown
Run the file filename.markdown through markdown
Cache the output for future lookups
Insert the output in the rendered template
Right now, copyblock only does markdown. If your copy is not in markdown (plain text), you can pass in the nomarkdown parameter to the template tag:
{% copyblock filename nomarkdown %}
Also, if you don’t want to use the in-memory cache (load copy from file every time, good for copy editing), pass in the nocache parameter:
{% copyblock filename nocache %}
When working on site copy, it can be helpful to turn off the Copyblock cache completely with (in settings.py):
COPYBLOCK_CACHE=False
Serving Copyblock Files
Copyblock provides a simple app that will serve Markdown files in your COPYBLOCK_ROOT on the url endpoint of your choosing:
In settings.py, set the template name (in your main application) to render markdown files through:
COPYBLOCK_TEMPLATE='template.html'
This template should contain an output template variable, like so:
{{ output|safe }}
In urls.py, add:
urlpatterns += patterns('',
url(r'^site/(?P<path>.+)', include('copyblock.urls', namespace="copyblock", app_name='copyblock')),
)
The path can be whatever you choose.
Now, accessing http://mysite.example.com/site/name-of-markdown-file in your browser will load the content of the
@TODO
Add support for other text formats, or even HTML (suggestions, request? steve@wallrazer.com)
A view that will render any file in settings.COPYBLOCK_ROOT through the site’s base template (base.html) under a path determined by urls.py. IE, /path/to/copy/dir/foo.markdown would be viewable at yoursite.com/somepath/foo. Or, something like that. [DONE]
Metadata
Release files for django-copyblock 0.5.3
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 |
|---|---|---|---|---|
| django-copyblock-0.5.3.tar.gz | 4.7 kB | Without provenance | Details for django-copyblock-0.5.3.tar.gz |
Release files / django-copyblock-0.5.3.tar.gz
| Download URL | django-copyblock-0.5.3.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00a6652c11517189aadcfd0f7839dd100dc895c84f2db401f273dd03f028720e
|
|
BLAKE2b-256 checksum How to use checksums |
e5f5fae0d6c5d285f0c33bf7ed0de7b8b7c9fdd47c5f6076bf4dd0d3ee697e0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-copyblock 0.5.3
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.