# Path: findingaids/fa/sitemaps.py
# FINDINGAID_SITEMAPS = {
#     'findingaids': FindingAidSitemap,
#     'findingaids-pdf': PDFSitemap,
#     'findingaids-eadxml': EADXMLSitemap,   # maybe
#     'findingaids-series': SeriesSitemap,
#     'findingaids-subseries': SubseriesSitemap,
#     'findingaids-subsubseries': SubsubseriesSitemap,
#     'findingaids-index': IndexSitemap,
# }
# 
# Path: findingaids/content/sitemaps.py
# class ContentSitemap(Sitemap):
#     changefreq = 'yearly'    # this content changes very rarely
#     default_priority = 0.4   # lower priority than actual findingaid content
# 
#     # names for pages within content url namespace
#     content_pages = ['request-materials', 'feedback', 'faq',
#                      'search-tips', 'contributors']
# 
# 
#     def items(self):
#         # special case pages - index, static html site pages
#         items = [reverse('content:%s' % page) for page in self.content_pages]
#         items.append(reverse('site-index'))
# 
#         # possibly also advanced search? (not really content to index)
# 
#         # generate list of higher priority urls (can't be calculated at load
#         # time because urls haven't been defined yet)
#         self.higher_priority = [reverse('site-index'), reverse('content:faq'),
#                        reverse('content:search-tips')]
# 
#         return items
# 
#     def location(self, item):
#         return item
# 
#     def priority(self, item):
#         # set specific urls (such as home page) to higher priority
#         if item in self.higher_priority:
#             return 0.5
#         return self.default_priority
# 
# Path: findingaids/content/views.py
# def site_index(request):
# def feedback(request):
# def request_materials(request):


from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.sitemaps import views as sitemaps_views
from django.views.generic import TemplateView
from django.views.generic.base import RedirectView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from findingaids.fa.sitemaps import FINDINGAID_SITEMAPS
from findingaids.content.sitemaps import ContentSitemap
from findingaids.content import views as contentviews

urlpatterns = [
    url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt',
        content_type='text/plain')),
    url(r'^favicon\.ico$', RedirectView.as_view(url='/static/images/favicon.ico',
        permanent=True)),

    # embedded url on non-library Emory sites that gets picked up by search bots
    url(r'^-Libraries-EmoryFindingAids$',
        RedirectView.as_view(url='/', permanent=True)),

    url(r'^db-admin/', include(admin.site.urls)),
    url(r'^admin/', include('findingaids.fa_admin.urls',
                            namespace='fa-admin')),
    url(r'^$', contentviews.site_index, name='site-index'),
    url(r'^content/', include('findingaids.content.urls',
                              namespace='content')),
    # everything else should fall through to the main app
    url(r'^', include('findingaids.fa.urls', namespace='fa')),
]

# xml sitemaps for search-engine discovery
sitemap_cfg = {'content': ContentSitemap}
sitemap_cfg.update(FINDINGAID_SITEMAPS)

urlpatterns += [
    url(r'^sitemap\.xml$', sitemaps_views.index, {'sitemaps': sitemap_cfg},
       name='django.contrib.sitemaps.views.sitemap'),
    url(r'^sitemap-(?P<section>.+)\.xml$', sitemaps_views.sitemap,
       {'sitemaps': sitemap_cfg},

# Path: findingaids/fa/sitemaps.py
# FINDINGAID_SITEMAPS = {
#     'findingaids': FindingAidSitemap,
#     'findingaids-pdf': PDFSitemap,
#     'findingaids-eadxml': EADXMLSitemap,   # maybe
#     'findingaids-series': SeriesSitemap,
#     'findingaids-subseries': SubseriesSitemap,
#     'findingaids-subsubseries': SubsubseriesSitemap,
#     'findingaids-index': IndexSitemap,
# }
# 
# Path: findingaids/content/sitemaps.py
# class ContentSitemap(Sitemap):
#     changefreq = 'yearly'    # this content changes very rarely
#     default_priority = 0.4   # lower priority than actual findingaid content
# 
#     # names for pages within content url namespace
#     content_pages = ['request-materials', 'feedback', 'faq',
#                      'search-tips', 'contributors']
# 
# 
#     def items(self):
#         # special case pages - index, static html site pages
#         items = [reverse('content:%s' % page) for page in self.content_pages]
#         items.append(reverse('site-index'))
# 
#         # possibly also advanced search? (not really content to index)
# 
#         # generate list of higher priority urls (can't be calculated at load
#         # time because urls haven't been defined yet)
#         self.higher_priority = [reverse('site-index'), reverse('content:faq'),
#                        reverse('content:search-tips')]
# 
#         return items
# 
#     def location(self, item):
#         return item
# 
#     def priority(self, item):
#         # set specific urls (such as home page) to higher priority
#         if item in self.higher_priority:
#             return 0.5
#         return self.default_priority
# 
# Path: findingaids/content/views.py
# def site_index(request):
# def feedback(request):
# def request_materials(request):


# Path: findingaids/urls.py
from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.sitemaps import views as sitemaps_views
from django.views.generic import TemplateView
from django.views.generic.base import RedirectView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from findingaids.fa.sitemaps import FINDINGAID_SITEMAPS
from findingaids.content.sitemaps import ContentSitemap
from findingaids.content import views as contentviews


urlpatterns = [
    url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt',
        content_type='text/plain')),
    url(r'^favicon\.ico$', RedirectView.as_view(url='/static/images/favicon.ico',
        permanent=True)),

    # embedded url on non-library Emory sites that gets picked up by search bots
    url(r'^-Libraries-EmoryFindingAids$',
        RedirectView.as_view(url='/', permanent=True)),

    url(r'^db-admin/', include(admin.site.urls)),
    url(r'^admin/', include('findingaids.fa_admin.urls',
                            namespace='fa-admin')),
    url(r'^$', contentviews.site_index, name='site-index'),
    url(r'^content/', include('findingaids.content.urls',
                              namespace='content')),
    # everything else should fall through to the main app
    url(r'^', include('findingaids.fa.urls', namespace='fa')),
]

# xml sitemaps for search-engine discovery
sitemap_cfg = {'content': ContentSitemap}
sitemap_cfg.update(FINDINGAID_SITEMAPS)

urlpatterns += [
    url(r'^sitemap\.xml$', sitemaps_views.index, {'sitemaps': sitemap_cfg},
       name='django.contrib.sitemaps.views.sitemap'),
    url(r'^sitemap-(?P<section>.+)\.xml$', sitemaps_views.sitemap,
       {'sitemaps': sitemap_cfg},

       name='django.contrib.sitemaps.views.sitemap'),