degal/folder.py
changeset 133 0c1c092bbc5d
parent 132 c2b2f4b6fe6d
child 138 130fb8a8dbb9
equal deleted inserted replaced
132:c2b2f4b6fe6d 133:0c1c092bbc5d
     8 
     8 
     9 import math
     9 import math
    10 
    10 
    11 class Folder (filesystem.Directory) :
    11 class Folder (filesystem.Directory) :
    12     """
    12     """
    13         A Folder is a filesystem Directory that contains any number of other Folders and Images.
    13         A Folder is a filesystem Directory that:
       
    14             * has a title/description (XXX: Page)
       
    15             * contains any number of other sub-Folders and Images.
       
    16             * can load custom configuration for itself and sub-nodes to override the base config
       
    17             * holds sub-dirs for previews/thumbs
       
    18             * has a HTML view
    14     """
    19     """
    15 
    20 
    16     def iter_config_files (self) :
    21     def iter_config_files (self) :
    17         """
    22         """
    18             Iterate over the possible config files for this dir
    23             Iterate over the possible config files for this dir
    30                 # yay! More configuration!
    35                 # yay! More configuration!
    31                 self.config = self.config.load(file.path)
    36                 self.config = self.config.load(file.path)
    32 
    37 
    33                 break
    38                 break
    34 
    39 
    35         # load some info from title?
    40         # load some info for title?
    36         if self.config and self.config.title :
    41         if self.config and self.config.title :
       
    42             # override our default title
    37             self.title = self.config.title
    43             self.title = self.config.title
    38 
    44 
    39             # disable it so it won't be used by children
    45             # disable it so it won't be used by children
    40             # XXX: figure out a better way of doing this
    46             # XXX: figure out a better way of doing this
    41             self.config.title = None
    47             self.config.title = None
    42     
    48     
    43     @lazy_load
    49     @lazy_load
    44     def title (self) :
    50     def title (self) :
    45         """
    51         """
    46             Find the title for this dir
    52             Find the default title for this dir.
    47         """
    53         """
    48 
    54 
    49         # default
    55         # default
    50         return self.name.title()
    56         return self.name.title()
    51     
    57     
    59         return None
    65         return None
    60 
    66 
    61     @lazy_load
    67     @lazy_load
    62     def preview_dir (self) :
    68     def preview_dir (self) :
    63         """
    69         """
    64             Load and return the Directory for previews
    70             Load and return the Directory used for for preview Thumbnails
    65         """
    71         """
    66         
    72         
    67         return self.subdir(self.config.preview_dir, create=True)
    73         return self.subdir(self.config.preview_dir, create=True)
    68     
    74     
    69     @lazy_load
    75     @lazy_load
    70     def thumb_dir (self) :
    76     def thumb_dir (self) :
    71         """
    77         """
    72             Load and return the Directory for thumbs
    78             Load and return the Directory used for thumb Thumbnails
    73         """
    79         """
    74         
    80         
    75         return self.subdir(self.config.thumb_dir, create=True)
    81         return self.subdir(self.config.thumb_dir, create=True)
    76    
    82    
    77     @lazy_load_iter
    83     @lazy_load_iter