Pimp out your FeedBurner Count
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 https://www.askapache.com/s/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.
Header unset Expires Header unset Last-Modified FileETag None Header set Cache-Control "no-cache, must-revalidate"
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!
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.
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.
« Notes from Apache HTTPD Source CodeNew Version of Password Protection Plugin »
Comments