Created
January 1, 2013 23:08
-
-
Save Moc/4430879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Configuration ---------------------- // | |
$repo = "e107inc/e107"; | |
$branch = "master"; | |
// ------------------------------------ // | |
$git = simplexml_load_file("https://github.com/".$repo."/commits/".$branch.".atom"); | |
$arr = array('+ ', '- ', 'm '); | |
echo "<html> | |
<head> | |
<title>".$git->title."</title> | |
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script> | |
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> | |
<style> | |
body { | |
background-color: #fff; | |
color: #333; | |
font: normal 14px/1.5em Arial, Helvetica, sans-serif; | |
width: 1000px; | |
margin: 10px auto; | |
} | |
a { | |
color:#0086CB; | |
text-decoration:none; | |
} | |
a:hover { | |
color:#F29400; | |
text-decoration:none; | |
} | |
#commit { | |
background-color:#EBFAFF; | |
padding: 10px; | |
margin: 10px 0; | |
border-radius: 4px; | |
} | |
</style> | |
</head> | |
<body> | |
<h2>20 ".$git->title."</h2> | |
"; | |
for($i = 0; $i <= 19; $i++) | |
{ | |
$title = "<a href='".$git->entry[$i]->link['href']."'>".$git->entry[$i]->title."</a>"; | |
$author = "<a href='".$git->entry[$i]->author->uri."'>".$git->entry[$i]->author->name."</a>"; | |
$datestamp = time_passed(strtotime($git->entry[$i]->updated)); | |
$files = ""; | |
$files_affected = 0; | |
foreach(explode("\n", strip_tags(trim($git->entry[$i]->content))) as $k => $v) | |
{ | |
if(in_array(substr($v, 0, 2), $arr)) | |
{ | |
$files .= "<a style='margin-left: 32px;' href='https://github.com/".$repo."/blob/".$branch."/".str_replace($arr, "", $v)."'>".$v."</a><br />\n"; | |
$files_affected++; | |
} | |
} | |
echo " | |
<div id='commit'> | |
<b>".$files_affected." file".($files_affected > 1 ? "s" : "")." modified by ".$author."</b> <span style='float:right; font-size:0.8em;'>".$datestamp."</span><br /> | |
<div style='margin-left: 10px;'><a style='cursor: hand;' onclick=\"$('.files_".$i."').toggle('fast')\">[+]</a> ".$title."</div> | |
<div class='files_".$i."' style='display:none; font-size:0.8em; max-height: 200px; overflow: auto;'>".$files."</div> | |
</div> | |
"; | |
unset($title, $author, $datestamp, $files, $files_affected); | |
} | |
echo " | |
<div id='commit' style='text-align:center; font-weight: 600;'> | |
Get the source code for this <a href='https://gist.github.com/4165493'>here</a> | |
</div> | |
</body> | |
</html>"; | |
function time_passed($timestamp) | |
{ | |
$timestamp = (int) $timestamp; | |
$current_time = time(); | |
$diff = $current_time - $timestamp; | |
$intervals = array ( | |
'year' => 31556926, 'month' => 2629744, 'week' => 604800, 'day' => 86400, 'hour' => 3600, 'minute'=> 60 | |
); | |
if ($diff == 0) | |
{ | |
return 'just now'; | |
} | |
if ($diff < 60) | |
{ | |
return $diff == 1 ? $diff . ' second ago' : $diff . ' seconds ago'; | |
} | |
if ($diff >= 60 && $diff < $intervals['hour']) | |
{ | |
$diff = floor($diff/$intervals['minute']); | |
return $diff == 1 ? $diff . ' minute ago' : $diff . ' minutes ago'; | |
} | |
if ($diff >= $intervals['hour'] && $diff < $intervals['day']) | |
{ | |
$diff = floor($diff/$intervals['hour']); | |
return $diff == 1 ? $diff . ' hour ago' : $diff . ' hours ago'; | |
} | |
if ($diff >= $intervals['day'] && $diff < $intervals['week']) | |
{ | |
$diff = floor($diff/$intervals['day']); | |
return $diff == 1 ? $diff . ' day ago' : $diff . ' days ago'; | |
} | |
if ($diff >= $intervals['week'] && $diff < $intervals['month']) | |
{ | |
$diff = floor($diff/$intervals['week']); | |
return $diff == 1 ? $diff . ' week ago' : $diff . ' weeks ago'; | |
} | |
if ($diff >= $intervals['month'] && $diff < $intervals['year']) | |
{ | |
$diff = floor($diff/$intervals['month']); | |
return $diff == 1 ? $diff . ' month ago' : $diff . ' months ago'; | |
} | |
if ($diff >= $intervals['year']) | |
{ | |
$diff = floor($diff/$intervals['year']); | |
return $diff == 1 ? $diff . ' year ago' : $diff . ' years ago'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment