Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: aef6f13794
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (38 sloc) 1.121 kb
#!/usr/bin/env python
Post a single unindexed page at /draft/title, where the title and body of the
page is extracted from the HTML markup of the given file.
Usage: draft [-l] filepath
By default, requests are made to {APPID}
The script will print out the URL of the draft page if success.
-l make requests to to localhost:8080
import BeautifulSoup
import datetime
import getopt
import sys
import os
if sys.argv[1] == '-l':
host = 'localhost:8080'
filename = sys.argv[2]
host = None
filename = sys.argv[1]
import remote
import config
import models
import static
import utils
soup = BeautifulSoup.BeautifulSoup(open(filename).read())
title = unicode(soup.title.string)
post = models.BlogPost(
body=u''.join(unicode(s) for s in soup.body.contents if s),
path = '/draft/' + utils.slugify(title)
rendered = utils.render_template("draft.html", {'post': post})
static.set(path, rendered, config.html_mime_type, indexed=False)
print 'http://' + (host or (remote.APPID + '')) + path
Jump to Line
Something went wrong with that request. Please try again.