# Path: blog/models.py
# class Post(models.Model):
#     """文章的数据模型"""
#     title = models.CharField(max_length=128)
#     slug = models.SlugField(unique=True)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     modification_time = models.DateTimeField(auto_now=True)
#     body_markdown = models.TextField()
#     body_html = models.TextField()
#     author = models.ForeignKey('auth.User')
#     categories = models.ManyToManyField(Category)
#     tags = models.ManyToManyField(Tag)
# 
#     def save(self, force_insert=False, force_update=False, using=None,
#              update_fields=None):
#         super(Post, self).save(force_insert, force_update, using, update_fields)
#         try:
#             ping_google()
#         except Exception:
#             pass
# 
#     def get_absolute_url(self):
#         from django.core.urlresolvers import reverse
#         return reverse('post', args=[self.slug])
# 
#     def __str__(self):
#         return self.title


from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
from blog.models import Post
"""
这个文件定义了RSS输出。
"""

class PostFeed(Feed):
    """
    定义文章 ATOM 输出的类
    """
    feed_type = Atom1Feed
    title = "学习笔记"
    link = "/"
    subtitle = "恩岩的学习笔记"

    def items(self):

# Path: blog/models.py
# class Post(models.Model):
#     """文章的数据模型"""
#     title = models.CharField(max_length=128)
#     slug = models.SlugField(unique=True)
#     creation_time = models.DateTimeField(auto_now_add=True)
#     modification_time = models.DateTimeField(auto_now=True)
#     body_markdown = models.TextField()
#     body_html = models.TextField()
#     author = models.ForeignKey('auth.User')
#     categories = models.ManyToManyField(Category)
#     tags = models.ManyToManyField(Tag)
# 
#     def save(self, force_insert=False, force_update=False, using=None,
#              update_fields=None):
#         super(Post, self).save(force_insert, force_update, using, update_fields)
#         try:
#             ping_google()
#         except Exception:
#             pass
# 
#     def get_absolute_url(self):
#         from django.core.urlresolvers import reverse
#         return reverse('post', args=[self.slug])
# 
#     def __str__(self):
#         return self.title


# Path: blog/feeds.py
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
from blog.models import Post

"""
这个文件定义了RSS输出。
"""

class PostFeed(Feed):
    """
    定义文章 ATOM 输出的类
    """
    feed_type = Atom1Feed
    title = "学习笔记"
    link = "/"
    subtitle = "恩岩的学习笔记"

    def items(self):

        return Post.objects.order_by('-id')