Exemplo n.º 1
0
 def item_description(self, item):
     bbcode_parser = BBCodeParser(item.content)
     if len(bbcode_parser.get_all_paragraphs()) > 0:
         s = bbcode_parser.remove_bbcode(bbcode_parser.get_all_paragraphs()[0])
     else:
         s = 'This article doesn\'t have description.'
     return s
Exemplo n.º 2
0
def content_get_info(s):
    """Remove all media tags"""
    bbcode_to_html = BBCodeParser(s)
    info_tags = [tag for tag in bbcode_to_html.bbcode_rules.iterkeys() if tag not in bbcode_to_html.get_media_tags()]
    content = bbcode_to_html.get_html_from_bbcode_tags(bbcode_to_html.escape_html(), 
                                                       True, 
                                                       *info_tags)
    return content    
Exemplo n.º 3
0
 def item_description(self, item):
     bbcode_parser = BBCodeParser(item.content)
     if len(bbcode_parser.get_all_paragraphs()) > 0:
         s = bbcode_parser.remove_bbcode(
             bbcode_parser.get_all_paragraphs()[0])
     else:
         s = 'This article doesn\'t have description.'
     return s
Exemplo n.º 4
0
def content_get_info(s):
    """Remove all media tags"""
    bbcode_to_html = BBCodeParser(s)
    info_tags = [
        tag for tag in bbcode_to_html.bbcode_rules.iterkeys()
        if tag not in bbcode_to_html.get_media_tags()
    ]
    content = bbcode_to_html.get_html_from_bbcode_tags(
        bbcode_to_html.escape_html(), True, *info_tags)
    return content
Exemplo n.º 5
0
def about(request):

    user = user_get_owner()
    blog = blog_get_or_create(user)

    resume = BBCodeParser(user.get_profile().resume)
    resume = resume.bbcode_to_html(resume.escape_html())

    return render_to_response('itsme/about.html', {
        'user': user,
        'blog': blog,
        'resume': resume,
        'nav_active': 'about',
    },
                              context_instance=RequestContext(request))
Exemplo n.º 6
0
def about(request):
    
    user = user_get_owner()
    blog = blog_get_or_create(user)
    
    resume = BBCodeParser(user.get_profile().resume)
    resume = resume.bbcode_to_html(resume.escape_html())
    
    return render_to_response('itsme/about.html',
                              {
                               'user': user,
                               'blog': blog,
                               'resume': resume,
                               'nav_active': 'about',
                               },
                              context_instance=RequestContext(request))
Exemplo n.º 7
0
def post_view(request, slug):

    try:
        post = Post.objects.get(slug__exact=slug, status__exact='publish')
    except ObjectDoesNotExist:
        raise Http404

    user = user_get_owner()
    blog = blog_get_or_create(user)

    post_content = BBCodeParser(post.content)
    content = post_content.bbcode_to_html(post_content.escape_html())

    previous_post = Post.objects.exclude(slug__exact=post.slug).filter(
        date__lte=post.date).order_by('-date', 'title').count()
    if previous_post > 0:
        previous_post = Post.objects.exclude(slug__exact=post.slug).filter(
            date__lte=post.date).order_by('-date', 'title')[0]
    else:
        previous_post = False
    next_post = Post.objects.exclude(slug__exact=post.slug).filter(
        date__gte=post.date).order_by('date', 'title').count()
    if next_post > 0:
        next_post = Post.objects.exclude(slug__exact=post.slug).filter(
            date__gte=post.date).order_by('date', 'title')[0]
    else:
        next_post = False

    return render_to_response('itsme/post_view.html', {
        'post': post,
        'user': user,
        'blog': blog,
        'post_content': post_content,
        'content': content,
        'previous_post': previous_post,
        'next_post': next_post,
    },
                              context_instance=RequestContext(request))
Exemplo n.º 8
0
def post_view(request, slug):
    
    try:
        post = Post.objects.get(slug__exact=slug,
                                status__exact='publish')
    except ObjectDoesNotExist:
        raise Http404
    
    user = user_get_owner()
    blog = blog_get_or_create(user)
    
    post_content = BBCodeParser(post.content)
    content = post_content.bbcode_to_html(post_content.escape_html())
    
    previous_post = Post.objects.exclude(slug__exact=post.slug).filter(date__lte=post.date).order_by('-date', 'title').count()
    if previous_post > 0:
        previous_post = Post.objects.exclude(slug__exact=post.slug).filter(date__lte=post.date).order_by('-date', 'title')[0]
    else:
        previous_post = False
    next_post = Post.objects.exclude(slug__exact=post.slug).filter(date__gte=post.date).order_by('date', 'title').count()
    if next_post > 0:
        next_post = Post.objects.exclude(slug__exact=post.slug).filter(date__gte=post.date).order_by('date', 'title')[0]
    else:
        next_post = False
    
    return render_to_response('itsme/post_view.html',
                              {
                               'post': post,
                               'user': user,
                               'blog': blog,
                               'post_content': post_content,
                               'content': content,
                               'previous_post': previous_post,
                               'next_post': next_post,
                               },
                              context_instance=RequestContext(request))
