Fehérke's GitHub Site == glue between Fehérke's GitHub hosted projects

Sketch

Not an outstanding name. Not an outstanding idea. There are already enough similar softwares and online services on the web. I wrote a couple of similar things myself too. Including in Python. The only new element was involving Django.

To make them available in multiple circumstances, I tried to make them as flexible as possible. So the placeholders can be generated through views, template filters and template tags. Of course, there are small differences between those calling methods, but those are mostly imposed by the circumstances.

Usage

Image placeholder

The image placeholder is just an image of a certain size. Inspired by free online services like Cambelt, Dynamic Dummy Image Generator, Fake images please?, FPOImg ( “For Placement Only” ), Ipsum Image, Lorem Pixel, Placehold it, Yet Another Placeholder Generator ( in alphabetical order, no personal preference involved ).

image placeholder

generated image placeholder

Live image placeholder demo, thanks to PythonAnywhere.

It has few parameters :

Parameter Description Type Default
width Image width Integer 640
height Image height Integer 480
front Text color Name or hexadecimal code #666
back Background color Name or hexadecimal code #999
text Inscription on the image Text with placeholders %(width)s x %(height)s

General notes :

URL with verbose parameters

Suitable to be used from outside the Django application, typically in static HTML documents.

/sketch/iph.png?width=400&height=100&front=fuchsia&back=purple&text=%25(width)px%20wide%20image

Additional notes :

Friendly URL

/sketch/iph/400/100/fuchsia/purple/%25(width)px%20wide%20image

Additional notes :

The notes from the above URL with verbose parameters section also applies.

Template filter

Suitable for the rare case when you have the HTML img tag’s source code in a template variable.

{{ '<img src="/whatever.png" width=100 height=50 front=fuchsia back=purple alt="%(width)spx wide image">' | imgplace }}
{{ '<img src="/whatever.png" width=100 height=50 alt="%(width)spx wide image">' | imgplace:"front=fuchsia back=purple" }}

Additional notes :

Template tag

{% imgplace width=100 height=50 front="fuchsia" back="purple" text="%(width)px wide image" %}

Additional notes :

Text placeholder

The text placeholder is just a text of a certain length. Inspired by free online services like Dummy Text Generator, Gangsta Lorem Ipsum dummy text generator, Lorem Ipsum Generator, Lorem Ipsum, professional lorem ipsum generator for typographers ( in alphabetical order, no personal preference involved ).

text placeholder

Em mefahu sigelesimit esin ube. Er elire ovexas ese ipa fe eni elalo ir eteg ihi inehediyalofin. Abapisulesi ton le aheben mositataho. Ciraca ah ut pogoceyepi ipas. Toh bewayobepe erivite moru sey im sasusunefetane adenirere ale epeyat. Werile gana neras cehe ineban rer ege bahet etecac beret ne enoyic. Eni itesu webe etebene neremexa. At iretib obaretol dosiri yareseto. Or bef onasut res pot. Iden i oliy raleye rugomisu.

Live text placeholder demo, thanks to PythonAnywhere.

It has few parameters :

Parameter Description Type Default
entity Units of text to generate text, paragraph, sentence or word text
length Subunit count in the generated text Integer Random or 5
sample Sample text to analyze Text The Zen of Python

General notes :

URL with verbose parameters

Suitable to be used from outside the Django application, typically in static HTML documents.

/sketch/blah.txt?entity=paragraph&length=10

Friendly URL

/sketch/blah/paragraph/10

Additional notes :

Template filter

Suitable for the sample to analyze is in a template variable.

{{ 'Hello World' | blahblah:"paragraph 10" }}

Additional notes :

Template tag

{% blahblah "paragraph" 10 %}

Template block tag

{% blahblock "paragraph" 10 %}
Hello World
{% endblahblock %}

Configuration

You have to add sketch to the INSTALLED_APPS in your Django project’s settings :

your_django_project/settings.py

INSTALLED_APPS = (
    'your_django_project.sketch',
)

You have to include() the sketch urls into your Django project’s urls :

your_django_project/urls.py

urlpatterns = patterns('',
    url(r'^sketch/', include('your_django_project.sketch.urls')),
)

And generally you have to replace all occurences of “your_django_project” with… well, the name of your Django project.

Proper configuration not really supported.

One thing you may have to configure is the font used for the image placeholder’s text. You can set it by editing the image_placeholder() function’s first line :

sketch/image_placeholder.py

def image_placeholder(param):
    fontfile = '/usr/share/fonts/X11/TTF/arialbd.ttf'
    minsize = 5
    maxsize = 500

The next two lines are the lower and upper limits between which a suitable font size is checked. The largest font size which still fits the image size will be used. Just so you know it. Hopefully you will never need to change those limits.

Versions

Plans

Download

You can find the related files on GitHub in my Django-application repository’s sketch directory :