ametaireau/pelican — pull request #199 by kylef (2011-12-24 00:54:05+00:00)
Title: Configurable URL's and SAVE_AS files

This is similar to @borgar configurable-urls branch. But instead both the URL and the SAVE_AS are completely configurable and this is fully backwards compatible with CLEAN_URLS and ARTICLE_PERMALINK_STRUCTURE.

This adds the following settings:

- `ARTICLE_URL`
- `ARTICLE_SAVE_AS`
- `ARTICLE_LANG_URL`
- `ARTICLE_LANG_SAVE_AS`
- `PAGE_URL`
- `PAGE_SAVE_AS`
- `PAGE_LANG_URL`
- `PAGE_LANG_SAVE_AS`
- `AUTHOR_URL`
- `AUTHOR_SAVE_AS`
- `CATEGORY_URL`
- `CATEGORY_SAVE_AS`
- `TAG_URL`
- `TAG_SAVE_AS `

Which replaces:

- `CLEAN_URLS`
- `ARTICLE_PERMALINK_STRUCTURE`

When either of these deprecated settings are used, or a combination of them. pelican will produce a warning to the user and it will make it work. When you have ARTICLE_PERMALINK_STRUCTURE set as follows.

```
ARTICLE_PERMALINK_STRUCTURE = '/%Y/%(category)s/'
```

pelican will output the following:

```
WARNING: Found deprecated `ARTICLE_PERMALINK_STRUCTURE` in settings. Modifying the following settings for the same behaviour.
WARNING: ARTICLE_URL = '{date:%Y}/{category}/{slug}.html'
WARNING: ARTICLE_LANG_URL = '{date:%Y}/{category}/{slug}-{lang}.html'
WARNING: PAGE_URL = '{date:%Y}/{category}/pages/{slug}.html'
WARNING: PAGE_LANG_URL = '{date:%Y}/{category}/pages/{slug}-{lang}.html'
WARNING: ARTICLE_SAVE_AS = '{date:%Y}/{category}/{slug}.html'
WARNING: ARTICLE_LANG_SAVE_AS = '{date:%Y}/{category}/{slug}-{lang}.html'
WARNING: PAGE_SAVE_AS = '{date:%Y}/{category}/pages/{slug}.html'
WARNING: PAGE_LANG_SAVE_AS = '{date:%Y}/{category}/pages/{slug}-{lang}.html'
```

Example usage:

```
ARTICLE_URL = 'posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/'
ARTICLE_SAVE_AS = 'posts/{date:%Y}/{date:%b}/{date:%d}/{slug}/index.html'
```

The result of these patches means that every object has a .url and .save_as attribute which can be used in the template. As @borgar says, it would be nice if we could also have a jinja2 template tag for urls which can prefix the SITEURL. Turning `{% url article %}` into `{{ SITEURL }}/{{ article.url }}` for tidiness. I will leave this for someone with more experience with jinja2.

This would also close #153 as the same behaviour could be accomplished with these settings.