Mostly an excuse for me to learn JavaScript (and now pjax) TBH. See it in action:
You should probably fork it first, then
git clone //github.com/you/wtfismygenericthing
cd wtfismygenericthing
bundle
bundle exec rake
You’ll want to do some customisation or it’ll be a bit shit
There are some sample data files in data. The key ones are:
headings.ymlA list of titles, one of which will be randomly chosen. Probably something along the lines of
headings:
- Stop what you're doing and look at this, my blockchain strategy is
Note: EVERYTHING gets upcased when it’s rendered, it’s just easier that way
templates.ymlA list of skeletons for the robots to randomly select and then populate, with hilarious effect. Maybe
templates:
- to use @animals and @people to mine bitcoins
or similar
Note: those @placeholder words are important, more later
responses.ymlOne of these will be randomly picked as the text for the ‘Give me another’ link.
responses:
- this is shit, try again
you know the sort of thing
The rest of the data files will be used to randomly populate the templates. I’ve used the convention of one-file-per-list, but the code does not care TBH - you can mash them all into the same YAML file as long as they’re namespaced like this
animals:
- dogs
- cats
people:
- Edsger Dijkstra
- Beyoncé
You can have something like @things and also @things in a template, which will replace each occurrence with a different item from things as long as there are enough items in things to cover the bet. More on How Not To Fuck Things Up below
It’s perfectly cromulent to put @placeholders in these lists, so you can have:
things:
- @adjective bananas
adjective:
- furry
- straight
or whatever. In theory, this works to arbitrary depth (the tests go 2 levels down, at least) but it will presumably explode in your face if you attempt to take the piss. Speaking of which:
I can think of at least these things that will make it not work:
Your customisations will have broken the tests, specifically this Cuke (yes, the app generates JSON underneath, all the fun stuff happens client-side). You may not really care, but you won’t be able to get Travis to automatically deploy to Heroku with a failing test. The (terrible, but easy) solution is to copy-actual-to-expected (or delete that line) and just move along
There’s also a config/config.yml:
title: Wtfismygenericthing
#ga_tag: UA-1974-1
github_corner:
url: //github.com/pikesley/wtfismygenericthing
colour: '#fa8100'
homepage:
name: sam
url: //sam.pikesley.org
bootswatch: flatly
title is for the <title> tagga_tag is for a Google Analytics tag, if you have onegithub_corner takes a URL and a hex colour for the Fork me on Github thinghomepage is for your homepage and name, to go in the footerbootswatch is an entirely optional identifier for a Bootstrap theme from BootswatchYou should be able to run it with
bundle exec rackup
and then point your browser at //localhost:9292/. And it should deploy straight onto Heroku no bother
As ever, I regret nothing