X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=html_generator.py;h=0fef3d421c3f1b9158a7e97932f07b43342b24a6;hb=99dee2f570cb7f91f410ff64895f877db0bb5fe5;hp=3ee751c989348e6c5004ec399fa6dc403f4972be;hpb=72e26f791228ad95c4cc5bd67eba4e0d23396f63;p=turbot-web diff --git a/html_generator.py b/html_generator.py index 3ee751c..0fef3d4 100644 --- a/html_generator.py +++ b/html_generator.py @@ -16,10 +16,30 @@ Requires sorttable.js, which should be included """ import boto3 from boto3.dynamodb.conditions import Key +import os import re +import sys -website = "https://halibut.cworth.org/" -#change this if we're using AWS or some other subdomain instead +WEBROOT = "/srv/halibut.cworth.org/www" + + +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 internal_link(hunt, name): + """Returns a path for a link on this site.""" + + # Just generate a relative link, (which is just the name itself) + return "{}".format(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.""" @@ -86,7 +106,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 @@ -118,7 +138,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', @@ -126,7 +146,7 @@ def overview(puzzles, rounds): ' \n', ' \n', '\n', - ' \n', + ' \n', ' \n', '\n', '