X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=in%2Ffunctions.md;fp=in%2Ffunctions.md;h=5b28338241f35bf34e7ac084045a13f16b8b3ae9;hb=b5bc4ffdfbaa76db7cd4cdeb078097ec17024f6b;hp=05e0d8deb10133f2e99b601447f20c1d2368a7f8;hpb=c6d30c7f18e835e0b99032d01b1f8acd7f077ec6;p=webber.git diff --git a/in/functions.md b/in/functions.md index 05e0d8d..5b28338 100644 --- a/in/functions.md +++ b/in/functions.md @@ -1,27 +1,41 @@ title: Functions parent: Webber +lang: en ctime: 2009-06-24 +mtime: 2011-01-13 +change: remove reference to show_orphan -= Calling functions = +You can call functions only from [[template_mako]], not from +[[pages|pageformat]]. If you need the latter, look at [[macros]]. -You can call functions only from [[template_mako]]. An example: += Example = Modified ${format_date(mtime)} += List of functions = + Here's list of functions defined by webber and it's default plugins: -== format_date(timestamp) == +== format_date(timestamp, format) == Takes a timestamp (seconds since 1st January 1970) and converts it into -a string, using to `cfg.date_format`. +a string. + +"`format`" is optional. If not used, "`cfg.date_format`" will be used. +Otherwise it should be a format-string as documented by "`man strftime`". For +example, "`%Y-%m-%d`" stands for year-month-date. Defined in `webber.py`. -== get_time() == +== get_time(format) == + +Returns the current date/time as a string. -Returns the current date/time as a string according to `cfg.date_format`. +"`format`" is optional. If not used, "`cfg.date_format`" will be used. +Otherwise it should be a format-string as documented by "`man strftime`". For +example, "`%Y-%m-%d`" stands for year-month-date. Defined in `webber.py`. @@ -63,7 +77,7 @@ You'll need to specify "`root`" if your top-most page isn't named "`Home`". Defined in [[hierarchy.py|hierarchy]], where you find an example. -== get_sitemap(root, show_orphans) == +== get_linear_sitemap(root, level) == Returns all pages as "`(level, page, link)`" tuples, where "`page`" is a "`class File`"-object and link is a relative link from the current page to @@ -71,15 +85,15 @@ Returns all pages as "`(level, page, link)`" tuples, where "`page`" is a You'll need to specify "`root`" if your top-most page isn't named "`Home`". -To put pages into the sitemap that are outside the parent/child relationships, -specify "`True`" for "`show_orphans`". +The "`level`" will by default start at 1. Defined in [[hierarchy.py|hierarchy]], where you find an example. +== get_toc() == -== func == +Returns an unsorted list with the hierarchy of the table-of-contents. -A sample function in the [[skeleton.py|skeleton]]. See below. +Defined in [[toc.py|toc]], where you find an example. = Writing functions =