X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=html_generator.py;h=f18703211897d73f90fdec216645e24f22a53e33;hb=HEAD;hp=0950d6f4212db82f8b24a9874416dc992dfb6195;hpb=69ca8f924191441a382b46a446457c8df2a62ebc;p=turbot-web diff --git a/html_generator.py b/html_generator.py index 0950d6f..f187032 100644 --- a/html_generator.py +++ b/html_generator.py @@ -16,10 +16,25 @@ 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 @@ -91,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 @@ -123,13 +138,14 @@ 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', '
\n', ' \n', ' \n', + ' \n', '\n', ' \n', ' \n' '\n', - ' \n' + ' \n', '\n',] columns = ['{}
\n'.format(link(website + "index.html", 'Hunt Overview')), + '{}
\n'.format(link(internal_link(hunt, "index") + ".html", 'Hunt Overview')), '{} | \n'.format(elink(slack_url, puzzle['name']+meta)), '{} | \n'.format(elink(puzzle.get('url',''), 'Puzzle')), '{} | \n'.format(elink(puzzle['sheet_url'], 'Sheet')), - '{} | \n'.format(link(website + filename_from_name(puzzle['name']) + '.html', 'Overview')), - '{} | \n'.format(puzzle['solution']), + '{} | \n'.format(link(internal_link(hunt, filename_from_name(puzzle['name'])) + ".html", 'Overview')), + '{} | \n'.format(", ".join(puzzle['solution']).upper()), # '\n', - ' | {} | \n'.format("".join(puzzle.get('tags',[]))), + '{} | \n'.format(", ".join(puzzle.get('tags',[]))), ' \n'] else: puzzle_list += [ '
{} | \n'.format(elink(slack_url, puzzle['name']+meta)), '{} | \n'.format(elink(puzzle.get('url',''), 'Puzzle')), '{} | \n'.format(elink(puzzle['sheet_url'], 'Sheet')), - '{} | \n'.format(link(website + filename_from_name(puzzle['name']) + '.html', 'Overview')), + '{} | \n'.format(link(internal_link(hunt, filename_from_name(puzzle['name'])) + ".html", 'Overview')), '\n', # ' | \n', - ' | {} | \n'.format(" ".join(puzzle.get('tags',[]))), + '{} | \n'.format(", ".join(puzzle.get('tags',[]))), '