django-greeking

Django template tools for printing filler, a technique from the days of hot type known as greeking

Features

Greeking can:

  • Generate filler images from placehold.it, placekitten.com and Fill Murray.

  • Print pangrams in a variety of languages. A pangram is a phrase that includes every letter of an alphabet.

  • Create Story, Image, RelatedItem and Quote objects with boilerplate text, URLs and a set of the attributes common to news.

  • Print snippets from Lewis Carroll’s poem Jabberwocky.

  • Import an list of filler comments for use in greeking Django’s ‘contrib’ comments app.

Installation

pip install greeking

Getting started

Before you can use any of the template tags, you have to add the app to the INSTALLED_APPS your settings.py file, like so:

INSTALLED_APPS = [
    "greeking",
]

And then import the library into your template.

{% load greeking_tags %}

Then you just need to call out the tag you want to use.

Templatetags

Placeholder images

All placeholder providers expect a width and height to be provided.

One provider is placekitten.com

{% placekitten 200 200 %}

Pangrams

A pangram is a phrase that includes every letter of an alphabet. It is useful when testing font implementations.

By default, an English pangram is returned.

{% pangram %}

The quick brown fox jumps over the lazy dog.

A set of other language are available, including Japanese, Spanish, French and German. They can be called by providing the language code like so:

{% pangram 'de' %}

Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.

Here is the complete list of available languages.

Code

Language

en

English

da

Danish

de

German

el

Greek

es

Spanish

fr

French

ga

Irish

he

Hebrew

hu

Hungarian

is

Icelandic

jp

Japanese

pl

Polish

ru

Russian

tr

Turkish

L.A. Times ipsum

A set of objects with boilerplate text, URLs and other attributes common to news.

The library can generate Story, Image, RelatedItem and Quote objects.

They should be assigned to variables in the template and then printed out as needed.

Story objects

{% latimes_story as obj %}

<h1>{{ obj.headline }}</h1>
<div>{{ obj.byline }}</div>

Which would print out as:

This is not a headline

This is not a byline

Here are all the attributes on a Story object:

Name

slug

headline

byline

pub_date

canonical_url

kicker

description

sources

credits

content

Quote objects

{% latimes_quote as obj %}

<q>{{ obj.quote }}</q>
<p>{{ obj.source }}</p>

Which would print out as:

This is not a quote

— This is not a source

Here are all the attributes on a Quote object:

Name

quote

source

Jabberwocky

“Jabberywocky” is a 1871 poem by Lewis Carroll, the author of “Alice in Wonderland.” Selections can be printed by using the tag below. The number of paragraphs can be optionally provided to limit its length. The poem has seven paragraphs in total.

{% jabberwocky 3 %}

‘Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe.

“Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!”

He took his vorpal sword in hand: Long time the manxome foe he sought- So rested he by the Tumtum tree, And stood awhile in thought.

Comments

An object_list of filler comments for use in greeking content for Django’s popular comments application.

{% greek_comment_list as comment_list %}
{% for comment in comment_list %}
    <div id="c{{ comment.id }}">
            <p>{{ comment.comment }}</p>
            <p>{{ comment.user_name }}</p>
            <p>{{ comment.submit_date|date:"F j, Y" }}</p>
            <p><a href="mailto:{{ comment.user_email }}">{{ comment.user_email }}</a></p>
            <p><a href="{{ comment.user_url }}">{{ comment.user_url }}</a></p>
    </div>
{% endfor %}

Credits

  • Pangrams are drawn from Markus Kuhn.

  • Comments drawn from the work of giants of our time.

Other resources