Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Commit

Permalink
Starting a refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsackett committed Jun 8, 2009
1 parent fe04262 commit 1acad95
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
36 changes: 36 additions & 0 deletions post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'''
post.py
copyright 2009 j.c.sackett
Defines a post object which contains the file information of the base text file and
converts it into an html post.
'''
from jinja2 import Environment, PackageLoader
import markdown2
import os

ENV = Environment(loader=PackageLoader('puffin', 'templates'))

class post:
def __init__(self, file_path, dest):
self.read, self.write = self.build_paths(file_path)
self.title = self.make_title(file_path)
self.content =

def build_paths(self, file_path):
r = file_path
w = file_path.replace(dest, '').replace('//', '/').replace('.txt', '.html')d
return r,w

def make_title(self, file_path):
return os.path.split(file_path)[-1].split('.')[0].replace('_', ' ')

def make_url(self):
if self.write_path.startswith('/'):
return self.write_path[1:]
else:
return self.write_path

def build_page(self):
pass

30 changes: 8 additions & 22 deletions puffin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,13 @@
written by j.c.sackett on 2.19.2009
"""
from optparse import OptionParser
from jinja2 import Environment, PackageLoader

import sys
import os
import markdown2
import subprocess

MAJOR = 0
MINOR = 1

ENV = Environment(loader=PackageLoader('puffin', 'templates'))

class post:
def __init__(self, file_path, dest):
self.read_path = file_path
self.write_path = file_path.replace(dest, '').replace('//', '/').replace('.txt', '.html')
self.title = os.path.split(file_path)[-1].split('.')[0].replace('_', ' ')
if self.write_path.startswith('/'):
self.url = self.write_path[1:]
else:
self.url = self.write_path
self.content = ''

def init_posts(output_dir):
try:
os.mkdir(output_dir)
except OSError:
print 'Post directory already exists. Use -r or --rebuild to force overwrite.'
MINOR = 2

def get_files(dest):
files = []
Expand All @@ -44,6 +23,13 @@ def get_files(dest):
f = post(path,dest)
files.append(f)
return files

def init_posts(output_dir):
try:
os.mkdir(output_dir)
except OSError:
print 'Post directory already exists. Use -r or --rebuild to force overwrite.'


def process_files(file_list, output_dir):
print 'Processing markdown for %s...' % [f.read_path for f in file_list]
Expand Down

0 comments on commit 1acad95

Please sign in to comment.