User:Ch4zm/Initial MediaWiki Setup/Make Common CSS

From Golly.Life Wiki

< User:Ch4zm‎ | Initial MediaWiki Setup

Revision as of 03:31, 5 February 2021 by Ch4zm (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Python script to generate the sections of MediaWiki:Common.css that specify CSS classes for each Golly team:

import requests
import json

teams = requests.get('https://api.golly.life/teams').json()

for team in teams:
    abbr = team['teamAbbr'].lower()
    color = team['teamColor']
    css_template = f"""
.{abbr}_fg {{
    color: {color} !important;
}}
.{abbr}_border {{
    border: medium solid {color} !important;
}}
.{abbr}_bg {{
    background-color: {color} !important;
}}
"""
    print(css_template)