UPDATE: I have came up with a better zero-maintenance solution thanks to a comment by Dustin. The one bellow will still work, you just have to maintain the date constant that is defined at the top of the handler.
I kinda like the idea of CSS Naked Day, which was thought up by Dustin Diaz (a Google fellow) a couple of years ago. I have decided to participate. If you have a personal web site, I would encourage you to do the same. If your web site runs on ASP.NET (highly recommended), you can use the HTTP handler below. I wrote it today and am implementing on my blog. On CSS Naked Day, which is defined at the top of the handler in a constant, it will return a 404 HTTP status code for each and every request for a .css file. You just have to change this date every year and you'll be all set without having to modify any markup or move around files. Your blog engine might already have an HTTP handler setup to intercept .css file requests. If that is true, you can just reference my handler and modify your current one accordingly. Here is the code in VB.NET (attention crazy people: go here to convert to C#)…
Imports System.IO Imports System.Web Public Class Naked Implements IHttpHandler Const NAKED_DAY As Date = #4/9/2008# Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements IHttpHandler.ProcessRequest Dim Response As HttpResponse = context.Response Dim Path As String = context.Request.PhysicalPath If File.Exists(Path) AndAlso Date.Today <> NAKED_DAY Then Response.ContentEncoding = Encoding.UTF8 Response.ContentType = "text/css" Response.WriteFile(Path, False) Else Response.StatusCode = 404 Response.Close() End If End Sub End Class
To implement this handler into your ASP.NET web site, simply modify the <httpHandlers> element within <system.web> as illustrated below…
<system.web> <httpHandlers> <add verb="*" path="*.css" type="Naked" validate="false"/> </httpHandlers> </system.web>
Talk about easy! ASP.NET freakin' rules. It's uncomparable to Pretty Horrific Programming, I can tell you that much.
http://php-naked-day-api.googlecode.com/files/config.json
Guess What?
There are a few basic guidelines you should be aware of before leaving a comment…
- If you choose to display your email address, it will not be detected by spam bots
- Comments are limited to 3,000 characters; so far you have used none of them
- HTML will be encoded; links and line breaks will be converted automatically
- Comments containing five or more links will be subject to moderation
