diff options
-rwxr-xr-x | bin/build-players.sh | 2 | ||||
-rw-r--r-- | scripts/players.py | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/bin/build-players.sh b/bin/build-players.sh index 3f123bd..e1d099d 100755 --- a/bin/build-players.sh +++ b/bin/build-players.sh @@ -1,4 +1,4 @@ #!/bin/bash DIR=$1 mkdir -p $DIR/players -python scripts/players.py $DIR/players +python scripts/players.py $DIR/players $DIR/players/.menu.html diff --git a/scripts/players.py b/scripts/players.py index 7799972..613c01f 100644 --- a/scripts/players.py +++ b/scripts/players.py @@ -6,6 +6,9 @@ from pyranking.fetch import fetch_ranking output_directory = sys.argv[1] pagesize = 100.0 +menu_file = sys.argv[2] +menu_content = bs4(file(menu_file), 'html.parser') + dates = {} for date_config in json.load(file('config/dates.json')): dates[date_config['date']] = date_config['url'] @@ -28,7 +31,6 @@ for date in sorted(dates.keys()): players[player]['rankings'][date][field + '-change-class'] = 'primary' for pid, player in players.iteritems(): - template = bs4(file('templates/player.html'), 'lxml') template.select('h2.name')[0].insert(0, player['name']) template.select('h3.club')[0].string = player['club'] @@ -89,4 +91,8 @@ for pid, player in players.iteritems(): change_label.string = ranking[field+'change'] change_label['class'] = change_label['class'] + ['label-'+ranking[field+'change-class']] template.select('table.table tbody')[0].insert(0, row) - file(os.path.join(output_directory, '%d.html' % pid), 'w').write(template.prettify().encode('utf-8')) + + menu = template.select('div.static-menu')[0] + menu.append(copy.copy(menu_content)) + + file(os.path.join(output_directory, '%d.html' % pid), 'w').write(template.prettify().encode('utf-8')) |