Example #1
0
    def disable_photo(self, event_index, photo_index, disable, verbose = False):
        """
        disable_photo: disable or enable an event. 
        
        20130103/RB: started function
        
        INPUT:
        - event_index (int): index of the event in event_array. Use 'list_events' to find the correct index.
        - disable (BOOL): True to disable, False to enable. If you try to re-disable an event, it will give a warning and continue
        
        OUTPUT:
        - True: success or False: failure
        
        """
        # use a bit of shorthand... sorry
        ev = self.event_array[event_index]
        ph = ev.photo_array[photo_index]
        
        if disable:
            dis = "disabled"
        else:
            dis = "enabled"
    
        HBFUN.verbose("HBalbum/disable_photo(): event " + ev.event_title + " photo " + ph.photo_filename + " to " + dis, verbose)
    
        if event_index > len(self.event_array):
            HBFUN.printError("The event index exceeds the length of the event_array", inspect.stack())
            return False

        if photo_index > len(ev.photo_array):
            HBFUN.printError("The photo_index exceeds the length of the photo_array", inspect.stack())
            return False

           
        if ph.disabled == disable:
            HBFUN.printWarning("Event " + ev.event_title + " photo " + ph.photo_filename + " is already " + dis, inspect.stack())

        HBFUN.verbose("  event_title: " + ev.event_title, verbose)
        HBFUN.verbose("  event_dir: " + ev.event_dir, verbose)           
        HBFUN.verbose("  photo_title: " + ph.photo_title, verbose)
        HBFUN.verbose("  photo_filename: " + ph.photo_filename, verbose)  
                
        ph.disabled = disable
        
        return True
Example #2
0
    def disable_event(self, index, disable, verbose = False):
        """
        disable_event: disable or enable an event. 
        
        20130103/RB: started function
        
        INPUT:
        - index (int): index of the event in event_array. Use 'list_events' to find the correct index. If index is -1, it will affect all albums.
        - disable (BOOL): True to disable, False to enable. If you try to re-disable an event, it will give a warning and continue
        
        OUTPUT:
        - True: success or False: failure
        
        """
        
        ev = ev = self.event_array[index]
        
        if disable:
            dis = "disabled"
        else:
            dis = "enabled"

        HBFUN.verbose("HBalbum/disable_event(): index " + str(index) + " to " + dis, verbose)

        if index > len(self.event_array) or index < -1:
            HBFUN.printError("The index exceeds the length of the array", inspect.stack())
            return False
            
        if index == -1:
            HBFUN.verbose("  all events will be set to " + dis, verbose)
            for i in range(len(self.event_array)):
                ev.disabled = disable
        
        else:
            if ev.disabled == disable:
                HBFUN.printWarning("Event " + ev.event_title + " is already " + dis, inspect.stack())
            
            HBFUN.verbose("  event_title: " + ev.event_title, verbose)
            HBFUN.verbose("  event_dir: " + ev.event_dir, verbose)          
            ev.disabled = disable
        
        return True
Example #3
0
def make_html(album, verbose = False):
    """
    make_html: the do-all function to generate html
    
    20130103/RB: started the function
    20130127/RB: generate RSS feed at end of this function
    
    INPUT:
    - album (HBAL.album)
    
    """
    
    HBFUN.verbose("make_html: Hi!", True)
    
    # some general strings
    no_nav = "" # value if there is no navigation element (first picture or so)

    # make album
    HBFUN.verbose("  make album: " + album.album_title, verbose)
    
    f = open(album.album_path + album.html_dir + "index.html", "wb")
    make_html_header(f, album.album_title)
    make_html_navigation(f, album.album_title)
    gallery = prepare_album_gallery(album)
    make_html_gallery(f, gallery)
    make_html_footer(f)
    f.close()

    # make event pages
    ev_array = range(len(album.event_array))
    ev_array = [n for n in ev_array if album.event_array[n].disabled == False]
        
    for i in ev_array: #range(len(album.event_array)):
        
        event = album.event_array[i]
        
        # filter disabled photos
        ph_array = range(len(event.photo_array))
        ph_array = [n for n in ph_array if event.photo_array[n].disabled == False]
        
        if ph_array == []:
            HBFUN.printWarning(event.event_title + " does not contain any photos or all photos are disabled. The event will be skipped!", inspect.stack())    
        
        else:
            
            event.read_properties_list(verbose)
            
            HBFUN.verbose("    make event: " + event.event_title, verbose)
            
            f = open(album.album_path + album.html_dir + event.event_dir + "index.html", "wb")
            
            page_title = album.album_title + " - " + event.event_title
            make_html_header(f, page_title, css_path = "../") 
            
            if i == 0:
                prev_nav = no_nav
            else:
                prev_nav = "../" + album.event_array[i-1].event_dir + "index.html"
            if i == len(album.event_array) - 1:
                next_nav = no_nav
            else:
                next_nav = "../" + album.event_array[i+1].event_dir + "index.html"        
            up_nav = "../index.html"
            make_html_navigation(f, event.event_title, prev_nav, up_nav, next_nav)
            
            gallery = prepare_event_gallery(event)
            make_html_gallery(f, gallery)
            
            make_html_footer(f)
            
            f.close()   
    
            # make photo pages
            for j in ph_array:

                photo = event.photo_array[j]  

                HBFUN.verbose("      make photo: " + photo.photo_title, verbose)
                
                f = open(album.album_path + album.html_dir + event.event_dir + photo.photo_html_name, "wb")      
                
                page_title = album.album_title + " - " + event.event_title 
                if photo.photo_title:
                    page_title += " - " + photo.photo_title
                make_html_header(f, page_title, css_path = "../")
                
                if j == 0:
                    prev_nav = no_nav
                else:
                    prev_nav = event.photo_array[j-1].photo_html_name
                if j == len(event.photo_array) - 1:
                    next_nav = no_nav
                else:
                    next_nav = event.photo_array[j+1].photo_html_name
                up_nav = "index.html"
                make_html_navigation(f, event.event_title, prev_nav, up_nav, next_nav)
                
                make_photo_html(f, photo)
                
                make_html_footer(f)
                
                f.close()  
    
    generate_rss(album)
    
    HBFUN.verbose("make_html: Bye!", True)

    return album