Django robots.txt generator
Project description
=========================
django-url-robots
=========================
``Django`` ``robots.txt`` generator. Based on using decorated ``django.conf.urls.defaults.url``
Installation & Usage
=========================
The recommended way to install django-url-robots is with `pip <http://pypi.python.org/pypi/pip>`_
1. Install from PyPI with ``easy_install`` or ``pip``::
pip install django-url-robots
2. Add ``'url_robots'`` to your ``INSTALLED_APPS``::
INSTALLED_APPS = (
...
'url_robots',
...
)
3. Add url_robots view to your root URLconf::
urlpatterns += patterns('',
url(r'^robots.txt$', 'url_robots.views.robots_txt'),
)
4. Describe rules by boolean keyword arguments
``robots_allow`` and ``robots_disallow``
using for it ``url_robots.utils.url`` instead ``django.conf.urls.defaults.url``::
from url_robots.utils import url
urlpatterns += patterns('',
url('^profile/private$', 'view', robots_disallow=True),
)
``django-url-robots`` tested with ``Django-1.3``
Settings
====================
In this moment there are only one option to define template of ``robots.txt`` file.::
urlpatterns += patterns('',
url(r'^robots.txt$', 'url_robots.views.robots_txt', {'template': 'my_awesome_robots_template.txt'}),
)
Example
===================
robots_template.txt::
User-agent: *
Disallow: /* # disallow all
{{ rules|safe }}
urls.py::
from django.conf.urls.defaults import patterns, include
urlpatterns = patterns('',
url(r'^profile', include('url_robots.tests.urls_profile')),
)
urls_profile.py::
from django.conf.urls.defaults import patterns
from url_robots.utils import url
urlpatterns = patterns('',
url(r'^s$', 'view', name='profiles', robots_allow=True),
url(r'^/(?P<nick>\w+)$', 'view'),
url(r'^/(?P<nick>\w+)/private', 'view', name='profile_private', robots_disallow=True),
url(r'^/(?P<nick>\w+)/public', 'view', name='profile_public', robots_allow=True),
)
Resulting robots.txt::
User-agent: *
Disallow: /* # disallow all
Allow: /profiles$
Disallow: /profile/*/private*
Allow: /profile/*/public*
django-url-robots
=========================
``Django`` ``robots.txt`` generator. Based on using decorated ``django.conf.urls.defaults.url``
Installation & Usage
=========================
The recommended way to install django-url-robots is with `pip <http://pypi.python.org/pypi/pip>`_
1. Install from PyPI with ``easy_install`` or ``pip``::
pip install django-url-robots
2. Add ``'url_robots'`` to your ``INSTALLED_APPS``::
INSTALLED_APPS = (
...
'url_robots',
...
)
3. Add url_robots view to your root URLconf::
urlpatterns += patterns('',
url(r'^robots.txt$', 'url_robots.views.robots_txt'),
)
4. Describe rules by boolean keyword arguments
``robots_allow`` and ``robots_disallow``
using for it ``url_robots.utils.url`` instead ``django.conf.urls.defaults.url``::
from url_robots.utils import url
urlpatterns += patterns('',
url('^profile/private$', 'view', robots_disallow=True),
)
``django-url-robots`` tested with ``Django-1.3``
Settings
====================
In this moment there are only one option to define template of ``robots.txt`` file.::
urlpatterns += patterns('',
url(r'^robots.txt$', 'url_robots.views.robots_txt', {'template': 'my_awesome_robots_template.txt'}),
)
Example
===================
robots_template.txt::
User-agent: *
Disallow: /* # disallow all
{{ rules|safe }}
urls.py::
from django.conf.urls.defaults import patterns, include
urlpatterns = patterns('',
url(r'^profile', include('url_robots.tests.urls_profile')),
)
urls_profile.py::
from django.conf.urls.defaults import patterns
from url_robots.utils import url
urlpatterns = patterns('',
url(r'^s$', 'view', name='profiles', robots_allow=True),
url(r'^/(?P<nick>\w+)$', 'view'),
url(r'^/(?P<nick>\w+)/private', 'view', name='profile_private', robots_disallow=True),
url(r'^/(?P<nick>\w+)/public', 'view', name='profile_public', robots_allow=True),
)
Resulting robots.txt::
User-agent: *
Disallow: /* # disallow all
Allow: /profiles$
Disallow: /profile/*/private*
Allow: /profile/*/public*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-url-robots-1.0.zip
(14.0 kB
view details)
File details
Details for the file django-url-robots-1.0.zip
.
File metadata
- Download URL: django-url-robots-1.0.zip
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d8d03a5beeade5b292c609125b2d3ca81dfce4d4f87d732df84c5703c0c5b82 |
|
MD5 | 36b519b1457dc4dfa9e299f322d47ff7 |
|
BLAKE2b-256 | c67e0bf8be1509690fdebeb194a03b1de9dfdd1e91562984592b6b1c36371f97 |