Skip to content

Commit

Permalink
Cleaned up some stuff, added @lgnap as a contributor.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtronic committed May 8, 2014
1 parent 4000d07 commit e42fd1d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 60 deletions.
60 changes: 30 additions & 30 deletions config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$config = array(
$config = [
// {{{ Environments

'environments' => array(
Expand All @@ -11,82 +11,82 @@
// }}}
// {{{ PHP Options

'php' => array(
'local' => array(
'php' => [
'local' => [
'date.timezone' => 'Universal',
'display_errors' => true,
'error_reporting' => -1,
'session.gc_maxlifetime' => 86400,
),
'production' => array(
],
'production' => [
'date.timezone' => 'Universal',
'display_errors' => false,
'error_reporting' => -1,
'session.gc_maxlifetime' => 86400,
),
),
],
],

// }}}
// {{{ PICKLES Stuff

'pickles' => array(
'pickles' => [
'disabled' => false,
'session' => 'files',
'template' => 'index',
'module' => 'home',
//'404' => 'error/404',
'cache' => 'memcached',
'profiler' => array(
'profiler' => [
'local' => false,
'production' => false,
),
'logging' => array(
],
'logging' => [
'local' => true,
'production' => false,
),
'minify' => array(
],
'minify' => [
'local' => true,
'production' => false,
),
),
],
],

// }}}
// {{{ Datasources

'datasources' => array(
'local' => array(
'memcached' => array(
'datasources' => [
'local' => [
'memcached' => [
'type' => 'memcache',
'hostname' => 'localhost',
'port' => 11211,
'namespace' => 'holidayapi',
),
),
'production' => array(
'memcached' => array(
],
],
'production' => [
'memcached' => [
'type' => 'memcache',
'hostname' => 'localhost',
'port' => 11211,
'namespace' => 'holidayapi',
),
),
),
],
],
],

// }}}
// {{{ Security Options

'security' => array(
'security' => [
'login' => 'login',
'model' => 'User',
'column' => 'role',
'levels' => array(
'levels' => [
0 => 'ANONYMOUS',
10 => 'USER',
20 => 'ADMIN',
),
),
],
],

// }}}
);
];

?>
18 changes: 9 additions & 9 deletions modules/v1/holidays.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class v1_holidays extends Module
{
public function __default()
{
$payload = array('status' => 200);
$holidays = array();
$payload = ['status' => 200];
$holidays = [];

try
{
Expand All @@ -23,7 +23,7 @@ public function __default()

$year = $_GET['year'];
$month = isset($_GET['month']) ? str_pad($_GET['month'], 2, '0', STR_PAD_LEFT) : '';
$day = isset($_GET['day']) ? str_pad($_GET['day'], 2, '0', STR_PAD_LEFT) : '';
$day = isset($_GET['day']) ? str_pad($_GET['day'], 2, '0', STR_PAD_LEFT) : '';
$country = isset($_GET['country']) ? strtoupper($_GET['country']) : '';
$date = $year . '-' . $month . '-' . $day;

Expand All @@ -38,7 +38,7 @@ public function __default()
$cache_key = $country . '-holidays-' . $year;
$country_holidays = $this->cache->get($cache_key);

//if ($country_holidays === false)
if ($country_holidays === false)
{
$country_file = '../countries/' . $country . '.json';

Expand All @@ -48,7 +48,7 @@ public function __default()
}

$country_holidays = json_decode(file_get_contents($country_file), true);
$calculated_holidays = array();
$calculated_holidays = [];

foreach ($country_holidays as $country_holiday)
{
Expand All @@ -69,14 +69,14 @@ public function __default()

if (!isset($calculated_holidays[$calculated_date]))
{
$calculated_holidays[$calculated_date] = array();
$calculated_holidays[$calculated_date] = [];
}

$calculated_holidays[$calculated_date][] = array(
$calculated_holidays[$calculated_date][] = [
'name' => $country_holiday['name'],
'country' => $country,
'date' => $calculated_date,
);
];
}

$country_holidays = $calculated_holidays;
Expand All @@ -94,7 +94,7 @@ public function __default()

if ($payload['status'] == 200)
{
$payload['holidays'] = array();
$payload['holidays'] = [];

if ($month && $day)
{
Expand Down
15 changes: 2 additions & 13 deletions templates/__shared/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,8 @@
ga('create', 'UA-46049009-1', 'holidayapi.com');
ga('send', 'pageview');
</script>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
<a class="addthis_button_linkedin_counter"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-529535354cd72841"></script>
<!-- AddThis Button END -->
<?php
$honey_pots = array(
$honey_pots = [
'<a href="http://holidayapi.com/iratedungeon.php"><!-- chap-capability --></a>',
'<a href="http://holidayapi.com/iratedungeon.php"><img src="chap-capability.gif" height="1" width="1" border="0"></a>',
'<a href="http://holidayapi.com/iratedungeon.php" style="display: none;">chap-capability</a>',
Expand All @@ -36,7 +25,7 @@
'<div style="position: absolute; top: -250px; left: -250px;"><a href="http://holidayapi.com/iratedungeon.php">chap-capability</a></div>',
'<a href="http://holidayapi.com/iratedungeon.php"><span style="display: none;">chap-capability</span></a>',
'<a href="http://holidayapi.com/iratedungeon.php"><div style="height: 0px; width: 0px;"></div></a>',
);
];

shuffle($honey_pots);

Expand Down
26 changes: 18 additions & 8 deletions templates/home.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@

<p>The goal of this project is to provide a comprehensive &amp; free API for obtaining information about holidays.</p>

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
<a class="addthis_button_linkedin_counter"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-529535354cd72841"></script>
<!-- AddThis Button END -->

<h2>Usage</h2>

<p>To retrieve a list of holidays, simply make a GET request to <a href="http://holidayapi.com/v1/holidays" target="_blank">http://holidayapi.com/v1/holidays</a></p>

<h3>Parameters</h3>

<ul>
<li><code>country</code> - required, <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" target="_blank">ISO 3166-1 alpha-1</a> format</li>
<li><code>country</code> - required, <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" target="_blank">ISO 3166-1 alpha-1</a> format. Valid codes: BE, US</li>
<li><code>year</code> - required, 4 digits</li>
<li><code>month</code> - optional</li>
<li><code>day</code> - optional</li>
Expand All @@ -27,14 +39,12 @@

<pre>{"status":200,"holidays":[{"name":"Star Wars Day","country":"US","date":"2013-05-04"}]}</pre>

<h2>TODO</h2>

<p>At this time we only have holidays for the United States (<code>country</code> = US) and it’s only a partial list at best. We have made sure that most federal holidays are represented with the exception of Election and Inauguration days. We are also missing Lunar New Year, Password, Rosh Hashanah, Yom Kippur and Hanukkah at this time.</p>
<h2>Want to help?</h2>

<p>The plan is to support as many holidays as we can with the goal of maintaining logic to calculate the date when the holiday will occur instead of relying on a database pre-populated with the holidays. We are also planning to expand outside of the United States as well.</p>
<p>If you are interested in contributing to this API either with design, development or helping with your country’s holiday list (each country is a JSON file), <a href="https://github.com/joshtronic/holidayapi.com" target="_blank">go fork this API over on Github</a>. If you have any suggestions or find a bug, <a href="https://github.com/joshtronic/holidayapi.com/issues">please take the time to report it</a>. If you like what I’ve created and find it to be useful, please consider tipping:</p>

<p>If you are interested in contributing to this API either with design, development or helping with your country’s holiday list (each country is a JSON file), <a href="https://github.com/joshtronic/holidayapi.com" target="_blank">go fork this API over on Github</a>. If you have any suggestions or find a bug, <a href="https://github.com/joshtronic/holidayapi.com/issues">please take the time to report it</a>.</p>
<p><script data-gittip-username="joshtronic" src="//gttp.co/v1.js"></script></p>

<h2>Author</h2>
<h2>Contributors</h2>

<p>The Holiday API was created by <a href="http://joshtronic.com">Joshua Sherman</a> (<a href="https://twitter.com/joshtronic" target="_blank">@joshtronic</a>) and is provided as a free service. If you find this API useful, you should <a href="http://amzn.com/w/2J5B5K7KYUSET" target="_blank">say thank you</a>.</p>
<p>The Holiday API was created by <a href="https://github.com/joshtronic">Josh Sherman</a> and is provided as a free service. Special thanks to <a href="https://github.com/LGnap">LGnap</a> for providing a holiday list for Belgium.</p>

0 comments on commit e42fd1d

Please sign in to comment.