User:Ch4zm/Initial MediaWiki Setup/Make Common CSS: Difference between revisions

From Golly.Life Wiki
(Created page with "Python script to generate the sections of MediaWiki:Common.css that specify CSS classes for each Golly team: <pre> import requests import json teams = requests.get('http...")
 
No edit summary
 
Line 23: Line 23:
     print(css_template)
     print(css_template)
</pre>
</pre>
[[Category:MediaWiki]]

Latest revision as of 03:31, 5 February 2021

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)