# Path: july/blog/models.py
# class Blog(models.Model):
#     title = models.CharField(max_length=100, unique=True)
#     user = models.ForeignKey(settings.AUTH_USER_MODEL)
#     slug = models.SlugField(max_length=100, unique=True)
#     body = models.TextField()
#     posted = models.DateTimeField(db_index=True)
#     active = models.BooleanField(default=True)
#     category = models.ForeignKey('blog.Category')
# 
#     def __unicode__(self):
#         return '%s' % self.title
# 
#     @permalink
#     def get_absolute_url(self):
#         return ('view_blog_post', None, {'slug': self.slug})


from markdown import markdown
from django import template
from django.template.defaultfilters import stringfilter
from django.utils.encoding import force_unicode
from django.utils.safestring import mark_safe
from july.blog.models import Blog



register = template.Library()


@register.filter(is_safe=True)
@stringfilter
def markup(value):
    extensions = ["markdown.extensions.nl2br"]
    val = force_unicode(value)
    html = markdown(val, extensions=extensions, enable_attributes=False)
    return mark_safe(html)


@register.inclusion_tag('blog/blog_roll.html', takes_context=True)
def blog_roll(context):
    return {
        'blog': context['blog'],

# Path: july/blog/models.py
# class Blog(models.Model):
#     title = models.CharField(max_length=100, unique=True)
#     user = models.ForeignKey(settings.AUTH_USER_MODEL)
#     slug = models.SlugField(max_length=100, unique=True)
#     body = models.TextField()
#     posted = models.DateTimeField(db_index=True)
#     active = models.BooleanField(default=True)
#     category = models.ForeignKey('blog.Category')
# 
#     def __unicode__(self):
#         return '%s' % self.title
# 
#     @permalink
#     def get_absolute_url(self):
#         return ('view_blog_post', None, {'slug': self.slug})


# Path: july/templatetags/markup.py
from markdown import markdown
from django import template
from django.template.defaultfilters import stringfilter
from django.utils.encoding import force_unicode
from django.utils.safestring import mark_safe
from july.blog.models import Blog




register = template.Library()


@register.filter(is_safe=True)
@stringfilter
def markup(value):
    extensions = ["markdown.extensions.nl2br"]
    val = force_unicode(value)
    html = markdown(val, extensions=extensions, enable_attributes=False)
    return mark_safe(html)


@register.inclusion_tag('blog/blog_roll.html', takes_context=True)
def blog_roll(context):
    return {
        'blog': context['blog'],

        'posts': Blog.objects.all(),