Example #1
0
    def render(self, context):
        input_abspath = os.path.join(settings.CSS_BUILDER_SOURCE,
                                     self.path)
        if not os.path.exists(input_abspath):
            msg = '%s (%s) does not exists.' % (self.path, input_abspath)
            log('css_file', msg)
            return '<!--\n%s\n-->' % msg
        if self.dir_path != '':
            os.makedirs(os.path.join(settings.MEDIA_ROOT, self.dir_path))

        output_abspath = os.path.join(settings.MEDIA_ROOT, self.path)

        if settings.DEBUG == True:
            add_embedding_images(input_abspath, output_abspath)
            add_css_sprites(output_abspath)
        url = os.path.join(settings.MEDIA_URL, self.path)
        return '<link rel="stylesheet" type="text/css" href="%s" />' % url