Metadata-Version: 1.1
Name: django-macros-url
Version: 0.1.0
Summary: Macros Url library for django
Home-page: https://github.com/phpdude/django-macros-url
Author: Alexandr Shurigin
Author-email: alexandr.shurigin@gmail.com
License: MIT
Description: # [Django Macros Url](https://github.com/phpdude/django-macros-url/) v0.1.0 - Routing must be simple as possible
        
        Django Macros Url makes it easy to write (and read) url patterns in your django applications by using macros.
        
        You can combine your prefixes with macro names with underscope, for example you can use macro `:slug` and `:product_slug`. They both will be compiled to same regex pattern with their group names of course. Multiple underscopes accepted too.
        
        ### Supported macros by default
        
        ```
        slug - [\w-]+
        year - \d{4}
        month - (0?([1-9])|10|11|12)
        day - ((0|1|2)?([1-9])|[1-3]0|31)
        id - \d+
        uuid - [a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12}
        ```
        
        If you want to offer more macros by default, you can fork and make pull request.
        
        ### Installation
        
        You can install library with pipy like a charm.
        
        ```
        pip install django-macros-url
        ```
        
        ### Usage
        
        Django Macros Urls used same way as django standart urls. You just import this and declare your patterns with macros.
        
        Also you can register new macro (or maybe you want to replace default macro with your like regex pattern) with `macrosurl.register(macro, pattern)` method.
        
        Example of registration.
        
        ```python
        import macrosurl
        
        macrosurl.register('myhash', '[a-f0-9]{9}')
        
        urlpatterns = patterns(
            'yourapp.views',
            url('^:myhash/$', 'myhash_main'),
            url('^news/:news_myhash/$', 'myhash_news'),
        )
        ```
        
        You free to register custom macro anywhere (i do it in main urls.py file). Macros Urls uses lazy initiazation. Macros will be compiled only on first request.
        
        ### Urls normalization
        
        Once Macros Url finished compile regex pattern, it makes normalization of it by rules:
        
        - Strip from left side all whitespace and ^
        - Strip from right side of pattern all whitespace and $
        - Add to left side ^
        - Add to right side $
        
        This makes your urls always very strong to adding any unexpected params into path.
        
        ### Examples
        
        Macro Url example urls.py file
        
        ```python
        from django.conf.urls import patterns
        from project.apps.portal import views
        from project.apps.macrosurl import url
        
        
        urlpatterns = patterns(
            'yourapp.views',
            url('^:category_slug/$', 'category'),
            url(':category_slug/:product_slug/', 'category_product'),
            url(':category_slug/:product_slug/:variant_id', 'category_product_variant'),
            url('news/', 'news'),
            url('news/:year/:month/:day$', 'news_date'),
            url('news/:slug$', 'news_entry'),
            url('^order/:id$', 'order'),
        )
        ```
        
        Django way urls example
        
        ```python
        from django.conf.urls import patterns
        from project.apps.portal import views
        from project.apps.macrosurl import url
        
        
        urlpatterns = patterns(
            'yourapp.views',
            url('^(?P<category_slug>[\w-]+>)/$', 'category'),
            url('^(?P<category_slug>[\w-]+>)/(?P<product_slug>[\w-]+>)/$', 'category_product'),
            url('^(?P<category_slug>[\w-]+>)/(?P<product_slug>[\w-]+>)/(?P<variant_id>\d+>)$', 'category_product_variant'),
            url('^news/$', 'news'),
            url('^news/(?P<year>\d{4}>)/(?P<month>(0?([1-9])|10|11|12)>)/(?P<day>((0|1|2)?([1-9])|[1-3]0|31)>)$', 'news_date'),
            url('^news/(?P<slug>[\w-]+>)$', 'news_entry'),
            url('^order/(?P<id>\d+>)$', 'order'),
        )
        ```
        
        I think you understand the difference of ways :)
        
        #### Routing must be simple! ;-)
        
        I think real raw url regexp patterns need in 1% case only. Prefer simple way to write (and read, this is important) fancy clean urls.
        
        ### Contributor
        
        Alexandr Shurigin (aka [phpdude](https://github.com/phpdude/))
Keywords: django macros url pattern regex
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Environment :: Plugins
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Pre-processors
Requires: django
