-
Recent Posts
Archives
Meta
Tag Archives: api
Meaty Social Politics
If you’re sick of the constant political drivel on Facebook, check out the Meaty Social Politics extension for Chrome that @WhiteyOmits whipped up. It changes instances of ‘Obama’, ’Romney’, ‘Election’, etc. into paragraphs of bacon ipsum via our API.

It also has a snazzy icon. Well done sir!

P.S. I don’t care who you vote for, but you should still go vote.
API and jQuery Plugin updates
I’ve added support to the JSON API so you can generate one or more sentences of bacon ipsum rather than always generating paragraphs of text. Just pass ‘sentences=x’ as a parameter.
For example: http://baconipsum.com/api/?type=meat-and-filler&sentences=1
The jQuery plugin has also been updated to support sentences.
All the source code goodness has also been posted to GitHub if you want to dig into it a little more. Enjoy!
Git some bacon
Want to implement your own ‘insert-something-witty-here’ ipsum generator? Then head on over to our GitHub repository and take a look at the code that runs baconipsum.com. The BaconIpsumGenerator class is straight PHP code that can easily be modified to work as you see fit. I’ll be refactoring this code a bit since the Make_Some_Meaty_Filler method is wrapping stuff in HTML and it really should return an array of paragraphs and sentences so the API code can handle it better. It’s on my to-do list.
I also spent some time this weekend writing proper WordPress plugins for the site. Previously, the home page’s form was hacked into the WP theme, and the API was just a standalone directory with a PHP page. Now they’re both plugins and run based on WP actions & shortcodes. It really shouldn’t affect what you see on the site at all, but it makes me feel warm & fuzzy to have it coded properly now.
Enjoy!
jQuery Plugin
I whipped up a little Bacon Ipsum jQuery plugin that uses our API to generate some meaty goodness. When you’re mocking up a design, now you can use this plugin in your HTML rather than static text.
You can reference the plugin from our server or download it and use it locally.
http://cdn.baconipsum.com/api/jquery-BaconIpsum.js
The easiest way to use it is just to call the method with no options.
$(‘#placeholder’).BaconIpsum();
You can also pass in options.
$(‘#placeholder).BaconIpsum({ type:’all-meat’, paras:5, start_with_lorem:false });
$(‘#placeholder).BaconIpsum({ type:’meat-and-filler’, sentences:1, start_with_lorem:true });
- type: either ‘all-meat’ or ‘meat-and-filler’
- paras: number of paragraphs
- sentences: number of sentences (this overrides paragraphs)
- start_with_lorem: true or false to start the text with ‘Bacon ipsum dolor sit amet’
- no_tags: true or false, pass true to not wrap the return value in <p> tags
There’s a sample page on GitHub with some example code.
I don’t always test my code

I happy rolled out the API, did some basic testing and it all worked fine, but it was all from within the API’s own page. Sure enough, external calls weren’t working. I’ve done some tweaks to the PHP code and the sample code so it should all be working now.
Judiciously sprinkle over nachos
Ok, so JSON actually stands for JavaScript Object Notation, but who doesn’t like bacon on nachos?
Anyway, we’ve rolled out an API for bacon ipsum. You pass in what you want generated, we return a JSON string array of paragraphs. There’s some sample jQuery code too.
Give it a try and I hope to see various WordPress and jQuery plugins, browser extensions, etc. taking advantage of this in the future.