diff options
author | R. Tyler Ballance <tyler@slide.com> | 2009-05-25 15:43:51 -0700 |
---|---|---|
committer | R. Tyler Ballance <tyler@slide.com> | 2009-05-25 15:43:51 -0700 |
commit | b39834eef474839b7ee88cb0b3ce2a29e88bde47 (patch) | |
tree | e2b5168d8fa8ed62babcc4b3795cfecba17d49a2 | |
parent | ec0e92a966af321b3d4733ac9e0ac09f1fc66552 (diff) | |
download | python-cheetah-b39834eef474839b7ee88cb0b3ce2a29e88bde47.tar.gz |
Implement the automagical markdown->template generation
Signed-off-by: R. Tyler Ballance <tyler@slide.com>
-rw-r--r-- | recipes/content/Basic_Inheritance.html (renamed from recipes/content/General_Inheritance.html) | 7 | ||||
-rw-r--r-- | recipes/content/Basic_Inheritance.markdown | 3 | ||||
-rw-r--r-- | recipes/content/General_Inheritance.tmpl | 17 | ||||
-rw-r--r-- | recipes/index.html | 2 | ||||
-rw-r--r-- | recipes/index.tmpl | 39 |
5 files changed, 38 insertions, 30 deletions
diff --git a/recipes/content/General_Inheritance.html b/recipes/content/Basic_Inheritance.html index 6315148..6824280 100644 --- a/recipes/content/General_Inheritance.html +++ b/recipes/content/Basic_Inheritance.html @@ -4,7 +4,7 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> - <title>Community Cheetah - The Python-Powered Template Engine - Inheritance in Cheetah</title> + <title>Community Cheetah - The Python-Powered Template Engine - Basic_Inheritance</title> <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/> <meta name="keywords" content="cheetah, template engine, python, community cheetah, templating, markdown, markup, mod_python, webware"/> <meta name="googlebot" content="index, follow" /> @@ -351,7 +351,9 @@ border:dashed 1px #888; padding:6px; font-size:1.1em; color:#fff;} <div id="centercontent"> - <h1>Inheritance in Cheetah</h1> + <pre><code> Basic Inheritance +</code></pre> +<p>=================</p> </div> <div id="rightcontent"> @@ -391,4 +393,3 @@ border:dashed 1px #888; padding:6px; font-size:1.1em; color:#fff;} - diff --git a/recipes/content/Basic_Inheritance.markdown b/recipes/content/Basic_Inheritance.markdown new file mode 100644 index 0000000..98dfc79 --- /dev/null +++ b/recipes/content/Basic_Inheritance.markdown @@ -0,0 +1,3 @@ +Basic Inheritance +================= + diff --git a/recipes/content/General_Inheritance.tmpl b/recipes/content/General_Inheritance.tmpl deleted file mode 100644 index 2ddc880..0000000 --- a/recipes/content/General_Inheritance.tmpl +++ /dev/null @@ -1,17 +0,0 @@ -#from Cheetah.Filters import Markdown - -#import WikiRoot -#extends WikiRoot.WikiRoot - -#attr PathPrefix = '../../' - -#def pagename() - #return 'Inheritance in Cheetah' -#end def - -#def content() -#transform Markdown -Inheritance in Cheetah -=============== - -#end def diff --git a/recipes/index.html b/recipes/index.html index e41ad45..76f4942 100644 --- a/recipes/index.html +++ b/recipes/index.html @@ -354,7 +354,7 @@ border:dashed 1px #888; padding:6px; font-size:1.1em; color:#fff;} <h1>Cheetah Recipes</h1> <p>Here are the available recipes thus far:</p> <ul> -<li><a href="content/General_Inheritance.html">General Inheritance</a></li> +<li><a href="content/Basic_Inheritance.html">Basic Inheritance</a></li> </ul> <p>If you're really hungry for some Cheetah recipies, you can check out the out-of-date <a href="http://wiki.cheetahtemplate.org/cheetah-recipes.html">Cheetah recipes page</a> diff --git a/recipes/index.tmpl b/recipes/index.tmpl index 53c6639..cd068b5 100644 --- a/recipes/index.tmpl +++ b/recipes/index.tmpl @@ -1,10 +1,13 @@ #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' @@ -17,16 +20,10 @@ Cheetah Recipes Here are the available recipes thus far: -## A short note about BaseDirectory, when the HTML files are being generated, the -## "current working directory is the Git root (i.e. ../ from this file) -## -## When the page is being loaded however, the "current working directory" is the -## "recipes/" directory -#set $BaseDirectory = 'content/' -#for dirpath, dirnames, filenames in $os.walk('recipes/%s' % $BaseDirectory) +#for dirpath, dirnames, filenames in $os.walk($ExecuteContentPath) #for file in filenames - #if file.endswith('.html') -* [${file.replace('_', ' ').replace('.html', '')}](${BaseDirectory}${file}) + #if file.endswith('.markdown') and $generateRecipePage($file) +* [${file.replace('_', ' ').replace('.markdown', '')}](${HyperlinkContentPath}${file.replace('.markdown', '.html')}) #end if #end for #end for @@ -36,3 +33,27 @@ 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) + #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 + $recipe + #end def + ''', searchList=[{'PageName' : $filepath.replace('.markdown', ''), 'recipe' : ''.join($content)}]) + #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 |