# Path: floyd/controllers/controllers.py
# class BaseController(object):
# def index():
# def TemplateVars(vars):
# def RenderPosts(posts, outputdir):  
# def post(post, route):
# def page(post, route):
# def index():
# def archive():
# def feed():
# def render(template_name, template_path, template_variables, output_file):
# 
# Path: floyd/core/multiopt.py
# class CommandError(Exception): pass


import os
import sys
import floyd.db
import floyd.templating.jinja
from floyd.controllers import controllers
from floyd.core.multiopt import CommandError
  from floyd.core.server import Server, ThreadedHTTPServer, StaticRequestHandler
  if not os.path.isdir(path_source):
    raise CommandError('Not a valid source directory: %s' % path_source)
  
  if not os.path.isdir(path_template):
    raise CommandError('Not a valid template directory or template: %s' % path_templates)
    
  if not os.path.isdir(path_output):
    try:
      fs = os.stat(path_output)
    except OSError:
      os.mkdir(path_output)
      create_dest_dir = True


  floyd.templating.jinja.setup(path_template)
  floyd.db.setup(path_source)

  posts = floyd.db.Query('Posts').filter(post_type='post').filter(post_status='published').fetch(100)
  drafts = floyd.db.Query('Posts').filter(post_type='post').filter(post_status='draft').fetch(100)
  pages = floyd.db.Query('Posts').filter(post_type='page').fetch(100)
  
  print "posts:"
  print posts
  
  print "drafts:"
  print drafts
  
  print "pages:"
  print pages


# Path: floyd/controllers/controllers.py
# class BaseController(object):
# def index():
# def TemplateVars(vars):
# def RenderPosts(posts, outputdir):  
# def post(post, route):
# def page(post, route):
# def index():
# def archive():
# def feed():
# def render(template_name, template_path, template_variables, output_file):
# 
# Path: floyd/core/multiopt.py
# class CommandError(Exception): pass


# Path: floyd/core/commands.py
import os
import sys
import floyd.db
import floyd.templating.jinja
from floyd.controllers import controllers
from floyd.core.multiopt import CommandError
  from floyd.core.server import Server, ThreadedHTTPServer, StaticRequestHandler

  if not os.path.isdir(path_source):
    raise CommandError('Not a valid source directory: %s' % path_source)
  
  if not os.path.isdir(path_template):
    raise CommandError('Not a valid template directory or template: %s' % path_templates)
    
  if not os.path.isdir(path_output):
    try:
      fs = os.stat(path_output)
    except OSError:
      os.mkdir(path_output)
      create_dest_dir = True


  floyd.templating.jinja.setup(path_template)
  floyd.db.setup(path_source)

  posts = floyd.db.Query('Posts').filter(post_type='post').filter(post_status='published').fetch(100)
  drafts = floyd.db.Query('Posts').filter(post_type='post').filter(post_status='draft').fetch(100)
  pages = floyd.db.Query('Posts').filter(post_type='page').fetch(100)
  
  print "posts:"
  print posts
  
  print "drafts:"
  print drafts
  
  print "pages:"
  print pages


  controllers.RenderPosts(posts, path_output)