Carl Worth [Wed, 21 Dec 2022 20:47:27 +0000 (12:47 -0800)]
Extend maxAge of cookies to be a full week
The other cookie properties set in this commit are the defaults.
We want a long cookie age so that sessions are as persistent as possible.
The default maxAge is unset, but apparently instead of that meaning
"never expire" it is interpeted by agents as meaning the cookie is
non-peristent (and the agent may delete the cookie on browser close).
Carl Worth [Wed, 21 Dec 2022 19:51:50 +0000 (11:51 -0800)]
Set session to be "rolling"
That is, the expiration of the session should be extended on every
request, (making the session last much longer as long as the user is
interacting with it).
This should help with any workaround I put in place for username
tweaking on the backend, (since Hyrum's iPhone is having trouble
setting his name).
Carl Worth [Wed, 21 Dec 2022 03:26:56 +0000 (19:26 -0800)]
Implement code to detect target image prompts with target seeds
When a user enters any of the 8 target prompts with the correct
corresponding seed, the server will now send the pre-generated image
for this.
Also, the server will immediately send a comment from ZomboCom,
(imitating the style of either HAL or GLaDOS to some extent), giving
the boys some indication that they are on the right track.
Carl Worth [Wed, 14 Dec 2022 22:47:35 +0000 (14:47 -0800)]
Make the server generate a non-random random seed occasionally
As often as every 6th image, (but only if a random seed is requested
and the word "dice" does not appear in the prompt), Zombocom will
generate a very-much not random seed of 319630254. This is precisely
the seed needed to generate the target image for the prompt that
includes dice in it.
Carl Worth [Sun, 11 Dec 2022 19:26:34 +0000 (11:26 -0800)]
Only generate a figcaption if image has both prompt and code
Up until now, every image of course has had both a prompt and a code.
But we're about to start introducting updates from Coda into the image
stream. We still want these to have support for comments, but they
shouldn't have a caption or a reuse button.
Carl Worth [Fri, 9 Dec 2022 17:34:46 +0000 (09:34 -0800)]
Bring newly-commented images up to the top of the feed
This won't disrupt any current clients, (which would be super
annoying), but for any refreshes or new visits to the page, they will
see the most-recently-commented images at the top of the feed.
Carl Worth [Fri, 9 Dec 2022 15:00:35 +0000 (07:00 -0800)]
Fix name tracking to be persistent
By adding both a variable to record in the client what the server has
told us the name is, and also adding localStorage storage of the name
so it persists between browser starts.
This behavior had some negative side effects. Most notably, it meant
that when reloading the website a user would see nothing until
generating a new image, (perhaps doing so for no other reason than to
see the history).
Another problem was that a spectator, (like Carl or Stacy), couldn't
silently watch along, but had to also create an image.
Meanwhile, the intent of this behavior was just to ensure each of the
boys saw a blank history on their first encounter with the web
site. Now that at least 3 boys have seen the site, there's not much
remaining need for this.
Carl Worth [Thu, 8 Dec 2022 16:45:43 +0000 (08:45 -0800)]
Validate numeric code before form is submitted
The image generation script will reject any non-numeric seed as well
as any value larger than 2**32-1. So enforcing this up front at the
form will give the user a better experience.
Carl Worth [Thu, 8 Dec 2022 16:22:20 +0000 (08:22 -0800)]
Don't show any images until the user generates a new one
This way, every new user will have a similar initial experience and
get forced to figure out the image-generation form before seeing
anything else on the page.
Carl Worth [Wed, 7 Dec 2022 19:58:07 +0000 (11:58 -0800)]
Limit generated filename to something not crazy
Since otherwise, with a crazy-long prompt, we could exceed the limit
of the filesystem, (which I think is 255 characters for what I'm using
for the server currently). In this commit, we don't use more than 200
characters from the prompt itself, to which we could add 10 from the
seed and another handful for separators and a file extension, so that
should be good.
Carl Worth [Wed, 7 Dec 2022 09:35:04 +0000 (01:35 -0800)]
Fix a mix-up of "code" vs. "seed"
The UI at the top-level facing the users uses "code", but the API down
deep uses "seed" so there has to be a switch at some point, which
wasn't quite correct before this fix.
Carl Worth [Wed, 7 Dec 2022 07:55:29 +0000 (23:55 -0800)]
Add generate_image.py script
Which uses the dreamstudio interface to Stable Diffusion to generate
images from a text prompt. This does require an API key and has non-zero
cost, but I'm willing to do this for now, (and fortunately, the Stable
Diffusion code itself is entirely open-source so I could switch to my
own hardware when I decide to).