summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-09-07 14:25:25 +0200
committeremkael <emkael@tlen.pl>2017-09-07 14:25:25 +0200
commit91b4d644cf8064457d5365dc1642ad8ab5f87be3 (patch)
tree5953aa85e47ab5286cda000816c6b43ea8ce6527
parent5a38d64cddc7cef197b5f7ac63b5fb97a72c80da (diff)
Pre-generating menu content for ranking pages
-rw-r--r--Makefile10
-rwxr-xr-xbin/build-rankings.sh4
-rwxr-xr-xbin/write-menus.sh7
-rw-r--r--scripts/ranking.py7
4 files changed, 18 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index edf9cb0..7ccc986 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,17 @@
-all: statics rankings players menus
+all: statics rankings players
targetfiles := $(shell bin/target-ranking-files.sh config/dates.json)
tmpfiles := $(patsubst %.html,http/%.html.tmp,$(targetfiles))
rankfiles := $(patsubst %.html,http/%.html.ed,$(targetfiles))
-rankings: datafiles tables editions json
+rankings: datafiles menus tables editions json
datafiles:
bin/build-datafiles.sh config/dates.json http/_data
+menus:
+ bin/write-menus.sh config/static.json http
+
tables:
bin/build-rankings.sh config/dates.json http
@@ -27,9 +30,6 @@ statics:
python scripts/generate-static-menu.py config/static.json http http > http/.menu.html
bin/generate-statics.sh config/static.json static http
-menus:
- bin/write-menus.sh config/static.json http
-
group-tools:
python scripts/static.py static/group-intro.html static/group-form-loading.html static/group-form.html > http/ranking-grupowy.html
python scripts/generate-static-menu.py config/static.json http http > http/.menu.html
diff --git a/bin/build-rankings.sh b/bin/build-rankings.sh
index 41e182a..c51fa1d 100755
--- a/bin/build-rankings.sh
+++ b/bin/build-rankings.sh
@@ -1,12 +1,10 @@
#!/bin/bash
CONFIG=$1
DIR=$2
-PREV_DATE=""
cat $CONFIG |
jq '.[] | .date, .url, .index, .name' |
xargs -n4 |
while read DATE URL INDEX NAME
do
- python scripts/ranking.py "$NAME" $INDEX $DATE $PREV_DATE > $DIR/$URL
- PREV_DATE=$DATE
+ python scripts/ranking.py "$NAME" $INDEX $DIR/.menu.html $DATE > $DIR/$URL
done
diff --git a/bin/write-menus.sh b/bin/write-menus.sh
index 33ae144..500db52 100755
--- a/bin/write-menus.sh
+++ b/bin/write-menus.sh
@@ -1,4 +1,9 @@
#!/bin/bash
CONFIG_FILE=$1
DIRECTORY=$2
-find $DIRECTORY -name \*.html -exec python scripts/static-menu.py $CONFIG_FILE {} $DIRECTORY \;
+mkdir -p $DIRECTORY/players
+find $DIRECTORY -type d -not -name _\* |
+ while read HTMLDIR
+ do
+ python scripts/generate-static-menu.py $CONFIG_FILE $DIRECTORY $HTMLDIR > $HTMLDIR/.menu.html
+ done
diff --git a/scripts/ranking.py b/scripts/ranking.py
index e3276da..52b036f 100644
--- a/scripts/ranking.py
+++ b/scripts/ranking.py
@@ -1,7 +1,7 @@
import os, sys
from bs4 import BeautifulSoup as bs4
-ranking_date = sys.argv[3]
+ranking_date = sys.argv[4]
subtitle = 'notowanie %s (%s), stan na %s' % (
sys.argv[1], sys.argv[2], '.'.join(ranking_date.split('-')[::-1])
)
@@ -18,4 +18,9 @@ script_src['src'] = '%s?%d' % ('_res/ranking.js', os.path.getmtime('http/_res/ra
rawlink = table.select('a#rawlink')[0]
rawlink['href'] = '%s/%s.csv' % (rawlink['href'], ranking_date)
+menu_file = file(sys.argv[3])
+menu = table.select('div.static-menu')[0]
+menu.clear()
+menu.append(bs4(menu_file, 'html.parser'))
+
print table.prettify().encode('utf-8')