def handle(self, *args, **options):
     """
     Cache Static Files
     """
     possible_js_cache = os.path.join(generate_cache_dir(get_main_js_dir()), "mediabrute_usefile")
     
     if os.path.isfile(possible_js_cache):
         os.unlink(possible_js_cache)
     
     js_urls = handlers.minify_js()
     js_file = open(possible_js_cache, "w")
     for url in js_urls:
         js_file.writelines(js_urls)
     js_file.close()
     
     
     possible_css_cache = os.path.join(generate_cache_dir(get_main_css_dir()), "mediabrute_usefile")
     
     if os.path.isfile(possible_css_cache):
         os.unlink(possible_css_cache)
     
     css_urls = handlers.minify_css()
     css_file = open(possible_css_cache, "w")
     for url in css_urls:
         css_file.writelines(css_urls)            
     css_file.close()
     
    def handle(self, *args, **options):
        """
        Cache Static Files
        """
        possible_js_cache = os.path.join(generate_cache_dir(get_main_js_dir()),
                                         "mediabrute_usefile")

        if os.path.isfile(possible_js_cache):
            os.unlink(possible_js_cache)

        js_urls = handlers.minify_js()
        js_file = open(possible_js_cache, "w")
        for url in js_urls:
            js_file.writelines(js_urls)
        js_file.close()

        possible_css_cache = os.path.join(
            generate_cache_dir(get_main_css_dir()), "mediabrute_usefile")

        if os.path.isfile(possible_css_cache):
            os.unlink(possible_css_cache)

        css_urls = handlers.minify_css()
        css_file = open(possible_css_cache, "w")
        for url in css_urls:
            css_file.writelines(css_urls)
        css_file.close()
Esempio n. 3
0
def clear_cache():
    """
    Clears out the cached media files
    """    
    js_dir = dirs.get_main_js_dir()
    css_dir = dirs.get_main_css_dir()
    
    heavy_lifting.unlink_cache(dirs.generate_cache_dir(js_dir), "js", unlink_all=True)
    heavy_lifting.unlink_cache(dirs.generate_cache_dir(css_dir), "css", unlink_all=True)
Esempio n. 4
0
def clear_cache():
    """
    Clears out the cached media files
    """
    js_dir = dirs.get_main_js_dir()
    css_dir = dirs.get_main_css_dir()

    heavy_lifting.unlink_cache(dirs.generate_cache_dir(js_dir),
                               "js",
                               unlink_all=True)
    heavy_lifting.unlink_cache(dirs.generate_cache_dir(css_dir),
                               "css",
                               unlink_all=True)
Esempio n. 5
0
def minify_js(app_name=None):
    """
    {{ MINI_JS }} Context processor
    """
    js_dir = dirs.get_main_js_dir()
    cache_dir = dirs.generate_cache_dir(js_dir)
    
    # check for a possible 'lock' file
    possible_cache = os.path.join(cache_dir, "mediabrute_usefile")
    if os.path.isfile(possible_cache):
        txt = open(possible_cache)
        js_urls = txt.readlines()        
        return [url for url in js_urls if url != ""]

    # continue to do an on-the-fly cache if no lock file was found
    js_dirs = [js_dir, dirs.APP_JS_DIRS]
    cache_files = [compile_and_cache_js(js_dirs, cache_dir, add_settings=True),]
    
    if app_name and app_name in dirs.get_separated_apps("js"):
        cache_files.append(compile_and_cache_js([dirs.get_separated_js(app_name), ], cache_dir, app_name=app_name))    
        
    return ["%s/cache/%s" % (dirs.get_js_url(), cache_name) for cache_name in cache_files]