From: Holger Schurig Date: Wed, 24 Jun 2009 20:41:17 +0000 (+0200) Subject: webber: get_link_from(), get_time(): X-Git-Url: https://oss.titaniummirror.com/gitweb?a=commitdiff_plain;h=87069875266f9043783ef33a68d3d40af7185473;p=oss-web.git webber: get_link_from(), get_time(): get_link_from() now access `class File` objects, not just names introduce new function get_time() --- diff --git a/in/functions.md b/in/functions.md index 79d51ae..9970a64 100644 --- a/in/functions.md +++ b/in/functions.md @@ -10,6 +10,7 @@ You can call functions only from [[template_mako]]. An example: Here's list of functions defined by webber and it's default plugins: + == format_date == Takes a timestamp (seconds since 1st January 1970) and converts it into @@ -17,18 +18,28 @@ a string, using to `cfg.date_format`. Defined in `webber.py`. + +== get_time == + +Returns the current date/time as a string according to `cfg.date_format`. + +Defined in `webber.py`. + + == get_breadcrumbs == Returns the breadcrumbs as "`(linktitle, link)`" tuples. Defined in [[hierarchy.py|hierarchy]], where you find an example. + == get_current_file == Returns the current `class File` object. Defined in `webber.py`. + == get_recently == Returns a list of up to 10 pages below the current page. For each diff --git a/webber.py b/webber.py index abb13d4..db3ea7e 100644 --- a/webber.py +++ b/webber.py @@ -188,11 +188,16 @@ def relpath(base_path, target): def get_link_from(source, dest): #print "get_link_from", source, dest - source = get_file_for(source) + #print source + if not isinstance(source, File): + source = get_file_for(source) if not source: + print "NO SOURCE" return "." - dest = get_file_for(dest) + if not isinstance(dest, File): + dest = get_file_for(dest) if not dest: + print "NO DEST" return "." rel_path = relpath(directories[source.direc].abs_path, directories[dest.direc].abs_path) try: @@ -417,6 +422,10 @@ def iso_to_time(val): def format_date(timestamp): return time.strftime(cfg.date_format, time.localtime(timestamp)) +@set_function("get_time") +def get_time(): + return format_date(time.time()) + @set_function("get_current_file") def get_current_file(): return current_file