# Path: djangoblog/admin_site.py
# class DjangoBlogAdminSite(AdminSite):
#     def __init__(self, name='admin'):
#     def has_permission(self, request):
# 
# Path: djangoblog/feeds.py
# class DjangoBlogFeed(Feed):
#     feed_type = Rss201rev2Feed
# 
#     description = '大巧无工,重剑无锋.'
#     title = "且听风吟 大巧无工,重剑无锋. "
#     link = "/feed/"
# 
#     def author_name(self):
#         return get_user_model().objects.first().nickname
# 
#     def author_link(self):
#         return get_user_model().objects.first().get_absolute_url()
# 
#     def items(self):
#         return Article.objects.filter(type='a', status='p').order_by('-pub_time')[:5]
# 
#     def item_title(self, item):
#         return item.title
# 
#     def item_description(self, item):
#         return CommonMarkdown.get_markdown(item.body)
# 
#     def feed_copyright(self):
#         now = datetime.now()
#         return "Copyright© {year} 且听风吟".format(year=now.year)
# 
#     def item_link(self, item):
#         return item.get_absolute_url()
# 
#     def item_guid(self, item):
#         return
# 
# Path: djangoblog/sitemap.py
# class StaticViewSitemap(Sitemap):
#     priority = 0.5
#     changefreq = 'daily'
# 
#     def items(self):
#         return ['blog:index', ]
# 
#     def location(self, item):
#         return reverse(item)
# 
# class ArticleSiteMap(Sitemap):
#     changefreq = "monthly"
#     priority = "0.6"
# 
#     def items(self):
#         return Article.objects.filter(status='p')
# 
#     def lastmod(self, obj):
#         return obj.last_mod_time
# 
# class CategorySiteMap(Sitemap):
#     changefreq = "Weekly"
#     priority = "0.6"
# 
#     def items(self):
#         return Category.objects.all()
# 
#     def lastmod(self, obj):
#         return obj.last_mod_time
# 
# class TagSiteMap(Sitemap):
#     changefreq = "Weekly"
#     priority = "0.3"
# 
#     def items(self):
#         return Tag.objects.all()
# 
#     def lastmod(self, obj):
#         return obj.last_mod_time
# 
# class UserSiteMap(Sitemap):
#     changefreq = "Weekly"
#     priority = "0.3"
# 
#     def items(self):
#         return list(set(map(lambda x: x.author, Article.objects.all())))
# 
#     def lastmod(self, obj):
#         return obj.date_joined


from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.contrib.sitemaps.views import sitemap
from django.urls import include
from djangoblog.admin_site import admin_site
from djangoblog.feeds import DjangoBlogFeed
from djangoblog.sitemap import StaticViewSitemap, ArticleSiteMap, CategorySiteMap, TagSiteMap, UserSiteMap
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""


sitemaps = {

    'blog': ArticleSiteMap,
    'Category': CategorySiteMap,
    'Tag': TagSiteMap,
    'User': UserSiteMap,
    'static': StaticViewSitemap
}

handler404 = 'blog.views.page_not_found_view'
handler500 = 'blog.views.server_error_view'
handle403 = 'blog.views.permission_denied_view'
urlpatterns = [
                  url(r'^admin/', admin_site.urls),
                  url(r'', include('blog.urls', namespace='blog')),
                  url(r'mdeditor/', include('mdeditor.urls')),
                  url(r'', include('comments.urls', namespace='comment')),
                  url(r'', include('accounts.urls', namespace='account')),
                  url(r'', include('oauth.urls', namespace='oauth')),
                  url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
                      name='django.contrib.sitemaps.views.sitemap'),
                  url(r'^feed/$', DjangoBlogFeed()),

# Path: djangoblog/admin_site.py
# class DjangoBlogAdminSite(AdminSite):
#     def __init__(self, name='admin'):
#     def has_permission(self, request):
# 
# Path: djangoblog/feeds.py
# class DjangoBlogFeed(Feed):
#     feed_type = Rss201rev2Feed
# 
#     description = '大巧无工,重剑无锋.'
#     title = "且听风吟 大巧无工,重剑无锋. "
#     link = "/feed/"
# 
#     def author_name(self):
#         return get_user_model().objects.first().nickname
# 
#     def author_link(self):
#         return get_user_model().objects.first().get_absolute_url()
# 
#     def items(self):
#         return Article.objects.filter(type='a', status='p').order_by('-pub_time')[:5]
# 
#     def item_title(self, item):
#         return item.title
# 
#     def item_description(self, item):
#         return CommonMarkdown.get_markdown(item.body)
# 
#     def feed_copyright(self):
#         now = datetime.now()
#         return "Copyright© {year} 且听风吟".format(year=now.year)
# 
#     def item_link(self, item):
#         return item.get_absolute_url()
# 
#     def item_guid(self, item):
#         return
# 
# Path: djangoblog/sitemap.py
# class StaticViewSitemap(Sitemap):
#     priority = 0.5
#     changefreq = 'daily'
# 
#     def items(self):
#         return ['blog:index', ]
# 
#     def location(self, item):
#         return reverse(item)
# 
# class ArticleSiteMap(Sitemap):
#     changefreq = "monthly"
#     priority = "0.6"
# 
#     def items(self):
#         return Article.objects.filter(status='p')
# 
#     def lastmod(self, obj):
#         return obj.last_mod_time
# 
# class CategorySiteMap(Sitemap):
#     changefreq = "Weekly"
#     priority = "0.6"
# 
#     def items(self):
#         return Category.objects.all()
# 
#     def lastmod(self, obj):
#         return obj.last_mod_time
# 
# class TagSiteMap(Sitemap):
#     changefreq = "Weekly"
#     priority = "0.3"
# 
#     def items(self):
#         return Tag.objects.all()
# 
#     def lastmod(self, obj):
#         return obj.last_mod_time
# 
# class UserSiteMap(Sitemap):
#     changefreq = "Weekly"
#     priority = "0.3"
# 
#     def items(self):
#         return list(set(map(lambda x: x.author, Article.objects.all())))
# 
#     def lastmod(self, obj):
#         return obj.date_joined


# Path: djangoblog/urls.py
from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.contrib.sitemaps.views import sitemap
from django.urls import include
from djangoblog.admin_site import admin_site
from djangoblog.feeds import DjangoBlogFeed
from djangoblog.sitemap import StaticViewSitemap, ArticleSiteMap, CategorySiteMap, TagSiteMap, UserSiteMap

    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""


sitemaps = {

    'blog': ArticleSiteMap,
    'Category': CategorySiteMap,
    'Tag': TagSiteMap,
    'User': UserSiteMap,
    'static': StaticViewSitemap
}

handler404 = 'blog.views.page_not_found_view'
handler500 = 'blog.views.server_error_view'
handle403 = 'blog.views.permission_denied_view'
urlpatterns = [
                  url(r'^admin/', admin_site.urls),
                  url(r'', include('blog.urls', namespace='blog')),
                  url(r'mdeditor/', include('mdeditor.urls')),
                  url(r'', include('comments.urls', namespace='comment')),
                  url(r'', include('accounts.urls', namespace='account')),
                  url(r'', include('oauth.urls', namespace='oauth')),
                  url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
                      name='django.contrib.sitemaps.views.sitemap'),
                  url(r'^feed/$', DjangoBlogFeed()),

                  url(r'^rss/$', DjangoBlogFeed()),