FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home » Hacking » Pimp out your FeedBurner Count

by 2 comments

wink

Alot of you have contacted me about the FeedBurner FeedCount image on AskApache. Most people are curious as to how I can display custom text and colors. Also there have been alot of questions about how I get it to change colors with every page view. Here you go!

Customizing the FeedCount Image

There are several parameters that can manipulate the feedcount image by adding them onto the feedcount image url. For example, my image url is http://feeds.askapache.com/~fc/apache/htaccess, so I just add on any of the following... Play around with them, they aren't documented officially.

bg
Specify the background color for the feedcount image, like bg=3366CC
fg
The font color for feed count fg=333333
anim
If 0, it won't animate. If 10, it will animate 10 times.. or 50 anim=50
label
This lets you specify a custom label built in to the image, instead of "readers".. like label=AxeApache

Loading Different FeedCount Images

I simply came up with 10 image configurations I liked using the GET parameters above, then I wrote a script to download all 10 of them to my server every 15 minutes. Next I setup a simple mod_rewrite rule in .htaccess that allows me to serve any of the 10 images using 1 url.

So when a user requests my feed image at http://s.askapache.net/feed.gif, they will in fact be seeing 1 of the 10 images, because their is no /feed.gif image.

Making feed.gif Never Cache

In order for the image to be reloaded on each page-view of the site, I set up some anti-caching headers in my .htaccess file.

First I unset the far-future Expires headers that I normally send with images, and then I instruct browsers to check the image every request to see if it has been modified.

<FilesMatch "^feed(1|2|3|4)?\.gif$">
Header unset Expires
Header unset Last-Modified
FileETag None
Header set Cache-Control "no-cache, must-revalidate"
</FilesMatch>

Rewriting feed.gif to feed1-4.gif

I save the 4 images in their own folder, so the rewrites only apply to them. This loads a different image file depending on the second of the request.

Update!
This code works even better than the one below it but you have to have all 10 images.

RewriteEngine On
RewriteBase /

RewriteCond %{TIME_SEC} ^.([0-9]) [NC]
RewriteRule ^feed\.gif$ /feed%1.gif [NC,L]
RewriteEngine On
RewriteBase /
RewriteRule !\.gif - [S=4]

RewriteCond %{TIME_SEC} ^(0|4|8|12|16|22|26|30|34|38|42|46|50|54|58)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^feed\.gif$ /zi/feed1.gif [S=3]

RewriteCond %{TIME_SEC} ^(1|5|9|13|17|23|27|31|35|39|43|47|51|55|59)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^feed\.gif$ /zi/feed2.gif [S=2]

RewriteCond %{TIME_SEC} ^(2|6|10|14|18|24|28|32|36|40|44|48|52|56|60)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^feed\.gif$ /zi/feed3.gif [S=1]

RewriteCond %{TIME_SEC} ^(3|7|11|15|19|25|29|33|37|41|45|49|53|57)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^feed\.gif$ /zi/feed4.gif

Bash Shell Script

This simple shell script is what I use, it downloads 4 different feedcount images with different background/foreground colors and with custom labels. It saves them to the BASE folder.

#!/bin/bash
umask 022

BASE="/web/askapache.com/i/feed"
FEEDURL="http://feeds.askapache.com/~fc/apache/htaccess?bg="
FEEDOPT="&fg=FFFFFF&anim=1&label="
CURLOPTS="-s -S -L -A 'Mozilla/5.0' -m 400"

curl $CURLOPTS -o ${BASE}1.gif ${FEEDURL}3366CC${FEEDOPT}chilling
curl $CURLOPTS -o ${BASE}2.gif ${FEEDURL}333333${FEEDOPT}smoking
curl $CURLOPTS -o ${BASE}3.gif ${FEEDURL}228800${FEEDOPT}on%20fire
curl $CURLOPTS -o ${BASE}4.gif ${FEEDURL}BB0000${FEEDOPT}loving

exit 0

Crontab Entry

This crontab runs the above shell script every 15 minutes, ensuring you have an up-to-date feed count.

*/15 * * * * /web/cron/feedcount.sh &>/dev/null

FeedCount

FeedCount is another cool way to promote your feed. It is a dynamic graphic that always displays your feed's current circulation, as calculated by FeedBurner. Choose its color scheme and an animated or static appearance; it is yours to customize!

See how this looks.

Pimp out your FeedBurner Count

Feed Image Burner

Add some color to your feed. Place a special image in your feed so that it stands out from the pack when displayed in many popular RSS news readers. This service Adds an image tag block to your feed, which refers to the web location of the image you choose below. Most RSS readers display this image in either individual or grouped views of the news items in a feed. If you provide your own image, it is recommended to be no more than 144 pixels tall or wide.

Pimp out your FeedBurner Count

Pimp out your FeedBurner Count Pimp out your FeedBurner Count Pimp out your FeedBurner Count Pimp out your FeedBurner Count Pimp out your FeedBurner Count Pimp out your FeedBurner Count

Advanced FeedBurner Stats

Thats it! Not very impressive technically, but a cool thing to have on your site.. the changing colors and custom labels work great at grabbing peoples attention.

Tags

Comments Welcome

Information is freedom. Freedom is non-negotiable. So please feel free to modify, copy, republish, sell, or use anything on this site in any way at any time ;)

My Online Tools

Popular Articles
Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two.
-- Richard M. Stallman


It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

+Askapache | htaccess.io | htaccess.guru

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service | @Htaccess

↑ TOPMain