where i'm from screenshot

I finished the first part of my #NaNoGenMo project, a “Where I’m From” poem generator.

click meeee for poetreeee

It’s nothing fancy, but I’m really pleased with how it turned out.

Some technical notes:

  • Much of the generated language comes from RiTA, which I installed through Node, a JavaScript package/project manager. I then added Express to serve the page (though I’m using it at the very fringe end of its abilities — basically I took the ‘Hello world!’ tutorial and just stuck my poem there).
  • The rest of the language comes from word lists, collected and curated by various sources, including me. I’m especially proud of the “trees” (I made a list of tree start and end words and it randomly combines them into pairs or trios) and the beverages — again I made a list of drink adjectives (hot, spiced, tropical) and drink nouns (coffee, lager, juice) and mashed them up.
  • The quotes come from a not-very-scientific google search for “short quotes” plus a bunch of novel starting sentences. I could probably add more options and clean up what’s there, but it’s big enough to stay interesting for the time being.
  • To expand on what’s happening here, the entire app is basically one file (index.js) where I’m requiring the various word list files, assigning each word variable to a source, and building the poem as a string object. Express then runs a server and assigns the GET command on “/” (what happens when you load a webpage at its root) to run a JavaScript function that renders the poem. To add a header and some html links, I built them into the long string that is the poem (and all the other text on the page).
  • I had to tinker with the loading a bit, because originally the page was not loading new content on refresh. This is due to how and when I assigned the variables, and I fixed it by moving everything inside a function that gets called each page load.
  • Done *correctly*, Express can render an html template instead! Html was not playing nicely with all the JavaScript ‘requiring’ I’m dependent on, so I’m content with a simple text page for now.
  • Did I mention I usually code in Ruby? I love Ruby. This is not Ruby! You can checkout the repo here for more details.

I needed a quick pick-me-up today (job hunting is brutal, y’all), and this hit the spot. I hope you enjoy!

Where I’m From