Remove markdown support from app engine blog demo.

This commit is contained in:
Ben Darnell 2013-03-03 11:16:07 -05:00
parent b00167b9d6
commit 19f7351d14
4 changed files with 11 additions and 1889 deletions

View File

@ -15,9 +15,9 @@
# under the License.
import functools
import markdown
import os.path
import re
import tornado.escape
import tornado.web
import tornado.wsgi
import unicodedata
@ -31,7 +31,7 @@ class Entry(db.Model):
author = db.UserProperty()
title = db.StringProperty(required=True)
slug = db.StringProperty(required=True)
markdown = db.TextProperty(required=True)
body_source = db.TextProperty(required=True)
html = db.TextProperty(required=True)
published = db.DateTimeProperty(auto_now_add=True)
updated = db.DateTimeProperty(auto_now=True)
@ -116,8 +116,9 @@ class ComposeHandler(BaseHandler):
if key:
entry = Entry.get(key)
entry.title = self.get_argument("title")
entry.markdown = self.get_argument("markdown")
entry.html = markdown.markdown(self.get_argument("markdown"))
entry.body_source = self.get_argument("body_source")
entry.html = tornado.escape.linkify(
self.get_argument("body_source"))
else:
title = self.get_argument("title")
slug = unicodedata.normalize("NFKD", title).encode(
@ -134,8 +135,8 @@ class ComposeHandler(BaseHandler):
author=self.current_user,
title=title,
slug=slug,
markdown=self.get_argument("markdown"),
html=markdown.markdown(self.get_argument("markdown")),
body_source=self.get_argument("body_source"),
html=tornado.escape.linkify(self.get_argument("body_source")),
)
entry.put()
self.redirect("/entry/" + entry.slug)

File diff suppressed because it is too large Load Diff

View File

@ -143,11 +143,11 @@ a code {
}
.compose .title,
.compose .markdown {
.compose .body_source {
width: 100%;
}
.compose .markdown {
.compose .body_source {
height: 500px;
line-height: 16pt;
}

View File

@ -3,9 +3,8 @@
{% block body %}
<form action="{{ request.path }}" method="post" class="compose">
<div style="margin-bottom:5px"><input name="title" type="text" class="title" value="{{ escape(entry.title) if entry else "" }}"/></div>
<div style="margin-bottom:5px"><textarea name="markdown" rows="30" cols="40" class="markdown">{{ escape(entry.markdown) if entry else "" }}</textarea></div>
<div style="margin-bottom:5px"><textarea name="body_source" rows="30" cols="40" class="body_source">{{ escape(entry.body_source) if entry else "" }}</textarea></div>
<div>
<div style="float:right"><a href="http://daringfireball.net/projects/markdown/syntax">{{ _("Syntax documentation") }}</a></div>
<input type="submit" value="{{ _("Save changes") if entry else _("Publish post") }}" class="submit"/>
&nbsp;<a href="{{ "/entry/" + entry.slug if entry else "/" }}">{{ _("Cancel") }}</a>
</div>
@ -24,7 +23,7 @@
$(function() {
$("input[name=title]").select();
$("form.compose").submit(function() {
var required = ["title", "markdown"];
var required = ["title", "body_source"];
var form = $(this).get(0);
for (var i = 0; i < required.length; i++) {
if (!form[required[i]].value) {
@ -39,4 +38,3 @@
//]]>
</script>
{% end %}