]> oss.titaniummirror.com Git - webber.git/commitdiff
webber: get_link_from(), get_time():
authorHolger Schurig <hs4233@mail.mn-solutions.de>
Wed, 24 Jun 2009 20:41:17 +0000 (22:41 +0200)
committerHolger Schurig <hs4233@mail.mn-solutions.de>
Wed, 24 Jun 2009 20:44:11 +0000 (22:44 +0200)
get_link_from() now access `class File` objects, not just names
introduce new function get_time()

in/functions.md
webber.py

index 79d51ae8ca852e99aab3bd6bf7b2d21e0096eaa2..9970a64b87246066e83e37b628359350dacfdb9c 100644 (file)
@@ -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
index abb13d474004e1d8242c7232fa360a88917c4cc3..db3ea7e3af444fdf20d1e5baef8a7d6a677bdb68 100644 (file)
--- 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