Wednesday, May 13, 2009

How to Make a Label Post in Blogger

If you're using blogger and know some UNIX it's pretty simple to make a label post for your blog. Yes you could do this with a widget, but then you might miss a chance to use sed.


First go to the Dashboard.


Click on 'Edit Posts' and then the manage posts page should have all of your labels on the left side.


Go to your browser and view the source. Save the source to a local file - in this case it's posts.g.html.


Next go to your UNIX terminal and select only the labels for your blog using:

grep "apply_" post* | sed -e 's/<\/option>/\
/g' | sed -e :a -e 's/<[^>]*>//g;/ temp.1

Go ahead and remove any spaces at the start of a line:

sed -e 's/^ //g' temp.1 > temp.2

Format the labels as a URL anchor with the /search/label blogger path. You should of course replace www.boldlentil.com with your blog name:

sed -e 's/ /%20/g' temp.2 | awk '{printf ("<a href=http://www.boldlentil.com/search/label/%s&g;t\n", $1)}' > temp.url

Finally create the anchor text and paste the pieces together:

awk -F : '{printf ("%s</a>, \n", $1)}' < temp.2 > temp.sa
paste temp.url temp.sa | awk -F ~ '{printf ("%s ", $1)}' > temp.ml

Paste the resulting HTML in the Edit HTML view for writing a new post:


37, al Qaeda, al Zawahiri, Alcatraz, amigos, ammonites, andre the giant, Andy Goldsworthy, angel, angle, annoyance, app-engine, arcade room, artichoke, Aspasia, Atlanta airport, attention, azkaban, backwards post, bad McLuhan pun, baidu, Bansky, barcelona, basketball, Beaver Falls, binder clip, Bloc Party, blogging, blogoflat, blög, Bottom of the Hill, boulders, bouncing ball, brazil, bromeliads, bucket, Buddha's hand citron, buddies, BugRank, bulgaria, bus stop, Bush, calculadora, calculator, CAPTCHA, carnegie international, carry-by, cartoons, carved lids, cat, cellophile, cellular automata, chew lips, Chomsky, cloud calculator, coast starlight, comments, computers, constult, corpus linguistics, cross-blogging, crowdsourcing, curve, dachshund, dan black, David Lesar, david shrigley, dead moose, delucidate, devils tower, diachronic post, divide by zero, dots, dried fallen oak branches, dried flower, drip, Dubai, duck-milker, durian, ear-witness, economy, Elvis, estarcido, explicandum, fake, fengyun bang, files, filing, filing cabinet post, flag lapel pin, foof, freeland, fruit, fuzzy math, geo-stencil, get well soon, glasses, goals, Granada, Grand Ole Party, Halliburton, halloween, hapax legomenon, Helsinki, horus, house slave, iframe, imágenes, in-situ measurement not recommended, inflatable animals, intelligent design, ira, James Joyce, james yuill, Joe Biden, Karl Rove, keywords, Kuwait, labels, laccolith, large eyes, large print, lean blogging, leaves, Legos, lemma, leopard, lesbian Wiccan Texan cellists, links, lists, lobster, Louise Bourgeois, low vision, lucuma, lynkbaiters, macaroni and cheese, maverick, mavericks, mayonnaise, mccain, memory, Merch, metronomy, Michael Palin, mixpost, mnemonic, mnemosyne, monkeys, monolith, moose, mosaics, muda, mullet, narratives, ni, night runner, ninja. ninja kick, non-dairy whipped topping lid, Not On My Island, notes, obama, objects, oboe, obtuse, oil, old years resolution, olympics, p.o.n.d., palin, pals, panga, partial success vs none, personal space, phat thu, pi, piles, Pittsburgh, playpost, plugs, pneumatic, Portland, president bh, proper respects, pumpkin, python comments with non-ascii, pöst, quarry, quotes, reference sheet, reremembered words, reverse long tail, robot, rock, roman, roof, saccades of beauty, Salvador Dali, Sarah Palin, school of seven bells, sculpture, seen, sertão, seven, shelf, shoe, signs and symbols, skull, snowflakes, software divergence, spanish, sphinx, spider, spiritual design, spleen, steady hitter, steganblography, stencil, sticker, sticks, strange activity, super-cross-linky, sweaters, symbol hunter, tabula rasa, tabula rasa engineering reference sheet, tag cloud, tags, tamarillos, tesserae, the big pink, the shortwave set, thirsty, tips, title is the tip, toast, tonterías, tools, train, transformer, translucency, triple-r, twitter, Ulysses, unique Englishes, videos, Voronoi Diagrams, w, walking, walks into a bar joke, water-cooler test, whinging, wiener dog, wink, wrestling moves, wyoming, youtube vs itunes, π, Ἀσπασία, 搜索风云榜,