From bed78f3f27f66a0411b27b8989e8e7b6c2333eb9 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 14 Apr 2017 02:06:15 +0200 Subject: Extended page subtitles, with ranking edition detailed titles --- bin/build.sh | 2 +- config/dates.json | 2 +- ranking.py | 11 ++++++----- templates/ranking.html | 4 +++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 4cd0f90..14b4f98 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -9,7 +9,7 @@ cat config/dates.json | xargs -n4 | while read DATE URL INDEX NAME do - python ranking.py $DATE $PREV_DATE > $DIR/$URL + python ranking.py "$NAME" $INDEX $DATE $PREV_DATE > $DIR/$URL PREV_DATE=$DATE done find $DIR -maxdepth 1 -type f -name \*.html | diff --git a/config/dates.json b/config/dates.json index f302866..4388d7d 120000 --- a/config/dates.json +++ b/config/dates.json @@ -1 +1 @@ -prod-dates.json \ No newline at end of file +test-dates.json \ No newline at end of file diff --git a/ranking.py b/ranking.py index e74864e..3382d8d 100644 --- a/ranking.py +++ b/ranking.py @@ -3,9 +3,12 @@ from bs4 import BeautifulSoup as bs4 from pyranking.fetch import fetch_ranking -ranking_date = sys.argv[1] +ranking_date = sys.argv[3] +subtitle = 'notowanie %s (%s), stan na %s' % ( + sys.argv[1], sys.argv[2], '.'.join(ranking_date.split('-')[::-1]) +) ranking = fetch_ranking(ranking_date) -old_ranking = fetch_ranking(sys.argv[2], True) if len(sys.argv) > 2 else {} +old_ranking = fetch_ranking(sys.argv[4], True) if len(sys.argv) > 4 else {} for row in ranking: if row['pid'] in old_ranking: @@ -28,9 +31,7 @@ table = bs4(file('templates/ranking.html'), 'lxml') table_body = table.select('tbody')[0] table_row = table_body.select('tr')[0].extract() -table.select('.page-header h1 small')[0].string = 'stan na %s' % ( - '.'.join(ranking_date.split('-')[::-1]) -) +table.select('.page-header h2 small')[0].string = subtitle for row in ranking: new_row = copy.copy(table_row) diff --git a/templates/ranking.html b/templates/ranking.html index c630753..a9b77e1 100644 --- a/templates/ranking.html +++ b/templates/ranking.html @@ -10,8 +10,10 @@