From b39834eef474839b7ee88cb0b3ce2a29e88bde47 Mon Sep 17 00:00:00 2001 From: "R. Tyler Ballance" Date: Mon, 25 May 2009 15:43:51 -0700 Subject: Implement the automagical markdown->template generation Signed-off-by: R. Tyler Ballance --- recipes/content/Basic_Inheritance.html | 395 +++++++++++++++++++++++++++++ recipes/content/Basic_Inheritance.markdown | 3 + recipes/content/General_Inheritance.html | 394 ---------------------------- recipes/content/General_Inheritance.tmpl | 17 -- recipes/index.html | 2 +- recipes/index.tmpl | 39 ++- 6 files changed, 429 insertions(+), 421 deletions(-) create mode 100644 recipes/content/Basic_Inheritance.html create mode 100644 recipes/content/Basic_Inheritance.markdown delete mode 100644 recipes/content/General_Inheritance.html delete mode 100644 recipes/content/General_Inheritance.tmpl diff --git a/recipes/content/Basic_Inheritance.html b/recipes/content/Basic_Inheritance.html new file mode 100644 index 0000000..6824280 --- /dev/null +++ b/recipes/content/Basic_Inheritance.html @@ -0,0 +1,395 @@ + + + + + + + Community Cheetah - The Python-Powered Template Engine - Basic_Inheritance + + + + + + + + + + + Fork me on GitHub + +
+ +
+ Home |  + Issues |  + Source |  + Roadmap |  +
+
+ + + + + +
+
        Basic Inheritance
+
+

=================

+
+ +
+ + +
+ +
    + + follow Cheetah on Twitter +
    + + + +
    + +
    +
    + + Python-powered +
    +
    + + + + + + + + + + + + + + + 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.html b/recipes/content/General_Inheritance.html deleted file mode 100644 index 6315148..0000000 --- a/recipes/content/General_Inheritance.html +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - Community Cheetah - The Python-Powered Template Engine - Inheritance in Cheetah - - - - - - - - - - - Fork me on GitHub - -
    - -
    - Home |  - Issues |  - Source |  - Roadmap |  -
    -
    - - - - - -
    -

    Inheritance in Cheetah

    -
    - -
    - - -
    - -
      - - follow Cheetah on Twitter -
      - - - -
      - -
      -
      - - Python-powered -
      -
      - - - - - - - - - - - - - - - - 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;}

      Cheetah Recipes

      Here are the available recipes thus far:

      If you're really hungry for some Cheetah recipies, you can check out the out-of-date Cheetah recipes page 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 -- cgit v1.2.1