]> git.cworth.org Git - turbot-web/log
turbot-web
2 years agoAbstract out the filename_from_name function
Carl Worth [Wed, 12 Jan 2022 08:20:40 +0000 (00:20 -0800)]
Abstract out the filename_from_name function

Previously, there were many, many places i nthe code performing a
calculation of:

"_".join(name.split())

in order to replace all spaces with underscores before using a name as
a filename.

But as we determined recently, this is insufficient as we at least
need to also replaces all '/' with an '_' as well (to ensure that the
filename looks like a filename and not a directory plus a filename).

The previous fix for the '/' in one place, (immediately before writing
the file), meant that all the other places that were emitting links to
that file were now wrong.

We can ensure everything is consistent by having a single function for
all instances of this filename generation which we do here with the
new filename_from_name() function.

2 years agoMake the code robust against a puzzle without some fields
Carl Worth [Wed, 12 Jan 2022 08:12:58 +0000 (00:12 -0800)]
Make the code robust against a puzzle without some fields

Specifically, some puzzles may be missing any of the 'rounds', 'tags',
or 'url' keys. Previousl, the code was crashing whenever this was the case.

With this commit, empty strings or empty lists are used as the values
for any missing keys as appropriate.

2 years agoReplace slashes in puzzle name to create a filename
Carl Worth [Wed, 12 Jan 2022 08:11:31 +0000 (00:11 -0800)]
Replace slashes in puzzle name to create a filename

Otherwise, the open will fail with a "directory does not exist" error message.

Thanks to MH 2021 for including a puzzle with a '/' in its name to
exercise this bug.

2 years agoAdd missing import of boto3
Carl Worth [Wed, 12 Jan 2022 08:07:18 +0000 (00:07 -0800)]
Add missing import of boto3

Otherwise, this code wasn't going to work at all.

2 years agoDrop the top-level "turb" data structure
Carl Worth [Wed, 12 Jan 2022 08:05:06 +0000 (00:05 -0800)]
Drop the top-level "turb" data structure

In the original turbot code, this was a simple structure to hold on to
all the things necessary for turbot. Specifically, it had a boto
connection to the database, a handle for the Google sheets API, and a
handle for the Slack client API.

In this code, the only one of those things we talk to is the DynamoDB
table so that's all we need here.

2 years agoCopy in the channel_url function
Carl Worth [Wed, 12 Jan 2022 07:59:35 +0000 (23:59 -0800)]
Copy in the channel_url function

To make turbot-web a little more self-contained.

2 years agoDelete trailing whitespace
Carl Worth [Wed, 12 Jan 2022 07:56:07 +0000 (23:56 -0800)]
Delete trailing whitespace

Just to keep my editor happy.

2 years agoConvert all files from DOS to Unix text file format
Carl Worth [Wed, 12 Jan 2022 07:54:46 +0000 (23:54 -0800)]
Convert all files from DOS to Unix text file format

Since otherwise I'm going to be strufflign when editing these files.

2 years agoInitial import of turbot-web code
Carl Worth [Wed, 12 Jan 2022 07:52:31 +0000 (23:52 -0800)]
Initial import of turbot-web code

Thanks to Avram Gottschlich for writing all of this code.

This is as it was delivered to Slack as "big board.zip" on 2022-01-09.