]> oss.titaniummirror.com Git - webber.git/blobdiff - webber.py
toc.py: more comments
[webber.git] / webber.py
index 542df6da3172ac4eba2090b38d854ca28a54b1a1..6be571e0ff09ea19d88e0e9e2ef6625b442eaf16 100644 (file)
--- a/webber.py
+++ b/webber.py
@@ -116,7 +116,7 @@ class File(Holder):
 
                # Warn about long titles / long linktitles
                if len(self.linktitle) > 20:
-                       log('%s: define a shorter "linktitle: xxx"')
+                       log('%s: define a shorter linktitle' % self.rel_path)
 
                self.contents = "".join(txt)
 
@@ -125,7 +125,7 @@ _get_file_for_cache = {}
 def get_file_for(name):
        """webber.files is an hash of File objects, but keyed on the real file name.
        This function returns a File object for a specific linktitle."""
-       
+
        try:
                return _get_file_for_cache[name]
        except:
@@ -313,7 +313,7 @@ def info(s):
 # At startup:
 #      addoptions           allow plugins to add command-line options
 #      checkconfig          check configuration
-#      start                
+#      start
 # While reading files:
 #      read                 ask any reader (plugins!) to read the file
 #      filter               ask anybody to filter the contents
@@ -337,13 +337,11 @@ hooks = {}
 def load_plugins():
        """Loads all plugins in the plugins directory."""
        sys.path.append(os.path.join(get_program_directory(), "plugins"))
+       if cfg.has_key("plugin_dirs"):
+               for s in cfg.plugin_dirs:
+                       sys.path.append(s)
        for s in cfg.plugins:
-               #print "import:", s
-               #try:
                exec "import %s" % s
-               #except:
-               #       print "Could not import plugin '%s'" % s
-               #       sys.exit(1)
 
 
 def set_hook(name, last=False):
@@ -545,7 +543,7 @@ def walk_tree(dirpath):
                                        )
                                        file.inheritFrom(direc)
                                        read_file(direc, file)
-                                               
+
        walk(dirpath)
 
 
@@ -602,7 +600,7 @@ def run_macros(file, contents):
        s = reMacro.sub(do_macro, contents)
        #print s
        return s
-       
+
 
 def scan_files():
        info("Scanning files ...")
@@ -619,6 +617,10 @@ def scan_files():
 
                direc = directories[file.direc]
 
+               # Output-Filename "berechnen"
+               if file.render and file.render == "html":
+                       file.out_path = os.path.splitext(s)[0] + ".html"
+
                run_hooks("scan",
                        direc=direc,
                        file=file)
@@ -664,9 +666,6 @@ def render_files():
                        continue
                file.contents = contents
 
-               # Output-Filename "berechnen"
-               file.out_path = os.path.splitext(fname_in)[0] + ".html"
-
        for fname_in in files:
                file = files[fname_in]
                current_file = file
@@ -675,14 +674,13 @@ def render_files():
                        continue
                direc = directories[file.direc]
 
-               contents = run_hooks("linkify",
+               run_hooks("linkify",
                        direc=direc,
                        file=file,
-                       return_holder=False)
+                       return_holder=True)
                #print "contents after 'linkify':", contents
-               if not contents:
+               if not file.contents:
                        continue
-               file.contents = contents
 
                # TODO: einige Fragmente sollen u.U. in eine andere
                # Webseite eingebaut werden und sollten daher nicht in
@@ -742,7 +740,7 @@ def addoptions(params):
 
        return parser
 
-       
+
 @set_hook("checkconfig", last=True)
 def checkconfig(params):
        # Ensure absolute paths that end in '/'.