def test_separated_apps(self): """ Test what is separated by default """ self.assertEquals(dirs.get_separated_apps("css"), []) self.assertEquals(dirs.get_separated_apps("js"), []) with self.settings(SEPARATE_CSS=["something"]): self.assertIn("something", dirs.get_separated_apps("css")) self.assertEquals(len(dirs.get_separated_apps("css")), 1) with self.settings(SEPARATE_JS=["something"]): self.assertIn("something", dirs.get_separated_apps("js")) self.assertEquals(len(dirs.get_separated_apps("js")), 1)
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]