The Wayback Machine - https://web.archive.org/web/20090307182608/http://code.google.com:80/p/php-naked-day-api/
What's new? | Help | Directory | Sign in
Google
             
Code License: New BSD License
Labels: CSS, Styles, PHP, Standards, API
Show all Featured Downloads:
naked_day.zip
How to join?
Project owners:
  auldridgej, polvero

Welcome

Well, CSS Naked Day '08 has come and gone. The official site shows 2019 registered nudists--biggest year yet! Way to go everyone. More good news, I had 3 sites using this API to determine when to rip off their styles and all 3 worked flawlessly with the live config. Be sure to let me know if you experienced any issues with it.

CSS Naked Day

What is CSS Naked Day? Seems that would be a good thing to know before trying to work with this class. Read all about it on Dustin Diaz's CSS Naked Day page.

Naked Day Timer Class

The Naked Day timer class is a static class useful for determining if Naked Day is in progress, coming soon, or over. It also provides some methods for getting the configured day, month, and year of Naked Day as well as output a message to your visitors and output some text where your CSS would have been.

Quick Start

To start, download the "Featured Download" to the right named naked_day.zip and follow the instructions in the README.txt file contained within.

Having done that, you need to require or include the naked_day.php file into the PHP page you are working with:

require_once( 'naked_day/naked_day.php' );

You'll then need to initialize the class:

naked_day::init();

In that last example we have not passed any parameters to the init() method. Calling this method in that manner results in the code attempting to read the configurations from the config.json file which is hosted in the downloads section of this project. This process will be referred to as Live Config hereafter. Live Config will write the config file to the system and read from it instead of the web for the following 12 hours. After 12 hours, if init() is called with no params, the Live Config will read from the downloads section of this project again.

NOTE: using this methodology the code determines when naked day is based on what is in the Live Config file. This is fully automated and if you were to leave this code in place, and I were to edit the Live Config to make naked day right now, your CSS would be dropped if you had used this class to automate that action. Also, if the config file cannot be retrieved, the script will throw an exception. This is why I have used Google Code to host the Live Config file--reliability is a must.

NOTE 2: If you do not like the idea of the config being centrally managed by someone other than yourself, you can pass config parameters to init(). The first should be passed as false to disable Live Config. The others are properly documented in the Naked Day API Docs.

With all that out of the way, the class is loaded and initialized. Here are some examples of what you can do with it:

Conditionally exclude your CSS

<?php
if ( ! naked_day::today() )
{
    ?>

    <link href="/css/style.css" rel="stylesheet" type="text/css" media="screen,projection"/>

    <?php
}
else
{
    naked_day::css_replacement();
}
?>

This example checks to see if today is CSS Naked Day and allows your CSS to be printed if it isn't. If it is CSS Naked Day, it outputs the configured CSS replacement note into the source. Generally, this would be some sort of HTML comment like this:

<!-- CSS?
  It's naked day, didn't ya know it?
  Learn more at http://naked.dustindiaz.com
-->

Conditionally display a Naked Day explanation to your visitors

if ( naked_day::today() )
{
    naked_day::message();
}

This example checks to see if today is Naked Day and outputs the configured message to your visitors. If it is Naked Day, something like this would be echo'd into the source of your page:

<h3>What happened to the design?</h3>
<p>To know more about why styles are disabled on this website visit the
<a href="http://naked.dustindiaz.com" title="Web Standards Naked Day Host Website">Annual CSS Naked Day</a>
website for more information.</p>

Complete Interface

The full list of methods available to you are listed below and are well documented in the Naked Day API Docs.