Browse files

Add support for publishing from

  • Loading branch information...
thallada committed Oct 4, 2013
1 parent 3b0ebc3 commit c4694a6669dbc7b79a5bff3fb818a682ecacffbb
Showing with 29 additions and 1 deletion.
  1. +2 −0 blog/
  2. +24 −1 blog/
  3. +3 −0 personalsite/
@@ -17,6 +17,8 @@
url(r'^ajax/get_comment/$', 'get_comment', name='get_comment'),
url(r'^ajax/flag_comment/$', 'flag_comment', name='flag_comment'),
url(r'^ajax/publish_draft_doc/' + settings.DRAFT_PUBLISH_KEY + '/$',
'publish_draft_doc', name='publish_draft'),
url(r'^blog/tag/(?P<tags>[^\.]+)/$', 'index', name='tags'),
url(r'^blog/(?P<slug>[^\.]+)/$', 'detail', name='detail'),
url(r'^blog/$', 'index', name='index'),
@@ -1,10 +1,11 @@
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from django.shortcuts import render_to_response, get_object_or_404, redirect
from blog.models import Entry, Project
from django.contrib.comments import Comment
from django.conf import settings
from django.http import HttpResponse
from django.views.decorators.http import require_POST
from django.views.decorators.csrf import csrf_exempt
from django.contrib.comments.views.comments import CommentPostBadRequest
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.utils.html import escape
@@ -14,6 +15,7 @@
from django.contrib.auth.models import User
from django.http import Http404
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.template.defaultfilters import slugify
import json
import markdown_deux

@@ -239,3 +241,24 @@ def flag_comment(request):
raise Http404

def publish_draft_doc(request):
# WebHook for publishing a blog entry from
if 'payload' in request.POST:
payload = json.loads(request.POST['payload'])
# construct new blog entry from draft json data
# TODO: figure out a way to do tags
new_post = Entry.objects.create(title=payload['name'],
new_post.publish() # make public
response = HttpResponse()
# Tell draft where it was posted
response['Location'] = new_post.get_absolute_url()
return response
# Got a bad post
raise Http404
@@ -204,3 +204,6 @@

#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# The endpoint of the API url used to post entries from

0 comments on commit c4694a6

Please sign in to comment.