Twis (present tense of “twas”?) not a real big demand on the internet for the kind of silly randomness I spat out to make a web toy that generates random utterances about AI using the quotes of Agent 007’s gadget master, Q.
And there’s still place and value to do these things without just reachhig for ChatGPT method of Prompt, Copy, and Paste. This was one of a fleet of obscure random generating amusements done for my audience of 1 (me).
They had all been first set up to have a button proving a means to blip a generated nugget to Twitter (the platform I only will refer to as Twitter), (shown here as screencap because nobody can really be sure if a tweet can be viewed).
It’s not terribly complex to create a hypertext link to share on Twitter (not saying it again), of course , there’s no being sure when its supreme commander will arbitrarily take it away. Just make a link that looks like:
This opens a window where the person who clicks can just tweet out as is, or modify it.
The thing is… I barely use Twitter, under under extreme circumstances — I did login to test it for the new generator, here is a link that only works for the those who are Twitter Not Impaired.
I’ve already written too much but basically the old way had
After publishing my post, my back brain kept whispering…. why not change the button to share to Mastodon?
I had after all, discovered recently MastodonShare that does the same thing via the same URL structure
What is slick is he first time a visitor uses this link, it asks for their instance name, from whence the share screen is generated. From then on, the instance is saved as a cookie so te next share will go directly.
I could just change it out, but heck, some people actually use the Platform Formerly Known as a Better Platform, so my first approach was to add a second button.
I was going to detail the code changes, but I doubt anyone reall cares that much- I do have comments, with occasional sarcasm. And function names like
share_it_like_a_bluebird. One could compare the first commit with the new Q generator, where the share button was a single link and the current version where what is changed is:
- Link changed from an ugly button image reading “tweet” to a bootstrap class rendering a button with svg icons
- Options from calling function to send twitter and mastodon username to credit, by sending a blank string for parameters, it hides the button
- A more generalized function to build the button that is less brute forced concatenated
- Also added opengraph tags to template for spiffer social sharing
Who really cares? Well, these little generators are just toys, but now having some chops building the Mastodon share capability can come into use.
More than that, there’s pride in going through the iterative process of trying a new function, modifying and improving, as opposed to asking ChatGPT to spit out code you try, and then nag, the prompt continuously until maybe you are lucky it works. Both are iterative, yet I wonder which approach teaches you more. I do not doubt one could learn from analyzing and studying the code generated for you, but I’d bet most people will just keep banging until it works and not caring too much about understanding.
Look! Proof is in the tooting: