X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=html_generator.py;h=e337f08034dce8d0f0a19909b2c78351f96d1bdd;hb=976a9bcf02620a4b1aec2a180efbc0d741a212ce;hp=9eee85c95f1fcf62d9a47a4214c398743c3f6dc5;hpb=d0fb115838dd90a089cd44ecd63fc84c84389ce6;p=turbot-web diff --git a/html_generator.py b/html_generator.py index 9eee85c..e337f08 100644 --- a/html_generator.py +++ b/html_generator.py @@ -14,11 +14,29 @@ that would be great Requires sorttable.js, which should be included """ +import boto3 from boto3.dynamodb.conditions import Key +import os +import re +import sys + +WEBROOT = "/srv/halibut.cworth.org/www" website = "https://halibut.cworth.org/" #change this if we're using AWS or some other subdomain instead +def hunt_file(hunt, name): + """Return a path file 'name' within the given hunt. + + This will be withing WEBROOT and in a hunt-specific path.""" + + return "{}/{}/{}".format(WEBROOT, hunt['channel_id'], name) + +def filename_from_name(name): + """Returns a string derived from name, but with all spaces and slashes + replaced with underscores, (for making a clean filename)""" + return re.sub(r'[ /]', '_', name) + def channel_url(channel_id): """Given a channel ID, return the URL for that channel.""" @@ -84,7 +102,7 @@ def hunt_info(table, hunt_id): rounds = list(rounds) rounds.sort() - return puzzles, rounds + return hunt, puzzles, rounds def round_stat(rnd, puzzles): #Counts puzzles, solved, list of puzzles for a given round @@ -116,7 +134,7 @@ def round_stat(rnd, puzzles): -def overview(puzzles, rounds): +def overview(hunt, puzzles, rounds): #big board, main page. saves as index.html start = ['\n', '\n', @@ -124,7 +142,7 @@ def overview(puzzles, rounds): ' \n', ' \n', '\n', - ' \n', + ' \n', ' \n', '\n', '