Source

LazyBobo / lazybobo / __init__.py

from couchdbkit.client import Server
from couchdbkit.session import create_session
from jinja2 import Environment, PackageLoader
import oembed
from couchdbkit.loaders import FileSystemDocsLoader
import os


# server object
server = Server()

 # create database
try:
    server.create_db("tumblog")
except:
    pass

# open a database session
db = create_session(server, "tumblog")


#sync up design docs
loader = FileSystemDocsLoader(os.path.join(__path__[0], 'dbdocs/_design'))
loader.sync(db, verbose=True)

#Setup the template loader
templates = Environment(loader=PackageLoader('lazybobo', 'templates'))

#Prime oembed with the oohembed endpoints
oembed_consumer = oembed.OEmbedConsumer()
oohembed_endpoint = oembed.OEmbedEndpoint('http://oohembed.com/oohembed/', ['http://*.5min.com/Video/*', 
                                                                   'http://*.amazon.(com|co.uk|de|ca|jp)/*/(gp/product|o/ASIN|obidos/ASIN|dp)/*',
                                                                   'http://*.collegehumor.com/video:*',
                                                                   'http://*.thedailyshow.com/video/*', 
                                                                   'http://*.flickr.com/photos/*',
                                                                   'http://*.funnyordie.com/videos/*',
                                                                   'http://video.google.com/videoplay?*',
                                                                   'http://www.hulu.com/watch/*',
                                                                   'http://*.livejournal.com/',
                                                                   'http://*.metacafe.com/watch/*',
                                                                   'http://*.metacafe.com/watch/*',
                                                                   'http://qik.com/*',
                                                                   'http://*.revision3.com/*',
                                                                   'http://*.slideshare.net/*',
                                                                   'http://*.twitpic.com/*',
                                                                   'http://twitter.com/*/statuses/*',
                                                                   'http://*.viddler.com/explore/*',
                                                                   'http://www.vimeo.com/* and http://www.vimeo.com/groups/*/videos/*',
                                                                   'http://*.wikipedia.org/wiki/*',
                                                                   'http://*.wordpress.com/yyyy/mm/dd/*',
                                                                   'http://*.youtube.com/watch*',
                                                                   ])

oembed_consumer.addEndpoint(oohembed_endpoint)