Skip to content

Commit

Permalink
meta data added in new_base.html
Browse files Browse the repository at this point in the history
meta data added in new_base.html
  • Loading branch information
Anjaneyulu authored and ashwin31 committed Jul 20, 2016
1 parent 3b5661b commit 8243be8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
16 changes: 11 additions & 5 deletions django_blog_it/django_blog_it/templates/new_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
<meta charset="UTF-8">
<title>Blog - {% block title %}Home{% endblock %}</title>
{% block description %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="Home - micro-blog - simple blog package - MicroPyramid." />
<meta property="og:description" content="micro-blog - simple blog package - MicroPyramid." />
<meta name="description" content="micro-blog - simple blog package - MicroPyramid." />
<meta name="keywords" content="simple" />
<link rel="canonical" href="{{ request.build_absolute_uri }}"/>
<meta property="og:url" content="{{ request.build_absolute_uri }}" />
<meta property="og:image" content="{{ og_image }}" />
<meta property="og:title" content="{{ title }}" />
<meta property="og:description" content="{{ description|truncatechars:160 }}" />

<meta name="title" content="{{ title }}" />
<meta name="description" content="{{ description|truncatechars:160 }}" />
<meta name="keywords" content="{{ keywords }}" />
<meta name="author" content="{{ author }}" />
<meta name="robots" content="index, follow">
{% endblock %}

{% load staticfiles %}
Expand Down
6 changes: 6 additions & 0 deletions django_blog_it/django_blog_it/templates/posts/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
</div>
</div>
{% endfor %}
{% if GOOGLE_CAPTCHA_SITE_KEY %}
<div id="id_captcha" class="g-recaptcha" data-sitekey="{{GOOGLE_CAPTCHA_SITE_KEY}}"></div>
{% endif %}
</div>
<br clear="all">
<div class=" col-md-12 buttons_row text-left">
Expand All @@ -47,6 +50,9 @@
<!-- blog_detail_container ends here -->
{% endblock %}
{% block js_script %}
{% if GOOGLE_CAPTCHA_SITE_KEY %}
<script src='https://www.google.com/recaptcha/api.js'></script>
{% endif %}
<script>
$( document ).ready(function() {
$('#myModal').modal('hide');
Expand Down
11 changes: 11 additions & 0 deletions django_blog_it/posts/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import requests
import json
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
Expand Down Expand Up @@ -163,6 +165,13 @@ def contact_us(request):
if request.POST:
form = ContactForm(request.POST)
if form.is_valid():
if os.getenv("GOOGLE_CAPTCHA_SECRET_KEY"):
payload = {'secret': os.getenv("GOOGLE_CAPTCHA_SECRET_KEY"),
'response': request.POST.get('g-recaptcha-response'),
'remoteip': request.META.get('REMOTE_ADDR')}
r = requests.get('https://www.google.com/recaptcha/api/siteverify', params=payload)
if not json.loads(r.text)['success']:
return JsonResponse({'error': True, 'response': {"captcha": "Invalid captcha"}})
# email sending
messages.success(
request, 'Successfully Sent your contact us details.')
Expand All @@ -177,5 +186,7 @@ def contact_us(request):
"keywords": settings.BLOG_KEYWORDS,
"author": settings.BLOG_AUTHOR,
"contact_form": form}
if os.getenv("GOOGLE_CAPTCHA_SITE_KEY"):
context.update({"GOOGLE_CAPTCHA_SITE_KEY": os.getenv("GOOGLE_CAPTCHA_SITE_KEY")})
context.update(categories_tags_lists())
return render(request, 'posts/contact.html', context)

0 comments on commit 8243be8

Please sign in to comment.