예제 #1
0
def clan_category_link(cat):
    if isinstance(cat, str):
        try:
            cat = clan_category_by_name(cat)
        except KeyError:
            return None
    if not cat.source_table:
        return None
    return crawl_utils.base_link(crawl_utils.slugify("clan-" + cat.name)) + ".html"
예제 #2
0
def clan_category_pages(c):
    for category in scoring_data.CLAN_CATEGORIES:
        info("Updating clan category page %s" % category.name)
        render(
            c,
            page='category',
            dest='clan-' + crawl_utils.slugify(category.name),
            pars={
                'category': category,
            },
            top_level_pars=True,
        )
예제 #3
0
def _pretty_banners(banner_str):
    # type: (str) -> str
    banners = json.loads(banner_str)
    outstr = ''
    for bandata in BANNERS:
        prestige = banners.get(bandata.dbname, 0)
        if bandata.god == "Xom":
            color = random.choice(["#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff", "#00ffff"])
        else:
            color = bandata.color
        if prestige:
            imglink = crawl_utils.XXX_IMAGE_BASE + "/altar/" + crawl_utils.slugify(bandata.god) + ".png"
            outstr += '''<img src="{image_src}" alt="{god} {tier}" title="{god} {tier}"
                              class="pixel-art banner-tier-{tier}"
                              style="border-color:{color}" loading="lazy">'''.format(
                                      image_src = imglink, god = bandata.god,
                                      tier = prestige, color = color)

    return outstr
예제 #4
0
def category_pages(c):
    for category_type, categories in (('individual',
                                       scoring_data.INDIVIDUAL_CATEGORIES),
                                      ('clan', scoring_data.CLAN_CATEGORIES)):
        prefix = "" if category_type == 'individual' else 'clan-'
        for category in categories:
            if not category.source_table:
                info("Not generating any page for %s category %s",
                     category_type, category.name)
                continue
            info("Updating %s category page %s", category_type, category.name)
            rows = scoring_data.category_leaders(category, c)
            render(
                c,
                page='category',
                dest=prefix + crawl_utils.slugify(category.name),
                pars={
                    'category': category,
                    'rows': rows,
                },
                top_level_pars=True,
            )