Skip to content

Commit 5cac224

Browse files
add owner GitHub Stats
1 parent 026fe26 commit 5cac224

File tree

9 files changed

+111
-37
lines changed

9 files changed

+111
-37
lines changed

_layouts/default.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,14 @@
1010
{{ content }}
1111
</main>
1212
</div>
13+
<!-- Modal -->
14+
<div id="repoModal" class="fixed inset-0 z-50 bg-black/60 hidden justify-center items-center transition-opacity duration-200">
15+
<div class="bg-gray-900 rounded-md max-w-md w-[90%] sm:w-full p-6 shadow-lg relative">
16+
<button id="closeModal" class="cursor-pointer absolute top-2 right-3 text-white text-lg"></button>
17+
<div id="repoModalContent" class="text-gray-200 text-sm">
18+
<!-- Isi muncul di sini -->
19+
</div>
20+
</div>
21+
</div>
1322
</body>
1423
</html>

assets/js/aiService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function sendToAI(prompt) {
2525
}
2626

2727
document.addEventListener('DOMContentLoaded', async () => {
28-
const messagePrompt = "kamu adalah lyra ✨, real-time GitHub intelligence yang ramah dan profesional dibuat oleh Daffa & jangan terlalu panjang menjawab.";
28+
const messagePrompt = "kamu adalah lyra ✨, Agents GitHub intelligence yang ramah dan profesional dibuat oleh Daffa & jangan terlalu panjang menjawab.";
2929
const chatWelcomeDiv = document.getElementById('chat-welcome');
3030
try {
3131
// --- PERBAIKAN DI SINI ---
@@ -59,7 +59,7 @@ document.addEventListener('DOMContentLoaded', async () => {
5959
}, 700); // Sesuaikan dengan durasi transisi CSS Kamu (700ms)
6060
}
6161

62-
console.log("Respon dari AI:", result);
62+
// console.log("Respon dari AI:", result);
6363
} catch (error) {
6464
console.error("Terjadi kesalahan:", error.message);
6565
if (chatWelcomeDiv) {

assets/js/core/core-ai.js

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,39 +63,76 @@ if (intent === "github_search") {
6363
}
6464
});
6565

66+
document.addEventListener('click', (e) => {
67+
const card = e.target.closest('[data-repo-owner]');
68+
if (card) {
69+
const owner = card.dataset.repoOwner;
70+
const fullName = card.dataset.repoFullname;
71+
72+
const modal = document.getElementById('repoModal');
73+
const content = document.getElementById('repoModalContent');
74+
75+
content.innerHTML = `
76+
<p class="mb-2">Stats untuk <strong>${fullName}</strong></p>
77+
<img
78+
src="https://github-readme-stats.vercel.app/api?username=${owner}&show_icons=true&theme=radical"
79+
alt="${owner} GitHub Stats"
80+
class="w-full rounded-md"
81+
/>
82+
`;
83+
modal.classList.remove('hidden');
84+
modal.classList.add('flex');
85+
}
86+
});
87+
88+
document.getElementById('closeModal').addEventListener('click', () => {
89+
document.getElementById('repoModal').classList.add('hidden');
6690

91+
});
6792

68-
const resetLauncher = () => {
69-
launcher.classList.remove("bottom-0", "left-0", "right-0", "items-end", "justify-center");
70-
launcher.classList.add("inset-0", "items-center", "justify-center");
71-
launcherForm.classList.remove("rounded-t-lg", "w-full", "max-w-xl");
72-
launcherForm.classList.add("rounded-full", "w-60");
73-
chatWrapper.classList.add("hidden", "scale-100", "opacity-100");
74-
welcome.classList.remove("opacity-0", "blur-md");
75-
btnArea.classList.add("hidden");
76-
};
77-
78-
launcherInput.addEventListener("focus", () => {
79-
launcher.classList.remove("inset-0", "items-center", "justify-center");
80-
launcher.classList.add("bottom-0", "left-0", "right-0", "items-end", "justify-center");
81-
launcherForm.classList.remove("rounded-full", "w-60");
82-
launcherForm.classList.add("rounded-t-lg", "w-full", "max-w-xl");
83-
chatWrapper.classList.remove("hidden", "scale-0", "opacity-0");
84-
welcome.classList.add("opacity-0", "blur-md");
85-
btnArea.classList.remove("hidden");
86-
launcherInput.focus();
87-
});
93+
const resetLauncher = () => {
94+
launcher.classList.remove("bottom-0", "left-0", "right-0", "items-end", "justify-center");
95+
launcher.classList.add("inset-0", "items-center", "justify-center");
96+
launcherForm.classList.remove("rounded-t-lg", "w-full", "max-w-xl");
97+
launcherForm.classList.add("rounded-full", "w-60");
98+
chatWrapper.classList.add("hidden", "scale-100", "opacity-100");
99+
welcome.classList.remove("opacity-0", "blur-md");
100+
btnArea.classList.add("hidden");
101+
};
102+
103+
launcherInput.addEventListener("focus", () => {
104+
launcher.classList.remove("inset-0", "items-center", "justify-center");
105+
launcher.classList.add("bottom-0", "left-0", "right-0", "items-end", "justify-center");
106+
launcherForm.classList.remove("rounded-full", "w-60");
107+
launcherForm.classList.add("rounded-t-lg", "w-full", "max-w-xl");
108+
chatWrapper.classList.remove("hidden", "scale-0", "opacity-0");
109+
welcome.classList.add("opacity-0", "blur-md");
110+
btnArea.classList.remove("hidden");
111+
launcherInput.focus();
112+
});
88113

89-
launcherInput.addEventListener("blur", () => {
90-
setTimeout(() => {
91-
const isActive = document.activeElement;
92-
const allowed = ["launcher-input", "send-button", "mic-button", "chat-launcher-form", "grid", "href", "chat-messages"];
114+
launcherInput.addEventListener("blur", () => {
115+
setTimeout(() => {
116+
const isActive = document.activeElement;
117+
const allowed = ["launcher-input", "send-button", "mic-button", "chat-launcher-form", "grid", "href", "chat-messages", "chat-box-wrapper"];
93118

94-
if (!allowed.includes(isActive?.id)) {
95-
resetLauncher();
96-
}
97-
}, 100);
119+
if (!allowed.includes(isActive?.id)) {
120+
resetLauncher();
121+
}
122+
}, 100);
123+
});
124+
125+
if (messages) {
126+
messages.addEventListener("dblclick", () => {
127+
resetLauncher();
98128
});
129+
}
130+
131+
if (chatWrapper) {
132+
chatWrapper.addEventListener("dblclick", () => {
133+
resetLauncher();
134+
});
135+
}
99136

100137
function hideWelcomeMessage() {
101138
const welcome = document.getElementById("chat-welcome");

assets/js/githubSearchHandler.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export async function handleGithubSearchIntent(userMessage, chatBox) {
1010
return;
1111
}
1212

13+
chatBox.innerHTML += `
14+
<p class="text-gray-300 animate-pulse" id="loadingMessage">🔄 Mencari repositori "<strong>${keyword}</strong>"...</p>
15+
`;
16+
1317
const repos = await searchGithubRepos(keyword);
1418
if (repos.length === 0) {
1519
chatBox.innerHTML += "<p class='text-gray-400'>Tidak ada repositori ditemukan untuk <strong>" + keyword + "</strong></p>";
@@ -18,5 +22,6 @@ export async function handleGithubSearchIntent(userMessage, chatBox) {
1822

1923
const cardHTML = renderGithubCards(repos);
2024
chatBox.innerHTML += cardHTML;
25+
document.getElementById('loadingMessage')?.remove();
2126
chatBox.scrollTop = chatBox.scrollHeight;
2227
}

assets/js/intents-github.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export const detectIntent = (message) => {
88
const msg = message.toLowerCase();
99

1010
if (msg.match(/halo|hai|hi|assalam|pagi|siang|sore/)) return "greeting";
11-
if (msg.match(/repo|repositori|github|cari repo/)) return "github_search";
11+
if (msg.match(/repo|repositori|github|cari repo|cari proyek|lihat kode/)) return "github_search";
12+
if (msg.match(/cerita|kisah|buatkan cerita|dongeng|kisahkan|story/)) return "make_story";
13+
if (msg.match(/lanjut cerita|teruskan cerita|next chapter|continue/)) return "continue_story";
14+
if (msg.match(/hapus|reset|mulai ulang|clear/)) return "reset_conversation";
15+
if (msg.match(/daftar|subscribe|langganan|premium/)) return "subscribe_prompt";
16+
if (msg.match(/bantuan|help|fitur|apa bisa|ngapain aja/)) return "help";
17+
if (msg.match(/siapa kamu|kamu siapa|tentangmu|profil|creator|pembuat|yang buat kamu/)) return "about_ai";
1218

1319
return "fallback";
14-
};
20+
};

assets/js/intents.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export const detectIntent = (message) => {
88
const msg = message.toLowerCase();
99

1010
if (msg.match(/halo|hai|hi|assalam|pagi|siang|sore/)) return "greeting";
11-
if (msg.match(/(ada repo)?(sitori|repo|punya repo apa|repo apa|list repo)/)) return "list_repo";
11+
if (msg.match(/repo|repositori|github|cari repo|cari proyek|lihat kode/)) return "github_search";
12+
if (msg.match(/cerita|kisah|buatkan cerita|dongeng|kisahkan|story/)) return "make_story";
13+
if (msg.match(/lanjut cerita|teruskan cerita|next chapter|continue/)) return "continue_story";
14+
if (msg.match(/hapus|reset|mulai ulang|clear/)) return "reset_conversation";
15+
if (msg.match(/daftar|subscribe|langganan|premium/)) return "subscribe_prompt";
16+
if (msg.match(/bantuan|help|fitur|apa bisa|ngapain aja/)) return "help";
17+
if (msg.match(/siapa kamu|kamu siapa|tentangmu|profil|creator|pembuat|yang buat kamu/)) return "about_ai";
1218

13-
return "fallback"; // default jika tidak dikenali
19+
return "fallback";
1420
};

assets/js/promptBuilder-github.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Fokus sekarang hanya pada greeting, fallback, dan lainnya (bukan repo).
66
*/
77
export function buildPrompt(userMessage, repo, intent) {
8-
let systemContent = `kamu adalah lyra ✨, real-time GitHub intelligence yang ramah dan profesional dibuat oleh Daffa & jangan terlalu panjang menjawab.
8+
let systemContent = `kamu adalah lyra ✨, Agents GitHub intelligence yang ramah dan profesional dibuat oleh Daffa & jangan terlalu panjang menjawab.
99
1010
### 🧠 Sikap
1111
- Gunakan bahasa Indonesia santai dan jelas.

assets/js/renderGithubCards.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ export function renderGithubCards(repos) {
44
return `
55
<div id="grid" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 my-4">
66
${repos.map(repo => `
7-
<div class="border overflow-hidden border-gray-700 rounded-md p-4 bg-gray-800 shadow flex gap-4">
7+
<div class="border cursor-pointer overflow-hidden border-gray-700 rounded-md p-4 bg-gray-800 shadow flex gap-4 transition-transform hover:scale-[1.02]" data-repo-owner="${repo.owner.login}" data-repo-fullname="${repo.full_name}">
88
<img src="${repo.owner.avatar_url}" alt="Avatar" class="w-12 h-12 rounded-full object-cover" />
99
<div>
1010
<a href="${repo.html_url}" target="_blank" class="text-blue-400 font-semibold hover:underline">
1111
${repo.full_name}
1212
</a>
1313
<p class="text-gray-300 text-sm mt-1">${repo.description ? repo.description.slice(0, 150) + (repo.description.length > 180 ? '...' : '') : "Tanpa deskripsi."}</p>
14+
<div class="flex justify-between items-center">
1415
<p class="text-yellow-400 text-xs mt-1">⭐ ${repo.stargazers_count.toLocaleString()} stars</p>
16+
<p class="text-green-400 text-xs mt-1">${repo.language || 'Unknown language'}</p>
17+
</div>
1518
</div>
1619
</div>
1720
`).join("")}
@@ -23,14 +26,17 @@ export function renderGithubCard(repo) {
2326
if (!repo || typeof repo !== "object") return "";
2427

2528
return `
26-
<div id="grid" class="border overflow-hidden border-gray-700 bg-gray-800 rounded-md p-4 shadow-md flex gap-4 items-start my-4">
29+
<div id="grid" class="border cursor-pointer overflow-hidden border-gray-700 bg-gray-800 rounded-md p-4 shadow-md flex gap-4 items-start my-4 transition-transform hover:scale-[1.02]" data-repo-owner="${repo.owner.login}" data-repo-fullname="${repo.full_name}">
2730
<img src="${repo.owner?.avatar_url}" alt="Avatar" class="w-14 h-14 rounded-full object-cover" />
2831
<div>
2932
<a href="${repo.html_url}" target="_blank" class="text-blue-400 font-bold text-base hover:underline">
3033
${repo.full_name ? repo.full_name.slice(0, 25) + (repo.full_name.length > 15 ? '...' : '') : "tanpa nama"}
3134
</a>
3235
<p class="text-gray-300 text-sm mt-1">${repo.description ? repo.description.slice(0, 150) + (repo.description.length > 180 ? '...' : '') : "Tanpa deskripsi."}</p>
36+
<div class="flex justify-between items-center">
3337
<p class="text-yellow-400 text-xs mt-2">⭐ ${repo.stargazers_count.toLocaleString()} stars</p>
38+
<p class="text-green-400 text-xs mt-1">${repo.language || 'Unknown language'}</p>
39+
</div>
3440
</div>
3541
</div>
3642
`;

config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"MODEL_NAME": "mistralai/mistral-7b-instruct",
3+
"PROJECT_TITLE": "AI Cerita Interaktif",
4+
"API_BASE_URL": "https://nama-worker.pages.dev"
5+
}

0 commit comments

Comments
 (0)