1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#compiler-settings
useAutocalling=False
useLegacyImportMode=False
#end compiler-settings
#import os
#From Cheetah.Template import Template
#from Cheetah.Filters import Markdown
#import WikiRoot
#extends WikiRoot.WikiRoot
#attr PathPrefix = '../'
#attr ExecuteContentPath = 'recipes/content/'
#attr HyperlinkContentPath = 'content/'
#def pagename()
#return 'Recipes'
#end def
#def content()
#transform Markdown
Cheetah Recipes
===============
Here are the available recipes thus far:
#for dirpath, dirnames, filenames in $os.walk($ExecuteContentPath)
#for file in filenames
#if file.endswith('.markdown') and $generateRecipePage($file)
* [${file.replace('_', ' ').replace('.markdown', '')}](${HyperlinkContentPath}${file.replace('.markdown', '.html')})
#end if
#end for
#end for
If you're really hungry for some Cheetah recipies, you can check out the
out-of-date [Cheetah recipes page](http://wiki.cheetahtemplate.org/cheetah-recipes.html?)
from the old Wiki
#end def
#def generateRecipePage(filepath)
## Open and read in the .markdown document
#set fd = open('%s%s' % ($ExecuteContentPath, filepath), 'r')
#set content = fd.readlines()
#silent fd.close()
#set tmpl = Template('''
#from Cheetah.Filters import Markdown
#import WikiRoot
#extends WikiRoot.WikiRoot
#attr PathPrefix = '../../'
#def pagename()
#return $PageName
#end def
#def content
#transform Markdown
%s
#end def
''' % (''.join(content)),
searchList=[{'PageName' : filepath.replace('.markdown', '')}])
## Write the results of the template's execution to a .html file
#set fd = open('%s%s' % ($ExecuteContentPath, filepath.replace('.markdown', '.html')), 'w')
#silent fd.write(unicode(tmpl).encode('utf-8'))
#silent fd.close()
#return True
#end def
|