Repository navigation
Expand file tree
/
Copy pathrecent-changes.html
More file actions
178 lines (159 loc) · 8.35 KB
/
Copy pathrecent-changes.html
File metadata and controls
178 lines (159 loc) · 8.35 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
---
layout: info
title: Recent Changes
lang: en-US
description: See the latest updates to IPL from GitHub.
permalink: /en-US/recent-changes/
---
<!-- Hero -->
<section class="bg-gradient-to-r from-slate-700 to-slate-900 text-white py-12">
<div class="container mx-auto px-4">
<div class="flex items-center justify-between">
<div>
<h1 class="text-4xl font-bold mb-2">Recent Changes</h1>
<p class="text-slate-300">Track the latest updates from IPL repositories</p>
</div>
<a href="https://github.com/InternetPublicLibrary" target="_blank"
class="px-4 py-2 bg-white/10 border border-white/20 rounded-lg hover:bg-white/20 transition-colors flex items-center">
<i class="fab fa-github mr-2"></i>View on GitHub
</a>
</div>
</div>
</section>
<div class="container mx-auto px-4 py-8">
<div class="max-w-4xl mx-auto">
<!-- Repository Tabs -->
<div class="flex flex-wrap gap-2 mb-6">
<button onclick="IPL.loadRepoCommits('all')" id="tab-all"
class="repo-tab px-4 py-2 bg-blue-600 text-white rounded-lg text-sm font-medium">
All Repos
</button>
<button onclick="IPL.loadRepoCommits('IPLibrary-website')" id="tab-website"
class="repo-tab px-4 py-2 bg-white border rounded-lg text-sm hover:bg-gray-50">
IPLibrary-website
</button>
<button onclick="IPL.loadRepoCommits('en-US')" id="tab-en"
class="repo-tab px-4 py-2 bg-white border rounded-lg text-sm hover:bg-gray-50">
en-US
</button>
<button onclick="IPL.loadRepoCommits('pt-BR')" id="tab-pt"
class="repo-tab px-4 py-2 bg-white border rounded-lg text-sm hover:bg-gray-50">
pt-BR
</button>
</div>
<!-- Loading State -->
<div id="commits-loading" class="bg-white rounded-xl shadow-sm border p-8 text-center">
<div class="animate-spin w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full mx-auto mb-4">
</div>
<p class="text-gray-500">Loading commits from GitHub...</p>
</div>
<!-- Commits List -->
<div id="commits-list" class="bg-white rounded-xl shadow-sm border divide-y hidden">
<!-- Dynamically populated by JavaScript -->
</div>
<!-- Error State -->
<div id="commits-error" class="bg-white rounded-xl shadow-sm border p-8 text-center hidden">
<i class="fas fa-exclamation-circle text-red-500 text-3xl mb-4"></i>
<p class="text-gray-500">Error loading commits. Please try again later.</p>
</div>
<!-- Stats -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mt-8">
<div class="bg-white rounded-xl shadow-sm border p-6 text-center">
<div class="text-3xl font-bold text-blue-600" id="stat-total-commits">-</div>
<div class="text-sm text-gray-600">Recent Commits</div>
</div>
<div class="bg-white rounded-xl shadow-sm border p-6 text-center">
<div class="text-3xl font-bold text-green-600">3</div>
<div class="text-sm text-gray-600">Active Repositories</div>
</div>
<div class="bg-white rounded-xl shadow-sm border p-6 text-center">
<div class="text-3xl font-bold text-purple-600" id="stat-contributors">-</div>
<div class="text-sm text-gray-600">Contributors</div>
</div>
</div>
</div>
</div>
<script>
// Extended IPL functionality for Recent Changes page
document.addEventListener('DOMContentLoaded', function () {
IPL.loadRepoCommits = async function (repo) {
const commitsList = document.getElementById('commits-list');
const loading = document.getElementById('commits-loading');
const error = document.getElementById('commits-error');
// Update tab styles
document.querySelectorAll('.repo-tab').forEach(tab => {
tab.classList.remove('bg-blue-600', 'text-white');
tab.classList.add('bg-white', 'border');
});
const activeTab = document.getElementById('tab-' + (repo === 'all' ? 'all' : repo.replace('IPLibrary-', '').toLowerCase().replace('-', '')));
if (activeTab) {
activeTab.classList.remove('bg-white', 'border');
activeTab.classList.add('bg-blue-600', 'text-white');
}
loading.classList.remove('hidden');
commitsList.classList.add('hidden');
error.classList.add('hidden');
try {
let repos = repo === 'all'
? ['InternetPublicLibrary/IPLibrary-website', 'InternetPublicLibrary/en-US', 'InternetPublicLibrary/pt-BR']
: ['InternetPublicLibrary/' + repo];
const allCommits = [];
const contributors = new Set();
let loadedRepos = 0;
for (const r of repos) {
const response = await fetch(`https://api.github.com/repos/${r}/commits?per_page=15`);
if (response.ok) {
loadedRepos++;
const data = await response.json();
data.forEach(commit => {
allCommits.push({
repo: r.split('/')[1],
message: commit.commit.message,
author: commit.commit.author.name,
avatar: commit.author?.avatar_url || 'https://github.com/identicons/' + commit.commit.author.name,
date: new Date(commit.commit.author.date),
url: commit.html_url,
sha: commit.sha.substring(0, 7)
});
contributors.add(commit.commit.author.name);
});
}
}
// GitHub refused every request (e.g. the 60/hour anonymous limit): say so instead of showing zeros.
if (loadedRepos === 0) throw new Error('GitHub API unavailable');
// Sort by date
allCommits.sort((a, b) => b.date - a.date);
// Update stats
document.getElementById('stat-total-commits').textContent = allCommits.length;
document.getElementById('stat-contributors').textContent = contributors.size;
// Render commits
commitsList.innerHTML = allCommits.slice(0, 25).map(commit => `
<div class="p-4 hover:bg-gray-50 transition-colors flex items-start gap-4">
<img src="${iplUrl(commit.avatar)}" alt="${iplEsc(commit.author)}" class="w-10 h-10 rounded-full flex-shrink-0">
<div class="flex-grow min-w-0">
<div class="flex items-start justify-between gap-2">
<a href="${iplUrl(commit.url)}" target="_blank" class="font-medium text-gray-900 hover:text-blue-600 line-clamp-2">
${iplEsc(commit.message.split('\n')[0])}
</a>
<span class="text-xs text-gray-500 flex-shrink-0">${IPL.timeAgo(commit.date, 'en-US')}</span>
</div>
<div class="flex items-center gap-2 mt-1 text-sm">
<span class="bg-gray-100 text-gray-600 px-2 py-0.5 rounded text-xs">${iplEsc(commit.repo)}</span>
<span class="text-gray-500">${iplEsc(commit.author)}</span>
<code class="bg-gray-100 text-gray-600 px-1 rounded text-xs">${iplEsc(commit.sha)}</code>
</div>
</div>
</div>
`).join('');
loading.classList.add('hidden');
commitsList.classList.remove('hidden');
} catch (e) {
console.error('Error loading commits:', e);
loading.classList.add('hidden');
error.classList.remove('hidden');
}
};
// Load all commits by default
IPL.loadRepoCommits('all');
});
</script>