Exemplo n.º 9
0
def post_get_description(s):
    """Return description of a content."""
    content_bbcode = BBCodeParser(s)
    if len(content_bbcode.get_all_paragraphs()) > 0:
        content_bbcode = content_bbcode.bbcode_to_html(content_bbcode.get_all_paragraphs()[0])
        content_bbcode = '<p>' + content_bbcode + '</p>'
    elif len(content_bbcode.get_all_pictures()) > 0:
        content_bbcode = content_bbcode.get_all_pictures()[0]
        content_bbcode = '<p>' + '<img src="' + content_bbcode[1] + '" alt="' + content_bbcode[0] + '">' + '</p>'
    elif len(content_bbcode.get_all_youtube()) > 0:
        video_id = content_bbcode.get_all_youtube()[0]
        content_bbcode = '<div class="video-wrapper"><div class="video-container">'
        content_bbcode += '<iframe src="http://www.youtube.com/embed/' + video_id
        content_bbcode += '" width="600" height="361" frameborder="0" allowFullScreen></iframe>'
        content_bbcode += '</div></div>'
    elif len(content_bbcode.get_all_vimeo()) > 0:
        video_id = content_bbcode.get_all_vimeo()[0]
        content_bbcode = '<div class="video-wrapper"><div class="video-container">'
        content_bbcode += '<iframe src="http://player.vimeo.com/video/' + video_id
        content_bbcode += '?byline=0&amp;portrait=0" width="600" height="361" frameborder="0" allowFullScreen></iframe>'
        content_bbcode += '</div></div>'
    else:
        content_bbcode = '<p><em>There isn\'t description for this blog post.</em></p>'
    return content_bbcode
Exemplo n.º 10
0
def remove_bbcode(s):
    content_bbcode = BBCodeParser(s)
    return content_bbcode.remove_bbcode(s)
Exemplo n.º 11
0
def content_get_media(s):
    bbcode_to_html = BBCodeParser(s)
    content = bbcode_to_html.get_html_from_bbcode_tags(
        bbcode_to_html.escape_html(), True, *bbcode_to_html.get_media_tags())
    return content
Exemplo n.º 12
0
def post_get_description(s):
    """Return description of a content."""
    content_bbcode = BBCodeParser(s)
    if len(content_bbcode.get_all_paragraphs()) > 0:
        content_bbcode = content_bbcode.bbcode_to_html(
            content_bbcode.get_all_paragraphs()[0])
        content_bbcode = '<p>' + content_bbcode + '</p>'
    elif len(content_bbcode.get_all_pictures()) > 0:
        content_bbcode = content_bbcode.get_all_pictures()[0]
        content_bbcode = '<p>' + '<img src="' + content_bbcode[
            1] + '" alt="' + content_bbcode[0] + '">' + '</p>'
    elif len(content_bbcode.get_all_youtube()) > 0:
        video_id = content_bbcode.get_all_youtube()[0]
        content_bbcode = '<div class="video-wrapper"><div class="video-container">'
        content_bbcode += '<iframe src="http://www.youtube.com/embed/' + video_id
        content_bbcode += '" width="600" height="361" frameborder="0" allowFullScreen></iframe>'
        content_bbcode += '</div></div>'
    elif len(content_bbcode.get_all_vimeo()) > 0:
        video_id = content_bbcode.get_all_vimeo()[0]
        content_bbcode = '<div class="video-wrapper"><div class="video-container">'
        content_bbcode += '<iframe src="http://player.vimeo.com/video/' + video_id
        content_bbcode += '?byline=0&amp;portrait=0" width="600" height="361" frameborder="0" allowFullScreen></iframe>'
        content_bbcode += '</div></div>'
    else:
        content_bbcode = '<p><em>There isn\'t description for this blog post.</em></p>'
    return content_bbcode
Exemplo n.º 13
0
def remove_bbcode(s):
    content_bbcode = BBCodeParser(s)
    return content_bbcode.remove_bbcode(s)
Exemplo n.º 14
0
def content_get_media(s):
    bbcode_to_html = BBCodeParser(s)
    content = bbcode_to_html.get_html_from_bbcode_tags(bbcode_to_html.escape_html(), 
                                                       True,
                                                       *bbcode_to_html.get_media_tags())
    return content