-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
121 lines (102 loc) · 4.15 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE HTML>
<html>
<head>
<title>Git commit log</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/>
<style>
#maincontent {
margin-bottom: 50px;
}
header {
width: 100%;
}
header img {
display: block;
margin-top: -3px;
height: 60px;
}
footer {
text-align: center;
border-top: 2px solid #337AB7;
background-color: white;
position: fixed;
bottom: 0;
padding-top: 5px;
padding-bottom: 5px;
width: 100%;
}
#line {
border-bottom: 2px solid #337AB7;
position: absolute;
width: 100%;
left: 0;
top: 50px;
}
.draw_line {
border-top: 3px solid #337AB7;
}
td img {
width: 40px;
}
</style>
</head>
<body>
<div id="line"></div>
<div class="container" id="maincontent">
<header>
<img src="Logo.png"/>
</header>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Id</th>
<td></td>
<th>Author</th>
<th>Date</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<?php
require_once('config.php');
$content = file_get_contents('data/.commits.txt');
$lines = explode(PHP_EOL, $content);
if (!$lines)
$lines = array();
$lastDay = 0;
foreach (array_reverse($lines) as $jsonString) {
$commitList = json_decode($jsonString);
// Ignore invalid json lines
if (!$commitList)
continue;
foreach (array_reverse($commitList) as $commit) {
$id = htmlspecialchars($commit->id);
if (USE_SHORT_HASHES)
$id = substr($id, 0, 7);
$author = htmlspecialchars($commit->author);
$timestamp = htmlspecialchars(isset($commit->timestamp) ? $commit->timestamp : 'not available');
$css_class = '';
if (isset($commit->timestamp)) {
$parsed_date = date_parse($commit->timestamp);
if ($parsed_date['day'] != $lastDay)
$css_class = 'draw_line';
$lastDay = $parsed_date['day'];
}
$commit_url = htmlspecialchars(isset($commit->url) ? $commit->url : '');
$message = nl2br(match_GitHubChars($commit->message, substr($commit_url, 0, strlen($commit_url)-48)));
$avatar_tag = isset($commit->avatar_url) ? "<img src=\"{$commit->avatar_url}\"/>" : '';
$sender_tag = isset($commit->html_url) ? "<a href=\"{$commit->html_url}\">$author</a>" : $author;
echo "<tr class=\"$css_class\"><td><a href=\"$commit_url\">$id</a></td><td>$avatar_tag</td><td>$sender_tag</td><td>$timestamp</td><td>$message</td></tr>";
}
}
?>
</tbody>
</table>
</div>
<footer>
by
<a href="http://www.v-roleplay.net">vRoleplay</a> licensed under GPL v3.0 -
<a href="https://github.com/vRoleplay/CommitLog">GitHub</a>
</footer>
</body>
</html>