# -*- encoding: utf-8 -*-
from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
from content.views import *  # @UnusedWildImport
from events.views import EventListIcal
from content.feeds import LatestNews, LatestComments
from membership.views import MembershipDetail
from django.views.generic.base import TemplateView, RedirectView

admin.autodiscover()

urlpatterns = patterns(
    '',
    url(r'^$', StartPage.as_view()),
    url(r'^404/$', TemplateView.as_view(template_name='404.html')),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^ckeditor/', include('ckeditor.urls')),
    url(r'^comments/', include('django_comments.urls')),
    url(r'^content/', include('content.urls')),
    url(r'^events/', include('events.urls')),
    url(r'^events.ics$', EventListIcal.as_view(), name='events-ical'),
    url(r'^feeds/latest/$', LatestNews(), name='feed-latest-news'),
    url(r'^feeds/comments/$', LatestComments(), name='feed-latest-comments'),
    url(r'^gallery/', include('gallery.urls')),
    url(r'^google25dabc1a49a9ef03.html$', TemplateView.as_view(template_name='google25dabc1a49a9ef03.html')),
    url(r'^grappelli/', include('grappelli.urls')),
    url(r'^i18n/', include('django.conf.urls.i18n'), name='start-page'),
    url(r'^index.html$', StartPage.as_view()),
    url(r'^markdown/', include('django_markdown.urls')),
    url(r'^membership/', include('membership.urls')),
    url(r'^news/', include('content.news_urls')),
    url(r'^ranking/', include('mahjong_ranking.urls')),
    url(r'^ranking/', include('maistar_ranking.urls')),
    url(r'^robots.txt$', TemplateView.as_view(template_name='robots.txt')),
    url(r'^users/$', MembershipDetail.as_view(), name='membership-details'),
    url(r'^users/(?P<username>[\-\.\d\w]+)/$', MembershipDetail.as_view(), name='membership-details'),
)

if settings.DEBUG:
    urlpatterns += patterns('',
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    )

    if 'rosetta' in settings.INSTALLED_APPS:
        urlpatterns += patterns('', url(r'^rosetta/', include('rosetta.urls')),)

    if 'debug_toolbar' in settings.INSTALLED_APPS:
        import debug_toolbar
        urlpatterns += patterns('', url(r'^__debug__/', include(debug_toolbar.urls)),)

urlpatterns += patterns('',
                        url(r'^add_page/(?P<path>[\+\.\-\d\w\/]+)/$',
                            PageAddForm.as_view(), name='add-page'),
                        url(r'^edit_page/(?P<path>[\+\.\-\d\w\/]+)/$',
                            PageEditForm.as_view(), name='edit-page'),
                        url(r'^(?P<path>[\-\d\w\/]+)\.html$',
                            PageHtml.as_view(), name='view-page'),
                        url(r'^(?P<path>[\-\d\w\/]+)\.pdf$', PagePdf.as_view()),
)
