Skip to content

Commit

Permalink
Merge pull request #68 from AnjaneyuluBatta505/schema-tags#39
Browse files Browse the repository at this point in the history
schema tags breadcrumbs, blog article, author added
  • Loading branch information
chaitu210 committed Jul 18, 2016
2 parents b43a86a + 8d49655 commit 6bd503a
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 12 deletions.
37 changes: 32 additions & 5 deletions django_blog_it/django_blog_it/templates/posts/blog_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,47 @@
{% block title %} {{ blog_name.title }} {% endblock %}
{% block blog_content %}
<div class="row col-sm-12 col-md-9 blog-container-left">
<div class="blogs">
<!-- breadcrumbs-schema -->
<ol itemscope itemtype="http://schema.org/BreadcrumbList" class="breadcrumb">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="name">Blog</span></a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="{% url 'selected_category' category_slug=blog_name.category.slug %}">
<span itemprop="name"> {{ blog_name.category }}</span></a>
<meta itemprop="position" content="2" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="">
<span itemprop="name"> {{ blog_name.title }}</span></a>
<meta itemprop="position" content="3" />
</li>
</ol>
<!-- end -->
<div class="blogs" itemtype="http://schema.org/BlogPosting">
<ul class="blog-list">
<table align="center" class="table table-bordered">
<thead>
<th>
Title: {{ blog_name.title }}
<span itemprop="blog-article">Title: <span itemprop="name headline">{{ blog_name.title }}</span> </span>
</th>
</thead>
<tbody>
<tr>
<td><strong>Author</strong>: {{ blog_name.user }}</td>
<td>
<span itemprop="author" itemtype="http://schema.org/Person">
<strong>Author</strong>:
<span itemprop="name">{{ blog_name.user }}</span>
</span>
</td>
</tr>
<tr>
<td><strong>Content</strong>: {{ blog_name.content|safe }}</td>
<td><strong>Content</strong>: <div class="content" itemprop="articleBody">{{ blog_name.content|safe }}</div></td>
</tr>
<tr>
<td class="widget tags"><strong>Tags</strong>:
Expand All @@ -26,7 +53,7 @@
</td>
</tr>
<tr>
<td><strong>Keywords</strong>: {{ blog_name.keywords|safe }}</td>
<td><strong>Keywords</strong>: <div itemprop="keywords" itemtype="http://schema.org/keywords">{{ blog_name.keywords|safe }}</div></td>
</tr>
</tbody>
</table>
Expand Down
65 changes: 61 additions & 4 deletions django_blog_it/django_blog_it/templates/posts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,77 @@
{% load paginate %}
{% load blog_tags %}
{% block blog_content %}

<!-- breadcrumbs-schema -->
<ol itemscope itemtype="http://schema.org/BreadcrumbList" class="breadcrumb">
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="name">Blog</span></a>
<meta itemprop="position" content="1" />
</li>
{% if tag %}
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="name">Tag</span></a>
<meta itemprop="position" content="2" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="tag">{{ tag }}</span></a>
<meta itemprop="position" content="3" />
</li>
{% endif %}
{% if date %}
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="name">Archive</span></a>
<meta itemprop="position" content="2" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="month">{{ date|date:"F Y"}}</span></a>
<meta itemprop="position" content="3" />
</li>
{% endif %}
{% if category %}
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="/">
<span itemprop="name">Category</span></a>
<meta itemprop="position" content="2" />
</li>
<li itemprop="itemListElement" itemscope
itemtype="http://schema.org/ListItem">
<a itemprop="item" href="">
<span itemprop="name"> {{ category }}</span></a>
<meta itemprop="position" content="3" />
</li>
{% endif %}
</ol>
<!-- end -->
<div class="row col-sm-12 col-md-9 blog-container-left">
<div class="blogs">
<ul class="blog-list">
{% if blog_posts %}
{% paginate 5 blog_posts %}
{% for blog in blog_posts %}
<li class="list-item">
<li class="list-item" itemtype="http://schema.org/BlogPosting">
<div class="blog-left">
<h3 class="title" itemprop="headline"><a href="{% url 'blog_post_view' blog_slug=blog.slug %}">{{ blog }}</a></h3>
<h3 class="title" itemprop="name headline"><a href="{% url 'blog_post_view' blog_slug=blog.slug %}">{{ blog }}</a></h3>
</div>
<div class="desc">
<span> {{ blog.user|title }} | {{ blog.updated_on|date:"d F Y" }}</span>
<span>
<span itemprop="author" itemtype="http://schema.org/Person">{{ blog.user|title }} |</span>
<span itemprop="datePublished" itemtype="https://schema.org/datePublished"> {{ blog.updated_on|date:"d F Y" }}
</span>
</span>
<div class="content" itemprop="articleBody">
{{ blog.content|safe|truncatewords_html:50 }}
</div>
{% for tag in blog.tags.all %}
<span class="tags">
<a href="{% url 'selected_tag' tag_slug=tag.slug %}" ><i class="fa fa-tags"></i> {{ tag }}</a>
Expand Down
10 changes: 7 additions & 3 deletions django_blog_it/posts/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from django.shortcuts import render, get_list_or_404, get_object_or_404
from django_blog_it.django_blog_it.models import Post, Category, Tags, Page
from django.db.models import Count
Expand Down Expand Up @@ -39,29 +40,32 @@ def blog_post_view(request, blog_slug):


def selected_category(request, category_slug):
category = get_object_or_404(Category, slug=category_slug)
blog_posts = Post.objects.filter(category__slug=category_slug, category__is_active=True, status='Published')
context = list({'blog_posts': blog_posts}.items()) + list(categories_tags_lists().items())
return render(request, 'posts/index.html', context)
return render(request, 'posts/index.html', context + [("category", category)])


def selected_tag(request, tag_slug):
tag = get_object_or_404(Tags, slug=tag_slug)
blog_posts = get_list_or_404(
Post, tags__slug=tag_slug,
status='Published', category__is_active=True
)
context = list({'blog_posts': blog_posts}.items()) + list(categories_tags_lists().items())
context = list({'blog_posts': blog_posts}.items()) + list(categories_tags_lists().items()) + [("tag", tag)]
return render(request, 'posts/index.html', context)


def archive_posts(request, year, month):
date = datetime(int(year), int(month), 1)
blog_posts = Post.objects.filter(
category__is_active=True,
status="Published",
updated_on__year=year,
updated_on__month=month
).order_by('-updated_on')
blog_posts = [post for post in blog_posts if post.category.is_active]
context = list({'blog_posts': blog_posts}.items()) + list(categories_tags_lists().items())
context = list({'blog_posts': blog_posts}.items()) + list(categories_tags_lists().items()) + [("date", date)]
return render(request, 'posts/index.html', context)


Expand Down

0 comments on commit 6bd503a

Please sign in to comment.