refactor: group internship commits by date and update UI to a grid layout
This commit is contained in:
@@ -394,7 +394,7 @@
|
||||
Henüz hiç commit bulunamadı veya deponuz tanımlanmadı. Lütfen deponuzu tanımlayın ve commitlerinizi gönderin.
|
||||
</div>
|
||||
|
||||
<div id="commits-timeline" class="hidden relative border-l-2 border-slate-100 ml-4 pl-6 space-y-6">
|
||||
<div id="commits-timeline" class="hidden grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<!-- Loaded dynamically by JS -->
|
||||
</div>
|
||||
|
||||
@@ -513,41 +513,67 @@
|
||||
// Reverse to show in chronological order (Day 1, Day 2...)
|
||||
commits.reverse();
|
||||
|
||||
// Group commits by date (YYYY-MM-DD)
|
||||
const grouped = {};
|
||||
commits.forEach(item => {
|
||||
const dateStr = item.commit.author.date;
|
||||
if (dateStr) {
|
||||
const dateOnly = dateStr.substring(0, 10); // "YYYY-MM-DD"
|
||||
if (!grouped[dateOnly]) {
|
||||
grouped[dateOnly] = [];
|
||||
}
|
||||
grouped[dateOnly].push(item);
|
||||
}
|
||||
});
|
||||
|
||||
const sortedDates = Object.keys(grouped).sort();
|
||||
|
||||
timelineEl.classList.remove('hidden');
|
||||
|
||||
commits.forEach((item, index) => {
|
||||
sortedDates.forEach((date, index) => {
|
||||
const dayNum = index + 1;
|
||||
const message = item.commit.message;
|
||||
const authorDate = new Date(item.commit.author.date);
|
||||
const formattedDate = authorDate.toLocaleDateString('tr-TR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
const shaShort = item.sha.substring(0, 7);
|
||||
const commitUrl = item.html_url;
|
||||
const dayCommits = grouped[date];
|
||||
|
||||
// Format date as DD.MM.YYYY
|
||||
const dateParts = date.split('-');
|
||||
const formattedDate = `${dateParts[2]}.${dateParts[1]}.${dateParts[0]}`;
|
||||
|
||||
const commitHtml = `
|
||||
<div class="relative pl-6 pb-6 last:pb-0">
|
||||
<div class="absolute -left-[7px] top-1.5 w-3 h-3 rounded-full bg-blue-600 shadow-sm ring-4 ring-white"></div>
|
||||
<div class="bg-slate-50/60 rounded-2xl p-4 border border-slate-100 hover:border-slate-200 hover:bg-slate-50 transition-all">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 mb-2">
|
||||
<span class="text-xs uppercase font-extrabold tracking-wider text-blue-600 bg-blue-50 px-2.5 py-1 rounded-full">${dayNum}. Gün</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-xs text-slate-400 font-semibold">${formattedDate}</span>
|
||||
<a href="${commitUrl}" target="_blank" class="text-xs font-mono font-bold text-slate-500 hover:text-blue-600 bg-white px-2 py-0.5 rounded border border-slate-200/60 transition-colors flex items-center gap-1">
|
||||
<i class="uil uil-external-link-alt text-[10px]"></i>
|
||||
${shaShort}
|
||||
</a>
|
||||
</div>
|
||||
// Generate commits list HTML
|
||||
let commitsListHtml = '';
|
||||
dayCommits.forEach(c => {
|
||||
const message = c.commit.message;
|
||||
const authorDate = new Date(c.commit.author.date);
|
||||
const timeStr = authorDate.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });
|
||||
const shaShort = c.sha.substring(0, 7);
|
||||
const commitUrl = c.html_url;
|
||||
|
||||
commitsListHtml += `
|
||||
<div class="p-3 bg-white rounded-xl border border-slate-100 hover:border-slate-200 transition-all shadow-sm">
|
||||
<div class="flex items-center justify-between gap-2 mb-1.5">
|
||||
<span class="text-[10px] font-bold text-slate-400"><i class="uil uil-clock"></i> ${timeStr}</span>
|
||||
<a href="${commitUrl}" target="_blank" class="text-[10px] font-mono font-bold text-slate-500 hover:text-blue-600 bg-slate-50 px-2 py-0.5 rounded border border-slate-100 transition-colors">
|
||||
${shaShort}
|
||||
</a>
|
||||
</div>
|
||||
<p class="text-xs font-bold text-slate-700 leading-relaxed whitespace-pre-line">${escapeHtml(message)}</p>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
const dayCardHtml = `
|
||||
<div class="bg-slate-50/60 border border-slate-100/80 hover:border-blue-100 hover:bg-blue-50/10 rounded-2xl p-5 transition-all flex flex-col justify-between">
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-4 border-b border-slate-100 pb-2.5">
|
||||
<span class="text-sm font-extrabold text-blue-600 bg-blue-50/60 px-3 py-1 rounded-full">${dayNum}. Gün</span>
|
||||
<span class="text-xs font-bold text-slate-400"><i class="uil uil-calendar-alt"></i> ${formattedDate}</span>
|
||||
</div>
|
||||
<div class="space-y-3">
|
||||
${commitsListHtml}
|
||||
</div>
|
||||
<p class="text-sm font-bold text-slate-700 whitespace-pre-line leading-relaxed">${escapeHtml(message)}</p>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
timelineEl.insertAdjacentHTML('beforeend', commitHtml);
|
||||
timelineEl.insertAdjacentHTML('beforeend', dayCardHtml);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
Reference in New Issue
Block a user