Example #1
0
def themes(theme, path):
    """
    General static file handler
    :param theme:
    :param path:
    :return:
    """
    for cand_path in (
            safe_join(app.root_path, "themes", cand_theme, "static", path)
            # The `theme` value passed in may not be the configured one, e.g. for
            # admin pages, so we check that first
            for cand_theme in (theme, *config.ctf_theme_candidates())):
        if os.path.isfile(cand_path):
            return send_file(cand_path)
    abort(404)
Example #2
0
def themes_beta(theme, path):
    """
    This is a copy of the above themes route used to avoid
    the current appending of .dev and .min for theme assets.

    In CTFd 4.0 this url_for behavior and this themes_beta
    route will be removed.
    """
    for cand_path in (
        safe_join(app.root_path, "themes", cand_theme, "static", path)
        # The `theme` value passed in may not be the configured one, e.g. for
        # admin pages, so we check that first
        for cand_theme in (theme, *config.ctf_theme_candidates())
    ):
        if os.path.isfile(cand_path):
            return send_file(cand_path)
    abort(404)