From d191fa22e08c6d38c13b89aca6c40356d77a9940 Mon Sep 17 00:00:00 2001 From: Ben Firshman Date: Sat, 20 Sep 2014 18:52:16 -0700 Subject: Convert readme to markdown --- README | 83 ------------------------------------------------------------ README.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 83 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index b6a15ee..0000000 --- a/README +++ /dev/null @@ -1,83 +0,0 @@ -django-shorturls -================ - -A custom URL shortening app for Django, including easy ``rev=canonical`` -support. - -Most code was originally by Simon Willison; see -http://simonwillison.net/2009/Apr/11/revcanonical/ for details. Improved -slightly and packaged by Jacob Kaplan-Moss. - -Patches welcome: http://github.com/jacobian/django-shorturls - -Usage -===== - -So, you want to host your own short URLs on your Django site: - -1. In your settings, define a set of prefixes for short URLs:: - - SHORTEN_MODELS = { - 'A': 'myapp.animal', - 'V': 'myapp.vegetable', - 'M': 'myapp.mineral' - } - - The keys are string prefixes; they can be any string, actually, - but since we're going for short a single character is probably good. - - Values are the (hopefully-familiar) ``"."`` used - by Django to identify a model. Remember: ``app-name`` is the - (case-sensitive) last bit of your app's name in ``INSTALLED_APPS``, and - ```` is your model class's name, lowercased. - - Make sure your models have a ``get_absolute_url()`` method defined. - -2. Wire up the redirect view by adding to your URLconf:: - - ('^short/', include('shorturls.urls')) - -3. If you'd like to quickly link to shortened URLs in your templates, stick - ``"shorturls"`` in ``INSTALLED_APPS``, and then in your templates do:: - - {% load shorturl %} - ... - - (where ``object`` is a model instance). - - Alternatively:: - - {% load shorturl %} - {% revcanonical object %} - - This generates the whole ```` tag for - you. - -That's it. - -If you'd like more control, keep reading. - -Settings -======== - -Available settings are: - -``SHORTEN_MODELS`` - You've seen this one. - -``SHORT_BASE_URL`` - If defined, the ``shorturl`` and ``revcanonical`` template tags will - prefix generated URLs with this value. Use this if you've got a shorter - domain name you'd like to use for small URLs. - - For example, given ``SHORT_BASE_URL = 'http://exm.pl/'``, ``{% shorturl - obj %}`` would return something like ``http://exm.pl/AbCd``. - -``SHORTEN_FULL_BASE_URL`` - The domain to redirect to when redirecting away from the small URL. - Again, you'll use this if your short URL base and your "real" site - differ. - - If not defined, the redirect view will try to guess the proper domain by - consulting the ``django.contrib.sites`` framework, if installed, or the - requested domain, if not. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e7d3991 --- /dev/null +++ b/README.md @@ -0,0 +1,86 @@ +django-shorturls +================ + +A custom URL shortening app for Django, including easy ``rev=canonical`` +support. + +Most code was originally by Simon Willison; see +http://simonwillison.net/2009/Apr/11/revcanonical/ for details. Improved +slightly and packaged by Jacob Kaplan-Moss. + +Patches welcome: http://github.com/jacobian/django-shorturls + +Usage +----- + +So, you want to host your own short URLs on your Django site: + +1. In your settings, define a set of prefixes for short URLs: + + SHORTEN_MODELS = { + 'A': 'myapp.animal', + 'V': 'myapp.vegetable', + 'M': 'myapp.mineral' + } + + The keys are string prefixes; they can be any string, actually, + but since we're going for short a single character is probably good. + + Values are the (hopefully-familiar) ``"."`` used + by Django to identify a model. Remember: ``app-name`` is the + (case-sensitive) last bit of your app's name in ``INSTALLED_APPS``, and + ```` is your model class's name, lowercased. + + Make sure your models have a ``get_absolute_url()`` method defined. + +2. Wire up the redirect view by adding to your URLconf: + + ('^short/', include('shorturls.urls')) + +3. If you'd like to quickly link to shortened URLs in your templates, stick + ``"shorturls"`` in ``INSTALLED_APPS``, and then in your templates do: + + {% load shorturl %} + ... + + (where ``object`` is a model instance). + + Alternatively:: + + {% load shorturl %} + {% revcanonical object %} + + This generates the whole ```` tag for + you. + +That's it. + +If you'd like more control, keep reading. + +Settings +-------- + +Available settings are: + +#### ``SHORTEN_MODELS`` + +You've seen this one. + +#### ``SHORT_BASE_URL`` + +If defined, the ``shorturl`` and ``revcanonical`` template tags will +prefix generated URLs with this value. Use this if you've got a shorter +domain name you'd like to use for small URLs. + +For example, given ``SHORT_BASE_URL = 'http://exm.pl/'``, ``{% shorturl +obj %}`` would return something like ``http://exm.pl/AbCd``. + +#### ``SHORTEN_FULL_BASE_URL`` + +The domain to redirect to when redirecting away from the small URL. +Again, you'll use this if your short URL base and your "real" site +differ. + +If not defined, the redirect view will try to guess the proper domain by +consulting the ``django.contrib.sites`` framework, if installed, or the +requested domain, if not. -- cgit v1.2.3 From 330f0b6faf4fe68a9abf70f490380205d76cdbad Mon Sep 17 00:00:00 2001 From: Ben Firshman Date: Sun, 21 Sep 2014 11:46:40 -0700 Subject: Add Travis and PyPi badge --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e7d3991..797bd78 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ django-shorturls ================ +[![Build Status](https://travis-ci.org/bfirsh/django-shorturls.svg?branch=master)](https://travis-ci.org/bfirsh/django-shorturls) +[![PyPI version](https://badge.fury.io/py/django-shorturls.svg)](http://badge.fury.io/py/django-shorturls) + A custom URL shortening app for Django, including easy ``rev=canonical`` support. -- cgit v1.2.3