// sails-linker
module.exports = function(config) { return {
    devJs: {
        options: {
            startTag: '<!--SCRIPTS-->',
            endTag: '<!--SCRIPTS END-->',
            fileTmpl: '<script src="%s"></script>',
            appRoot: '.tmp/public'
        },
        files: {
            '.tmp/public/**/*.html': config.jsFilesToInject,
            'views/**/*.html': config.jsFilesToInject,
            'views/**/*.ejs': config.jsFilesToInject
        }
    },

    prodJs: {
        options: {
            startTag: '<!--SCRIPTS-->',
            endTag: '<!--SCRIPTS END-->',
            fileTmpl: '<script src="%s"></script>',
            appRoot: '.tmp/public'
        },
        files: {
            '.tmp/public/**/*.html': ['.tmp/public/min/production.js'],
            'views/**/*.html': ['.tmp/public/min/production.js'],
            'views/**/*.ejs': ['.tmp/public/min/production.js']
        }
    },

    devStyles: {
        options: {
            startTag: '<!--STYLES-->',
            endTag: '<!--STYLES END-->',
            fileTmpl: '<link rel="stylesheet" href="%s">',
            appRoot: '.tmp/public'
        },

        // config.cssFilesToInject defined up top
        files: {
            '.tmp/public/**/*.html': config.cssFilesToInject,
            'views/**/*.html': config.cssFilesToInject,
            'views/**/*.ejs': config.cssFilesToInject
        }
    },

    prodStyles: {
        options: {
            startTag: '<!--STYLES-->',
            endTag: '<!--STYLES END-->',
            fileTmpl: '<link rel="stylesheet" href="%s">',
            appRoot: '.tmp/public'
        },
        files: {
            '.tmp/public/index.html': ['.tmp/public/min/production.css'],
            'views/**/*.html': ['.tmp/public/min/production.css'],
            'views/**/*.ejs': ['.tmp/public/min/production.css']
        }
    },

    // Bring in JST template object
    devTpl: {
        options: {
            startTag: '<!--TEMPLATES-->',
            endTag: '<!--TEMPLATES END-->',
            fileTmpl: '<script type="text/javascript" src="%s"></script>',
            appRoot: '.tmp/public'
        },
        files: {
            '.tmp/public/index.html': ['.tmp/public/templates.js'],
            'views/**/*.html': ['.tmp/public/templates.js'],
            'views/**/*.ejs': ['.tmp/public/templates.js']
        }
    },


    /*******************************************
     * Jade linkers (TODO: clean this up)
     *******************************************/

    devJsJADE: {
        options: {
            startTag: '// SCRIPTS',
            endTag: '// SCRIPTS END',
            fileTmpl: 'script(type="text/javascript", src="%s")',
            appRoot: '.tmp/public'
        },
        files: {
            'views/**/*.jade': config.jsFilesToInject
        }
    },

    prodJsJADE: {
        options: {
            startTag: '// SCRIPTS',
            endTag: '// SCRIPTS END',
            fileTmpl: 'script(type="text/javascript", src="%s")',
            appRoot: '.tmp/public'
        },
        files: {
            'views/**/*.jade': ['.tmp/public/min/production.js']
        }
    },

    devStylesJADE: {
        options: {
            startTag: '// STYLES',
            endTag: '// STYLES END',
            fileTmpl: 'link(rel="stylesheet", href="%s")',
            appRoot: '.tmp/public'
        },
        files: {
            'views/**/*.jade': config.cssFilesToInject
        }
    },

    prodStylesJADE: {
        options: {
            startTag: '// STYLES',
            endTag: '// STYLES END',
            fileTmpl: 'link(rel="stylesheet", href="%s")',
            appRoot: '.tmp/public'
        },
        files: {
            'views/**/*.jade': ['.tmp/public/min/production.css']
        }
    },

    // Bring in JST template object
    devTplJADE: {
        options: {
            startTag: '// TEMPLATES',
            endTag: '// TEMPLATES END',
            fileTmpl: 'script(type="text/javascript", src="%s")',
            appRoot: '.tmp/public'
        },
        files: {
            'views/**/*.jade': ['.tmp/public/templates.js']
        }
    }
};};
