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

Commit

Permalink
Add user defined url patterns.
Browse files Browse the repository at this point in the history
  • Loading branch information
mythmon committed Jun 9, 2011
1 parent 07dfcb4 commit 3022b40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions wok/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Engine(object):
'output_dir' : 'output',
'media_dir' : 'media',
'site_title' : 'Some random Wok site',
'url_pattern' : '/{category}/{slug}.html',
}

def __init__(self, output_lvl = 1):
Expand Down
13 changes: 6 additions & 7 deletions wok/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ def build_meta(self):
# Guarantee: tags exists, is a list

if not 'url' in self.meta:
# /category/subcategory/slug.html
util.out.debug('building the url', self.categories)
self.meta['url'] = '/'
for cat in self.category:
self.meta['url']= os.path.join(self.meta['url'], cat)
self.meta['url'] = os.path.join(self.meta['url'],
self.slug + '.html')
parts = {
'slug' : self.slug,
'category' : '/'.join(self.category),
}
self.meta['url'] = self.options['url_pattern'].format(**parts);

def render(self, templ_vars=None):
"""
Expand Down Expand Up @@ -193,6 +191,7 @@ def write(self):
# Probably that the dir already exists, so thats ok.
# TODO: double check this. Permission errors are something to worry
# about
util.out.info('Page.write', 'writing to {0}'.format(path))

f = open(path, 'w')
f.write(self.html)
Expand Down

0 comments on commit 3022b40

Please sign in to comment.