'''
Created on Oct 24, 2021

@author: terry
'''

import os
from distutils.dir_util import remove_tree, copy_tree

class LunaGenAddOn(object):
    """
    Abstract base class for LunaGen Addons.
    """
    
    name = 'my_addon'   # Replace with string name of add-on (should match directory name).
    desc = """\
An add-on to demonstrate add-on design.
Replace this text with a brief description of your add-on's purpose.
"""
    
    @staticmethod
    def load(site):
        """
        Load the site data that the add-on needs to function.
        
        Note that this is site data that the site designer has to provide,
        which the addon will then interpret.
        Client is the LunaGen instance, which subclasses jinja2.Environment.
        Mandatory -- you must implement a loader.
        """
        raise NotImplementedError
    
    @classmethod
    def copy_skeleton(cls, site):
        skeleton = os.path.join(os.path.dirname(cls.file), 'skeleton')
        #
        print("Copying skeleton for %s from %s." % (cls.name, skeleton))
        #
        copy_tree(skeleton, site.tgtdir, verbose=site.verbose)
        
    @staticmethod
    def render(site):
        """
        Render templates to images or do other tasks to prepare target site.
        Optional.
        
         - Focused on images or other binary data
         - Should not be dependent on site data that might change
         - may have additional dependencies (e.g. Inkscape or ImageMagick) on
           software not installed on the server
         - not run when RE-generating the site.
        """
        pass
    
    @staticmethod
    def generate(site):
        """
        Generate a page or pages in the target site.
        Optional.
        
         - Produces PAGES of HTML, SVG, etc.
         - Uses templates provide by the chain of sources
         - Should provide a default template, unless its using a standard site template
           (i.e. don't leave it up to the theme)
         - Dynamic. Regenerated in every site update. 
        """
        pass


        