lib/folder.py
changeset 26 81d6679d50d0
parent 23 10841abbc01f
child 27 301d738b1181
equal deleted inserted replaced
25:4b3cf12848c2 26:81d6679d50d0
   158                 prev = img
   158                 prev = img
   159                 
   159                 
   160                 # add to the sorted images list
   160                 # add to the sorted images list
   161                 self.sorted_images.append(img)
   161                 self.sorted_images.append(img)
   162                 
   162                 
   163             # figure out our title/ descr. Must be done before our parent dir is rendered (self.title)
   163         # figure out our title/ descr. Must be done before our parent dir is rendered (self.title)
   164             title_path = self.pathFor(settings.TITLE_FILE)
   164         title_path = self.pathFor(settings.TITLE_FILE)
   165             
   165         
   166             self.title, self.descr = utils.readTitleDescr(title_path)
   166         self.title, self.descr = utils.readTitleDescr(title_path)
   167             
   167         
   168             # default title for the root dir
   168         # default title for the root dir
   169             if self.title :
   169         if self.title :
   170                 self.alive = True
   170             self.alive = True
   171                 pass # use what was in the title file
   171             pass # use what was in the title file
   172                 
   172             
   173             elif not self.parent :
   173         elif not self.parent :
   174                 self.title = 'Index'
   174             self.title = 'Index'
   175 
   175 
   176             else :
   176         else :
   177                 self.title = self.name
   177             self.title = self.name
   178             
   178         
   179             if self.descr :
   179         if self.descr :
   180                 self.alive = True
   180             self.alive = True
   181 
   181 
   182         return self.alive
   182         return self.alive
   183 
   183 
   184     def getObjInfo (self) :
   184     def getObjInfo (self) :
   185         """
   185         """
   272 
   272 
   273             pagination_required = len(pages) > 1
   273             pagination_required = len(pages) > 1
   274 
   274 
   275             if pagination_required :
   275             if pagination_required :
   276                 render.info("Index split into %d pages of %d images each", len(pages), settings.IMAGE_COUNT)
   276                 render.info("Index split into %d pages of %d images each", len(pages), settings.IMAGE_COUNT)
   277             
   277             elif not pages :
       
   278                 render.info("Dir with no images, render for subdirs")
       
   279                 pages = [[]]
       
   280 
   278             for cur_page, images in enumerate(pages) :
   281             for cur_page, images in enumerate(pages) :
   279                 if pagination_required and cur_page > 0 :
   282                 if pagination_required and cur_page > 0 :
   280                     shorturl = "%s/%s" % (self.shorturl_code, cur_page+1)
   283                     shorturl = "%s/%s" % (self.shorturl_code, cur_page+1)
   281                 else :
   284                 else :
   282                     shorturl = self.shorturl_code
   285                     shorturl = self.shorturl_code
   283 
   286                 
   284                 # render to index.html
   287                 # render to index.html
   285                 gallery_tpl.render_to(self.pathFor(url_for_page(cur_page)), 
   288                 gallery_tpl.render_to(self.pathFor(url_for_page(cur_page)), 
   286                     stylesheet_url               = self.inRoot('style.css'),
   289                     stylesheet_url               = self.inRoot('style.css'),
   287                     title                        = self.title,
   290                     title                        = self.title,
   288                     breadcrumb                   = self.breadcrumb(),
   291                     breadcrumb                   = self.breadcrumb(),