Mostly an excuse for me to learn JavaScript (and now pjax) TBH. See it in action:
- WTF is my Blockchain Strategy
- WTF is my Open Data Strategy
- WTF is this week's Uber for Cats
- WTF is my BBC The Big Questions Topic
You should probably fork it first, then
git clone http://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:
A 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
A 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
One 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:
- Nesting templates to stupid depths, as mentioned above
- Using a particular @placeholder more times than there are items in that list - items are removed from the lists as they're subbed into the template. On that note:
- Using a @placeholder for which you have no items at all - it blew up for me because of a stupid typo
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: http://github.com/pikesley/wtfismygenericthing
colour: '#fa8100'
homepage:
name: sam
url: http://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 Bootswatch
You should be able to run it with
bundle exec rackup
and then point your browser at http://localhost:9292/. And it should deploy straight onto Heroku no bother
As ever, I regret nothing