Blog postings
After many requests, I updated the wordle assistant so that you can exclude letters from certain positions, and not just overall. Why not give it a try. Let me know if it breaks.
Can't think of much more I can do with that. I am somewhat loth to remove stuff from the dictionary because the Wordle valid answer list is a moving target, so if I just put everything in there then it should be OK in the end.
Might make it a web service. You provide a JSON of the form contents and you get a list of potential answers back.
Or possibly I would do it for dice rolls. Number between 1 and 6 as a Service.
So after going to all that hassle of getting sitemap.xml working it seems I have to implement IndexNow to ping Bing and other web greppers whenever I post stuff. Urgh. Not too bad, really.
- Generate a key, some random hex string that is quite long and hard to guess. You can even generate a key online.
- Make a key.txt file. Not too bad in Django. Store your key as an environment secret; load it in settings; create a url that looks for key.txt; have a really simple template that renders it. I called the key
INDEXNOW_KEY.
The URL I added to urls.py is:
path(f"{settings.INDEXNOW_KEY}.txt", TemplateView.as_view(template_name='INDEXNOW_KEY.txt', extra_context = {'key': settings.INDEXNOW_KEY}))
Template fileINDEXNOW_KEY.txt
is really simple:{{ key }}
- Make a ping_bing() function, almost exactly like ping_google(), but you'll need to construct your new object's URL rather than just telling it to read the sitemap (this is all ping_google() does). The bing URL is
https://www.bing.com/indexnow?
; you need two things in the query string, aurl
pointing to your new object and thekey
. You can usebing_url + urlencode({'url' : your_object_url, 'key' : settings.INDEXNOW_KEY })
, and then feed this tourlopen()
- Amend relevant
save()
methods to ping bing when called. (I am not going to submit everything; bing already has sitemaps and any other web crawler should pull those as well the first time they come across my site) - That is all that you need to do. It's nice watching the logs as
<key>.txt
is pulled, and then you can use Bing webmaster tools to verify that your object has been submitted. - And then I found a bug and had to recommit!
I must be delicious. Here's a snap
This turned out to be both very easy and fiendish.
I have a thing called CKEditor that lets me do things like upload image files. This is already set up to point at my AWS S3 bucket to store uploaded media files. I wanted to use the Cloudfront CDN to distribute them. So I had some fun and games to do this...
- go into AWS and create a Cloudfront distribution which points at the S3 bucket
- Discover that you need an SSL certificate from Amazon for your domain, and they'll only give it to you if you go through some CNAME fun and games to authenticate your ownership of the domain
- Create another SSL cert as it needs to be made in the US, not the UK datacentre, there is a small dropdown you need to watch out for, so more CNAME thrashing
- Finally create a CNAME that points from assets.rkdouglas.co.uk to the cloudfront distribution itself
- Tell Django to use cloudfront URLs for media uploads - the
S3Boto3Storage
subclass you made when getting S3 uploads working in the first place has acustom_domain
attribute you point at your assets.rkdouglas.co.uk equivalent - Realise that all the stuff is hardcoded to point at S3 already, so log in to PSQL and issue an update command to rewrite S3 links to CDN links
I spent hours doing this. Documentation is poor. If you find this via Google you are welcome.
Did 7.73km in 55:04 which is a bit faster than the other day. Also there are altocumuli in the sky. Nice.