""" the main URL config that imports many URL configs from the applications. """
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.sitemaps.views import sitemap
from django.views.generic.base import TemplateView

from content import views, feeds
from content.sitemaps import ArticleSitemap, PageSitemap
from events.sitemaps import EventSitemap
from events.views import EventListIcal
from mahjong_ranking.sitemaps import *
from maistar_ranking.sitemaps import *
from membership.views import MembershipDetail

admin.autodiscover()

sitemaps = {
    'event_rankings': EventRankingSitemap,
    'event_hanchans': EventHanchanSitemap,
    'mahjong_seasons': MajongSeasonSitemap,
    'maistar_games': MaistarGamesSitemap,
    'articles': ArticleSitemap,
    'events': EventSitemap,
    'pages': PageSitemap,
}

urlpatterns = [  # Ignore PyLintBear (C0103)
    url(r'^$', views.StartPage.as_view()),
    url(r'^404/$', TemplateView.as_view(template_name='404.html')),
    url(r'^add_page/(?P<path>[\+\.\-\d\w\/]+)/$',
        views.PageAddForm.as_view(), name='add-page'),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'^ckeditor/', include('ckeditor_uploader.urls')),
    url(r'^comments/', include('django_comments.urls')),
    url(r'^edit_page/(?P<path>[\+\.\-\d\w\/]+)/$',
        views.PageEditForm.as_view(), name='edit-page'),
    url(r'^events/', include('events.urls')),
    url(r'^events.ics$', EventListIcal.as_view(), name='events-ical'),
    url(r'^feeds/latest/$', feeds.LatestNews(), name='feed-latest-news'),
    url(r'^feeds/comments/$', feeds.LatestComments(),
        name='feed-latest-comments'),
    url(r'^gallery/', include('events.gallery_urls')),
    url(r'^google25dabc1a49a9ef03.html$', TemplateView.as_view(
        template_name='google25dabc1a49a9ef03.html')),
    url(r'^i18n/', include('django.conf.urls.i18n'), name='start-page'),
    url(r'^index.html$', views.StartPage.as_view()),
    url(r'^manifest.json$',
        TemplateView.as_view(template_name='manifest.json')),
    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'^sitemap\.xml$', sitemap, {
        'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
    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'),
    url(r'^(?P<path>[\-\d\w\/]+)\.html$',
        views.PageHtml.as_view(), name='view-page'),
    url(r'^(?P<path>[\-\d\w\/]+)\.pdf$', views.PagePdf.as_view()),
    url('', include('social_django.urls', namespace='social'))
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)
    if 'rosetta' in settings.INSTALLED_APPS:
        urlpatterns += [url(r'^rosetta/', include('rosetta.urls'))]
    if 'debug_toolbar' in settings.INSTALLED_APPS:
        import debug_toolbar

        urlpatterns += [url(r'^__debug__/', include(debug_toolbar.urls)), ]
