chahuadev commited on
Commit ·
66caa01
1
Parent(s): 375fb36
feat: Enterprise UI redesign + Repo Explorer panel
Browse files- Add HF Explorer: browse all datasets/models/spaces from chahuadev profile
- Lazy-load commits per repo (split-pane layout)
- Enterprise palette: slate-900/800 colors, BORDER/MUTED/TEXT tokens
- Stats cards: Total / Windows / Linux file counts
- Skeleton loader with animation (replaces static loading text)
- Changelog nav tab: commits from HF API
- Fix Linux open-folder (xdg-open)
- Fix apt install python3-tk in build-desktop.bat WSL build
- Update npm package README: add Downloads/ChahuadevHub note
- build-desktop.bat +2 -2
- chahuadev_hub.py +604 -118
- chahuadev_hub/main.py +604 -118
- packages/@chahuadev/chahuadev-hub-app/README.md +52 -0
- packages/@chahuadev/chahuadev-hub-app/package.json +1 -1
build-desktop.bat
CHANGED
|
@@ -90,7 +90,7 @@ if errorlevel 1 goto menu
|
|
| 90 |
REM แปลง path Windows → WSL
|
| 91 |
for /f "delims=" %%p in ('wsl wslpath -u "%PROJECT_DIR%"') do set WSL_DIR=%%p
|
| 92 |
|
| 93 |
-
wsl bash -c "cd '%WSL_DIR%' && python3 -m pip install pyinstaller requests customtkinter -q && python3 -m PyInstaller --
|
| 94 |
|
| 95 |
if %errorlevel% neq 0 (
|
| 96 |
echo.
|
|
@@ -130,7 +130,7 @@ if errorlevel 1 (
|
|
| 130 |
echo [SKIP] ข้ามขั้นตอน Linux เนื่องจากไม่พบ WSL
|
| 131 |
) else (
|
| 132 |
for /f "delims=" %%p in ('wsl wslpath -u "%PROJECT_DIR%"') do set WSL_DIR=%%p
|
| 133 |
-
wsl bash -c "cd '%WSL_DIR%' && python3 -m pip install pyinstaller requests customtkinter -q && python3 -m PyInstaller --
|
| 134 |
if !errorlevel! neq 0 (
|
| 135 |
echo [ERROR] Build Linux ล้มเหลว!
|
| 136 |
) else (
|
|
|
|
| 90 |
REM แปลง path Windows → WSL
|
| 91 |
for /f "delims=" %%p in ('wsl wslpath -u "%PROJECT_DIR%"') do set WSL_DIR=%%p
|
| 92 |
|
| 93 |
+
wsl bash -c "cd '%WSL_DIR%' && sudo apt-get install -y python3-tk python3-dev -q && python3 -m pip install pyinstaller requests customtkinter -q && python3 -m PyInstaller --onefile %SCRIPT%"
|
| 94 |
|
| 95 |
if %errorlevel% neq 0 (
|
| 96 |
echo.
|
|
|
|
| 130 |
echo [SKIP] ข้ามขั้นตอน Linux เนื่องจากไม่พบ WSL
|
| 131 |
) else (
|
| 132 |
for /f "delims=" %%p in ('wsl wslpath -u "%PROJECT_DIR%"') do set WSL_DIR=%%p
|
| 133 |
+
wsl bash -c "cd '%WSL_DIR%' && sudo apt-get install -y python3-tk python3-dev -q && python3 -m pip install pyinstaller requests customtkinter -q && python3 -m PyInstaller --onefile %SCRIPT%"
|
| 134 |
if !errorlevel! neq 0 (
|
| 135 |
echo [ERROR] Build Linux ล้มเหลว!
|
| 136 |
) else (
|
chahuadev_hub.py
CHANGED
|
@@ -2,21 +2,33 @@ import customtkinter as ctk
|
|
| 2 |
import threading
|
| 3 |
import urllib.parse
|
| 4 |
import requests
|
| 5 |
-
import json
|
| 6 |
import os
|
| 7 |
-
import
|
| 8 |
|
| 9 |
# ── CONFIG ──────────────────────────────────────────────────────────────────
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# ── SKIP non-app files ───────────────────────────────────────────────────────
|
| 16 |
SKIP_FILES = {".gitattributes", "README.md", "chahuadev-framework-binaries.png",
|
| 17 |
"emoji-cleaner-app.png"}
|
| 18 |
|
| 19 |
-
# ── APP METADATA
|
| 20 |
APP_META = {
|
| 21 |
"Chahuadev Framework": {
|
| 22 |
"icon": "⚙️",
|
|
@@ -32,6 +44,27 @@ APP_META = {
|
|
| 32 |
},
|
| 33 |
}
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def format_size(n):
|
| 36 |
for unit in ("B", "KB", "MB", "GB"):
|
| 37 |
if n < 1024:
|
|
@@ -39,31 +72,177 @@ def format_size(n):
|
|
| 39 |
n /= 1024
|
| 40 |
return f"{n:.1f} TB"
|
| 41 |
|
|
|
|
| 42 |
def guess_app_name(path):
|
| 43 |
name = path.replace("-win-ia32.exe", "").replace("-win-x64.exe", "")
|
| 44 |
name = name.replace("-1.0.0.AppImage", "").replace(".AppImage", "").replace(".exe", "")
|
| 45 |
name = name.replace("-", " ").strip()
|
| 46 |
return name
|
| 47 |
|
|
|
|
| 48 |
def guess_platform(path):
|
| 49 |
p = path.lower()
|
| 50 |
if "ia32" in p:
|
| 51 |
-
return "Windows 32-bit",
|
| 52 |
if "x64" in p or ".exe" in p:
|
| 53 |
-
return "Windows 64-bit",
|
| 54 |
if ".appimage" in p:
|
| 55 |
-
return "Linux AppImage",
|
| 56 |
-
return "Unknown",
|
| 57 |
|
| 58 |
-
# ── THEME ────────────────────────────────────────────────────────────────────
|
| 59 |
-
ctk.set_appearance_mode("dark")
|
| 60 |
-
ctk.set_default_color_theme("blue")
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
# ════════════════════════════════════════════════════════════════════════════
|
|
@@ -71,61 +250,68 @@ class AppCard(ctk.CTkFrame):
|
|
| 71 |
"""Single file download card."""
|
| 72 |
|
| 73 |
def __init__(self, master, file_info: dict, download_dir: str, status_cb):
|
| 74 |
-
super().__init__(master, fg_color=CARD_BG, corner_radius=10
|
|
|
|
| 75 |
|
| 76 |
self.file_info = file_info
|
| 77 |
self.download_dir = download_dir
|
| 78 |
self.status_cb = status_cb
|
| 79 |
self._thread = None
|
| 80 |
|
| 81 |
-
path
|
| 82 |
-
size
|
| 83 |
app_name = guess_app_name(path)
|
| 84 |
-
meta
|
| 85 |
plat, plat_color = guess_platform(path)
|
| 86 |
|
| 87 |
self.columnconfigure(1, weight=1)
|
| 88 |
|
| 89 |
# Icon
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
# App name
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
| 98 |
|
| 99 |
# Description + size
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
|
| 106 |
# Platform badge
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
# Filename label (small)
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
# Download button
|
| 118 |
self.btn = ctk.CTkButton(self, text="⬇ Download", width=130,
|
|
|
|
| 119 |
command=self._start_download)
|
| 120 |
self.btn.grid(row=0, column=3, rowspan=2, padx=16, pady=16)
|
| 121 |
|
| 122 |
# Progress bar (hidden initially)
|
| 123 |
-
self.pbar = ctk.CTkProgressBar(self, width=130
|
|
|
|
| 124 |
self.pbar.set(0)
|
| 125 |
|
| 126 |
# Percent label
|
| 127 |
self.pct_lbl = ctk.CTkLabel(self, text="", font=ctk.CTkFont(size=10),
|
| 128 |
-
text_color=
|
| 129 |
|
| 130 |
# ── download logic ────────────────────────────────────────────────────────
|
| 131 |
def _start_download(self):
|
|
@@ -143,7 +329,7 @@ class AppCard(ctk.CTkFrame):
|
|
| 143 |
total = self.file_info.get("size", 0)
|
| 144 |
url = f"{HF_CDN_BASE}/{urllib.parse.quote(path)}"
|
| 145 |
dest = os.path.join(self.download_dir, path)
|
| 146 |
-
chunk_size = 65536
|
| 147 |
|
| 148 |
try:
|
| 149 |
self.btn.configure(text="Connecting…")
|
|
@@ -163,23 +349,20 @@ class AppCard(ctk.CTkFrame):
|
|
| 163 |
text=f"{format_size(downloaded)} / {format_size(total)} ({pct*100:.0f}%)"
|
| 164 |
)
|
| 165 |
|
| 166 |
-
# ── Verify size ───────────────────────────────────────────────────
|
| 167 |
if total > 0 and downloaded != total:
|
| 168 |
raise IOError(
|
| 169 |
f"Incomplete download: got {format_size(downloaded)}, expected {format_size(total)}"
|
| 170 |
)
|
| 171 |
|
| 172 |
-
# ── Done ─────────────────────────────────────────────────────────
|
| 173 |
self.btn.configure(text="✓ Done", fg_color=SUCCESS, state="normal")
|
| 174 |
self.pbar.set(1)
|
| 175 |
self.pct_lbl.configure(text=f"Saved → {dest}")
|
| 176 |
self.status_cb(f"✓ Downloaded: {path}")
|
| 177 |
|
| 178 |
except Exception as exc:
|
| 179 |
-
self.btn.configure(text="⚠ Retry", state="normal", fg_color=
|
| 180 |
self.pct_lbl.configure(text=f"Error: {exc}")
|
| 181 |
self.status_cb(f"✗ Failed: {path} — {exc}")
|
| 182 |
-
# Remove incomplete file if it exists
|
| 183 |
if os.path.exists(dest):
|
| 184 |
try:
|
| 185 |
os.remove(dest)
|
|
@@ -193,10 +376,14 @@ class ChahuadevHub(ctk.CTk):
|
|
| 193 |
def __init__(self):
|
| 194 |
super().__init__()
|
| 195 |
self.title("Chahuadev Hub")
|
| 196 |
-
self.geometry("
|
| 197 |
-
self.minsize(
|
| 198 |
-
self.
|
| 199 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
self._build_layout()
|
| 202 |
threading.Thread(target=self._fetch_files, daemon=True).start()
|
|
@@ -208,104 +395,237 @@ class ChahuadevHub(ctk.CTk):
|
|
| 208 |
self.grid_columnconfigure(1, weight=1)
|
| 209 |
|
| 210 |
# ── Sidebar ──────────────────────────────────────────────────────────
|
| 211 |
-
self.sidebar = ctk.CTkFrame(self, width=
|
| 212 |
fg_color=SIDEBAR_BG)
|
| 213 |
self.sidebar.grid(row=0, column=0, rowspan=2, sticky="nsew")
|
| 214 |
self.sidebar.grid_propagate(False)
|
| 215 |
-
self.sidebar.grid_rowconfigure(
|
| 216 |
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
ctk.CTkLabel(self.sidebar, text="FILTER BY PLATFORM",
|
| 227 |
font=ctk.CTkFont(size=10, weight="bold"),
|
| 228 |
-
text_color=
|
| 229 |
|
| 230 |
self._filter_btns = {}
|
| 231 |
for i, (label, key) in enumerate([
|
| 232 |
(" All Files", "All"),
|
| 233 |
-
(" Windows", "Windows"),
|
| 234 |
-
(" Linux", "Linux"),
|
| 235 |
-
], start=
|
| 236 |
btn = ctk.CTkButton(
|
| 237 |
self.sidebar, text=label, anchor="w",
|
| 238 |
fg_color=ACCENT if key == "All" else "transparent",
|
| 239 |
-
hover_color=
|
| 240 |
-
command=lambda k=key: self._set_filter(k)
|
| 241 |
)
|
| 242 |
-
btn.grid(row=i, column=0, padx=12, pady=
|
| 243 |
self._filter_btns[key] = btn
|
| 244 |
|
| 245 |
-
#
|
| 246 |
ctk.CTkButton(
|
| 247 |
self.sidebar, text="📂 Open Downloads",
|
| 248 |
-
fg_color="transparent", hover_color=
|
| 249 |
command=self._open_download_dir,
|
| 250 |
-
).grid(row=
|
| 251 |
|
| 252 |
ctk.CTkButton(
|
| 253 |
self.sidebar, text="🔄 Refresh",
|
| 254 |
-
fg_color="transparent", hover_color=
|
| 255 |
command=self._refresh,
|
| 256 |
-
).grid(row=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
# ── Main area ────────────────────────────────────────────────────────
|
| 259 |
-
main = ctk.CTkFrame(self, fg_color=HEADER_BG, corner_radius=0)
|
| 260 |
-
main.grid(row=0, column=1, sticky="nsew")
|
| 261 |
-
main.grid_rowconfigure(
|
| 262 |
-
main.grid_columnconfigure(0, weight=1)
|
| 263 |
|
| 264 |
# Header bar
|
| 265 |
-
hdr = ctk.CTkFrame(main, fg_color=
|
| 266 |
hdr.grid(row=0, column=0, sticky="ew")
|
| 267 |
hdr.grid_columnconfigure(0, weight=1)
|
| 268 |
hdr.grid_propagate(False)
|
| 269 |
|
| 270 |
self.hdr_title = ctk.CTkLabel(
|
| 271 |
hdr, text="Available Downloads",
|
| 272 |
-
font=ctk.CTkFont(size=18, weight="bold"),
|
|
|
|
| 273 |
)
|
| 274 |
self.hdr_title.grid(row=0, column=0, padx=24, pady=18, sticky="w")
|
| 275 |
|
| 276 |
self.hdr_count = ctk.CTkLabel(
|
| 277 |
-
hdr, text="
|
| 278 |
-
text_color=
|
| 279 |
)
|
| 280 |
self.hdr_count.grid(row=0, column=1, padx=24, pady=18, sticky="e")
|
| 281 |
|
| 282 |
-
#
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
-
#
|
| 288 |
-
self.
|
| 289 |
-
self.
|
| 290 |
-
font=ctk.CTkFont(size=14), text_color="#6b7280"
|
| 291 |
)
|
| 292 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
self.statusbar = ctk.CTkLabel(
|
| 296 |
-
self, text=f"Download folder: {DOWNLOAD_DIR}",
|
| 297 |
-
font=ctk.CTkFont(size=10), text_color=
|
| 298 |
-
fg_color=
|
| 299 |
)
|
| 300 |
-
self.statusbar.grid(row=1, column=1, sticky="ew", padx=
|
| 301 |
|
| 302 |
-
# ──
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
def _fetch_files(self):
|
| 304 |
try:
|
| 305 |
resp = requests.get(HF_API_URL, timeout=15)
|
| 306 |
resp.raise_for_status()
|
| 307 |
files = resp.json()
|
| 308 |
-
# Keep only "blob" type (actual files) and skip metadata files
|
| 309 |
blobs = [f for f in files
|
| 310 |
if f.get("type") == "file" and f["path"] not in SKIP_FILES]
|
| 311 |
self.after(0, self._populate_cards, blobs)
|
|
@@ -313,8 +633,11 @@ class ChahuadevHub(ctk.CTk):
|
|
| 313 |
self.after(0, self._show_error, str(exc))
|
| 314 |
|
| 315 |
def _populate_cards(self, files: list):
|
| 316 |
-
self.
|
|
|
|
|
|
|
| 317 |
self._all_files = files
|
|
|
|
| 318 |
self._render_cards(files)
|
| 319 |
|
| 320 |
def _render_cards(self, files: list):
|
|
@@ -323,7 +646,7 @@ class ChahuadevHub(ctk.CTk):
|
|
| 323 |
self._cards.clear()
|
| 324 |
|
| 325 |
for i, f in enumerate(files):
|
| 326 |
-
card = AppCard(self.
|
| 327 |
card.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 328 |
self._cards.append(card)
|
| 329 |
|
|
@@ -332,28 +655,157 @@ class ChahuadevHub(ctk.CTk):
|
|
| 332 |
self._set_status(f"Loaded {count} files from huggingface.co/{HF_REPO}")
|
| 333 |
|
| 334 |
def _show_error(self, msg: str):
|
| 335 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
text=f"⚠ Failed to connect to Hugging Face\n{msg}",
|
| 337 |
-
text_color=
|
| 338 |
-
)
|
| 339 |
self._set_status(f"✗ Error: {msg}")
|
| 340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
# ── Filter ────────────────────────────────────────────────────────────────
|
| 342 |
def _set_filter(self, key: str):
|
| 343 |
self._filter = key
|
| 344 |
for k, btn in self._filter_btns.items():
|
| 345 |
btn.configure(fg_color=ACCENT if k == key else "transparent")
|
| 346 |
-
|
| 347 |
-
if not hasattr(self, "_all_files"):
|
| 348 |
return
|
| 349 |
-
|
| 350 |
if key == "All":
|
| 351 |
filtered = self._all_files
|
| 352 |
elif key == "Windows":
|
| 353 |
filtered = [f for f in self._all_files if ".exe" in f["path"].lower()]
|
| 354 |
-
else:
|
| 355 |
filtered = [f for f in self._all_files if ".appimage" in f["path"].lower()]
|
| 356 |
-
|
| 357 |
self._render_cards(filtered)
|
| 358 |
|
| 359 |
# ── Helpers ───────────────────────────────────────────────────────────────
|
|
@@ -362,22 +814,56 @@ class ChahuadevHub(ctk.CTk):
|
|
| 362 |
|
| 363 |
def _open_download_dir(self):
|
| 364 |
os.makedirs(DOWNLOAD_DIR, exist_ok=True)
|
| 365 |
-
os.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
|
| 367 |
def _refresh(self):
|
| 368 |
-
self._cards_clear()
|
| 369 |
-
self.loading_lbl = ctk.CTkLabel(
|
| 370 |
-
self.scroll, text="⏳ Refreshing…",
|
| 371 |
-
font=ctk.CTkFont(size=14), text_color="#6b7280"
|
| 372 |
-
)
|
| 373 |
-
self.loading_lbl.grid(row=0, column=0, pady=60)
|
| 374 |
-
self.hdr_count.configure(text="Loading…")
|
| 375 |
-
threading.Thread(target=self._fetch_files, daemon=True).start()
|
| 376 |
-
|
| 377 |
-
def _cards_clear(self):
|
| 378 |
for card in self._cards:
|
| 379 |
card.destroy()
|
| 380 |
self._cards.clear()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
|
| 382 |
|
| 383 |
# ════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 2 |
import threading
|
| 3 |
import urllib.parse
|
| 4 |
import requests
|
|
|
|
| 5 |
import os
|
| 6 |
+
import webbrowser
|
| 7 |
|
| 8 |
# ── CONFIG ──────────────────────────────────────────────────────────────────
|
| 9 |
+
HF_AUTHOR = "chahuadev"
|
| 10 |
+
HF_REPO = "chahuadev/chahuadev-framework-binaries"
|
| 11 |
+
HF_API_URL = f"https://huggingface.co/api/datasets/{HF_REPO}/tree/main"
|
| 12 |
+
HF_COMMITS_URL = f"https://huggingface.co/api/datasets/{HF_REPO}/commits/main"
|
| 13 |
+
HF_CDN_BASE = f"https://huggingface.co/datasets/{HF_REPO}/resolve/main"
|
| 14 |
+
DOWNLOAD_DIR = os.path.join(os.path.expanduser("~"), "Downloads", "ChahuadevHub")
|
| 15 |
+
|
| 16 |
+
# ── HF Explorer API ──────────────────────────────────────────────────────────
|
| 17 |
+
HF_DATASETS_API = f"https://huggingface.co/api/datasets?author={HF_AUTHOR}&full=true"
|
| 18 |
+
HF_MODELS_API = f"https://huggingface.co/api/models?author={HF_AUTHOR}&full=true"
|
| 19 |
+
HF_SPACES_API = f"https://huggingface.co/api/spaces?author={HF_AUTHOR}&full=true"
|
| 20 |
+
|
| 21 |
+
REPO_TYPE_META = {
|
| 22 |
+
"dataset": {"icon": "🗄️", "color": "#8b5cf6", "label": "Dataset"},
|
| 23 |
+
"model": {"icon": "🤖", "color": "#3b82f6", "label": "Model"},
|
| 24 |
+
"space": {"icon": "🚀", "color": "#10b981", "label": "Space"},
|
| 25 |
+
}
|
| 26 |
|
| 27 |
# ── SKIP non-app files ───────────────────────────────────────────────────────
|
| 28 |
SKIP_FILES = {".gitattributes", "README.md", "chahuadev-framework-binaries.png",
|
| 29 |
"emoji-cleaner-app.png"}
|
| 30 |
|
| 31 |
+
# ── APP METADATA ─────────────────────────────────────────────────────────────
|
| 32 |
APP_META = {
|
| 33 |
"Chahuadev Framework": {
|
| 34 |
"icon": "⚙️",
|
|
|
|
| 44 |
},
|
| 45 |
}
|
| 46 |
|
| 47 |
+
# ── ENTERPRISE PALETTE ────────────────────────────────────────────────────────
|
| 48 |
+
ctk.set_appearance_mode("dark")
|
| 49 |
+
ctk.set_default_color_theme("blue")
|
| 50 |
+
|
| 51 |
+
BG_BASE = "#09090f"
|
| 52 |
+
SIDEBAR_BG = "#0f172a" # slate-900
|
| 53 |
+
SURFACE = "#1e293b" # slate-800
|
| 54 |
+
CARD_BG = "#1e293b"
|
| 55 |
+
HEADER_BG = "#0f172a"
|
| 56 |
+
BORDER = "#334155" # slate-700
|
| 57 |
+
MUTED = "#64748b" # slate-500
|
| 58 |
+
TEXT = "#f1f5f9" # slate-100
|
| 59 |
+
TEXT_DIM = "#94a3b8" # slate-400
|
| 60 |
+
ACCENT = "#3b82f6" # blue-500
|
| 61 |
+
ACCENT_DARK = "#1d4ed8" # blue-700
|
| 62 |
+
SUCCESS = "#10b981"
|
| 63 |
+
DANGER = "#ef4444"
|
| 64 |
+
WIN_COLOR = "#3b82f6"
|
| 65 |
+
LINUX_COLOR = "#f59e0b" # amber-500
|
| 66 |
+
|
| 67 |
+
|
| 68 |
def format_size(n):
|
| 69 |
for unit in ("B", "KB", "MB", "GB"):
|
| 70 |
if n < 1024:
|
|
|
|
| 72 |
n /= 1024
|
| 73 |
return f"{n:.1f} TB"
|
| 74 |
|
| 75 |
+
|
| 76 |
def guess_app_name(path):
|
| 77 |
name = path.replace("-win-ia32.exe", "").replace("-win-x64.exe", "")
|
| 78 |
name = name.replace("-1.0.0.AppImage", "").replace(".AppImage", "").replace(".exe", "")
|
| 79 |
name = name.replace("-", " ").strip()
|
| 80 |
return name
|
| 81 |
|
| 82 |
+
|
| 83 |
def guess_platform(path):
|
| 84 |
p = path.lower()
|
| 85 |
if "ia32" in p:
|
| 86 |
+
return "Windows 32-bit", WIN_COLOR
|
| 87 |
if "x64" in p or ".exe" in p:
|
| 88 |
+
return "Windows 64-bit", WIN_COLOR
|
| 89 |
if ".appimage" in p:
|
| 90 |
+
return "Linux AppImage", LINUX_COLOR
|
| 91 |
+
return "Unknown", MUTED
|
| 92 |
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 95 |
+
class StatCard(ctk.CTkFrame):
|
| 96 |
+
"""Summary stat card shown at top of dashboard."""
|
| 97 |
+
|
| 98 |
+
def __init__(self, master, label: str, value: str, accent: str, icon: str):
|
| 99 |
+
super().__init__(master, fg_color=SURFACE, corner_radius=10,
|
| 100 |
+
border_width=1, border_color=BORDER)
|
| 101 |
+
self.columnconfigure(0, weight=1)
|
| 102 |
+
ctk.CTkLabel(self, text=icon, font=ctk.CTkFont(size=20)).grid(
|
| 103 |
+
row=0, column=0, padx=16, pady=(14, 2), sticky="w"
|
| 104 |
+
)
|
| 105 |
+
self._val_lbl = ctk.CTkLabel(
|
| 106 |
+
self, text=value,
|
| 107 |
+
font=ctk.CTkFont(size=28, weight="bold"),
|
| 108 |
+
text_color=accent, anchor="w"
|
| 109 |
+
)
|
| 110 |
+
self._val_lbl.grid(row=1, column=0, padx=16, pady=0, sticky="w")
|
| 111 |
+
ctk.CTkLabel(
|
| 112 |
+
self, text=label, font=ctk.CTkFont(size=11),
|
| 113 |
+
text_color=TEXT_DIM, anchor="w"
|
| 114 |
+
).grid(row=2, column=0, padx=16, pady=(0, 14), sticky="w")
|
| 115 |
+
|
| 116 |
+
def update_value(self, value: str):
|
| 117 |
+
self._val_lbl.configure(text=value)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 121 |
+
class SkeletonCard(ctk.CTkFrame):
|
| 122 |
+
"""Animated placeholder shown while file list is loading."""
|
| 123 |
+
|
| 124 |
+
def __init__(self, master):
|
| 125 |
+
super().__init__(master, fg_color=CARD_BG, corner_radius=10,
|
| 126 |
+
border_width=1, border_color=BORDER, height=80)
|
| 127 |
+
self.grid_propagate(False)
|
| 128 |
+
self.columnconfigure(1, weight=1)
|
| 129 |
+
self._step = 0
|
| 130 |
+
self._colors = [BORDER, SURFACE, BORDER]
|
| 131 |
+
|
| 132 |
+
self._icon = ctk.CTkFrame(self, width=36, height=36, corner_radius=18,
|
| 133 |
+
fg_color=BORDER)
|
| 134 |
+
self._icon.grid(row=0, column=0, rowspan=2, padx=16, pady=16)
|
| 135 |
+
self._icon.grid_propagate(False)
|
| 136 |
+
|
| 137 |
+
self._title = ctk.CTkFrame(self, height=14, corner_radius=4, fg_color=BORDER)
|
| 138 |
+
self._title.grid(row=0, column=1, padx=6, pady=(18, 4), sticky="ew")
|
| 139 |
+
self._title.grid_propagate(False)
|
| 140 |
+
|
| 141 |
+
self._sub = ctk.CTkFrame(self, height=10, corner_radius=4, fg_color=SURFACE)
|
| 142 |
+
self._sub.grid(row=1, column=1, padx=6, pady=(0, 18), sticky="ew")
|
| 143 |
+
self._sub.grid_propagate(False)
|
| 144 |
+
|
| 145 |
+
self.columnconfigure(2, weight=0, minsize=140)
|
| 146 |
+
self._btn_ph = ctk.CTkFrame(self, width=120, height=34, corner_radius=6,
|
| 147 |
+
fg_color=BORDER)
|
| 148 |
+
self._btn_ph.grid(row=0, column=3, rowspan=2, padx=16, pady=16)
|
| 149 |
+
self._btn_ph.grid_propagate(False)
|
| 150 |
+
|
| 151 |
+
self._animate()
|
| 152 |
+
|
| 153 |
+
def _animate(self):
|
| 154 |
+
if not self.winfo_exists():
|
| 155 |
+
return
|
| 156 |
+
self._step = (self._step + 1) % len(self._colors)
|
| 157 |
+
self._title.configure(fg_color=self._colors[self._step])
|
| 158 |
+
self._sub.configure(fg_color=self._colors[(self._step + 1) % len(self._colors)])
|
| 159 |
+
self.after(500, self._animate)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 163 |
+
class ChangelogEntry(ctk.CTkFrame):
|
| 164 |
+
"""One commit entry in the Changelog panel."""
|
| 165 |
+
|
| 166 |
+
def __init__(self, master, commit: dict):
|
| 167 |
+
super().__init__(master, fg_color=SURFACE, corner_radius=8,
|
| 168 |
+
border_width=1, border_color=BORDER)
|
| 169 |
+
self.columnconfigure(0, weight=1)
|
| 170 |
+
|
| 171 |
+
title = commit.get("title") or commit.get("message", "—")
|
| 172 |
+
sha = (commit.get("id") or "")[:7]
|
| 173 |
+
date = (commit.get("date") or "")[:10]
|
| 174 |
+
author = commit.get("authors") or [{}]
|
| 175 |
+
author_name = author[0].get("name", "—") if author else "—"
|
| 176 |
+
|
| 177 |
+
ctk.CTkLabel(self, text=title,
|
| 178 |
+
font=ctk.CTkFont(size=13, weight="bold"),
|
| 179 |
+
text_color=TEXT, anchor="w", wraplength=560).grid(
|
| 180 |
+
row=0, column=0, padx=14, pady=(12, 2), sticky="w"
|
| 181 |
+
)
|
| 182 |
+
ctk.CTkLabel(self, text=f"#{sha} · {author_name} · {date}",
|
| 183 |
+
font=ctk.CTkFont(size=10),
|
| 184 |
+
text_color=TEXT_DIM, anchor="w").grid(
|
| 185 |
+
row=1, column=0, padx=14, pady=(0, 12), sticky="w"
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 190 |
+
class RepoCard(ctk.CTkFrame):
|
| 191 |
+
"""Clickable repo card in Explorer panel."""
|
| 192 |
+
|
| 193 |
+
def __init__(self, master, repo: dict, repo_type: str, on_select):
|
| 194 |
+
meta = REPO_TYPE_META.get(repo_type, {"icon": "📦", "color": ACCENT, "label": repo_type})
|
| 195 |
+
self._repo = repo
|
| 196 |
+
self._repo_type = repo_type
|
| 197 |
+
self._on_select = on_select
|
| 198 |
+
super().__init__(master, fg_color=SURFACE, corner_radius=8,
|
| 199 |
+
border_width=1, border_color=BORDER, cursor="hand2")
|
| 200 |
+
self.columnconfigure(1, weight=1)
|
| 201 |
+
|
| 202 |
+
ctk.CTkLabel(self, text=meta["icon"], font=ctk.CTkFont(size=18)).grid(
|
| 203 |
+
row=0, column=0, rowspan=2, padx=(12, 6), pady=10
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
repo_id = repo.get("id") or repo.get("modelId", "")
|
| 207 |
+
short_id = repo_id.split("/")[-1] if "/" in repo_id else repo_id
|
| 208 |
+
last_mod = (repo.get("lastModified") or repo.get("updatedAt") or "")[:10]
|
| 209 |
+
downloads = repo.get("downloads") or repo.get("downloadsAllTime") or ""
|
| 210 |
+
private = "🔒" if repo.get("private") else ""
|
| 211 |
+
|
| 212 |
+
self._name_lbl = ctk.CTkLabel(
|
| 213 |
+
self, text=short_id,
|
| 214 |
+
font=ctk.CTkFont(size=12, weight="bold"),
|
| 215 |
+
text_color=TEXT, anchor="w"
|
| 216 |
+
)
|
| 217 |
+
self._name_lbl.grid(row=0, column=1, padx=4, pady=(10, 1), sticky="w")
|
| 218 |
+
|
| 219 |
+
info_parts = [meta["label"]]
|
| 220 |
+
if downloads:
|
| 221 |
+
info_parts.append(f"↓{downloads}")
|
| 222 |
+
if last_mod:
|
| 223 |
+
info_parts.append(last_mod)
|
| 224 |
+
if private:
|
| 225 |
+
info_parts.append(private)
|
| 226 |
+
ctk.CTkLabel(
|
| 227 |
+
self, text=" · ".join(info_parts),
|
| 228 |
+
font=ctk.CTkFont(size=10), text_color=TEXT_DIM, anchor="w"
|
| 229 |
+
).grid(row=1, column=1, padx=4, pady=(0, 10), sticky="w")
|
| 230 |
+
|
| 231 |
+
ctk.CTkLabel(
|
| 232 |
+
self, text=meta["label"],
|
| 233 |
+
fg_color=meta["color"], corner_radius=4,
|
| 234 |
+
font=ctk.CTkFont(size=9, weight="bold"), padx=6, pady=1,
|
| 235 |
+
text_color="white"
|
| 236 |
+
).grid(row=0, column=2, padx=8, pady=(10, 0), sticky="e")
|
| 237 |
+
|
| 238 |
+
for w in (self, self._name_lbl):
|
| 239 |
+
w.bind("<Button-1>", lambda e: self._on_select(self._repo, self._repo_type))
|
| 240 |
+
|
| 241 |
+
def set_active(self, active: bool):
|
| 242 |
+
self.configure(
|
| 243 |
+
fg_color="#1e3a5f" if active else SURFACE,
|
| 244 |
+
border_color=ACCENT if active else BORDER
|
| 245 |
+
)
|
| 246 |
|
| 247 |
|
| 248 |
# ════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 250 |
"""Single file download card."""
|
| 251 |
|
| 252 |
def __init__(self, master, file_info: dict, download_dir: str, status_cb):
|
| 253 |
+
super().__init__(master, fg_color=CARD_BG, corner_radius=10,
|
| 254 |
+
border_width=1, border_color=BORDER)
|
| 255 |
|
| 256 |
self.file_info = file_info
|
| 257 |
self.download_dir = download_dir
|
| 258 |
self.status_cb = status_cb
|
| 259 |
self._thread = None
|
| 260 |
|
| 261 |
+
path = file_info["path"]
|
| 262 |
+
size = file_info.get("size", 0)
|
| 263 |
app_name = guess_app_name(path)
|
| 264 |
+
meta = APP_META.get(app_name, {"icon": "📦", "desc": path})
|
| 265 |
plat, plat_color = guess_platform(path)
|
| 266 |
|
| 267 |
self.columnconfigure(1, weight=1)
|
| 268 |
|
| 269 |
# Icon
|
| 270 |
+
ctk.CTkLabel(self, text=meta["icon"], font=ctk.CTkFont(size=32)).grid(
|
| 271 |
+
row=0, column=0, rowspan=2, padx=(16, 10), pady=16
|
| 272 |
+
)
|
| 273 |
|
| 274 |
# App name
|
| 275 |
+
ctk.CTkLabel(self, text=app_name,
|
| 276 |
+
font=ctk.CTkFont(size=15, weight="bold"),
|
| 277 |
+
text_color=TEXT, anchor="w").grid(
|
| 278 |
+
row=0, column=1, sticky="sw", padx=4, pady=(14, 0)
|
| 279 |
+
)
|
| 280 |
|
| 281 |
# Description + size
|
| 282 |
+
ctk.CTkLabel(self, text=f"{meta['desc']} • {format_size(size)}",
|
| 283 |
+
font=ctk.CTkFont(size=11),
|
| 284 |
+
text_color=TEXT_DIM, anchor="w").grid(
|
| 285 |
+
row=1, column=1, sticky="nw", padx=4, pady=(0, 14)
|
| 286 |
+
)
|
| 287 |
|
| 288 |
# Platform badge
|
| 289 |
+
ctk.CTkLabel(self, text=plat, fg_color=plat_color,
|
| 290 |
+
corner_radius=6, font=ctk.CTkFont(size=10, weight="bold"),
|
| 291 |
+
padx=8, pady=2).grid(
|
| 292 |
+
row=0, column=2, padx=8, pady=(14, 0), sticky="e"
|
| 293 |
+
)
|
| 294 |
|
| 295 |
# Filename label (small)
|
| 296 |
+
ctk.CTkLabel(self, text=path, font=ctk.CTkFont(size=10),
|
| 297 |
+
text_color=MUTED, anchor="e").grid(
|
| 298 |
+
row=1, column=2, padx=8, pady=(0, 14), sticky="e"
|
| 299 |
+
)
|
| 300 |
|
| 301 |
# Download button
|
| 302 |
self.btn = ctk.CTkButton(self, text="⬇ Download", width=130,
|
| 303 |
+
fg_color=ACCENT, hover_color=ACCENT_DARK,
|
| 304 |
command=self._start_download)
|
| 305 |
self.btn.grid(row=0, column=3, rowspan=2, padx=16, pady=16)
|
| 306 |
|
| 307 |
# Progress bar (hidden initially)
|
| 308 |
+
self.pbar = ctk.CTkProgressBar(self, width=130,
|
| 309 |
+
progress_color=ACCENT, fg_color=BORDER)
|
| 310 |
self.pbar.set(0)
|
| 311 |
|
| 312 |
# Percent label
|
| 313 |
self.pct_lbl = ctk.CTkLabel(self, text="", font=ctk.CTkFont(size=10),
|
| 314 |
+
text_color=TEXT_DIM)
|
| 315 |
|
| 316 |
# ── download logic ────────────────────────────────────────────────────────
|
| 317 |
def _start_download(self):
|
|
|
|
| 329 |
total = self.file_info.get("size", 0)
|
| 330 |
url = f"{HF_CDN_BASE}/{urllib.parse.quote(path)}"
|
| 331 |
dest = os.path.join(self.download_dir, path)
|
| 332 |
+
chunk_size = 65536
|
| 333 |
|
| 334 |
try:
|
| 335 |
self.btn.configure(text="Connecting…")
|
|
|
|
| 349 |
text=f"{format_size(downloaded)} / {format_size(total)} ({pct*100:.0f}%)"
|
| 350 |
)
|
| 351 |
|
|
|
|
| 352 |
if total > 0 and downloaded != total:
|
| 353 |
raise IOError(
|
| 354 |
f"Incomplete download: got {format_size(downloaded)}, expected {format_size(total)}"
|
| 355 |
)
|
| 356 |
|
|
|
|
| 357 |
self.btn.configure(text="✓ Done", fg_color=SUCCESS, state="normal")
|
| 358 |
self.pbar.set(1)
|
| 359 |
self.pct_lbl.configure(text=f"Saved → {dest}")
|
| 360 |
self.status_cb(f"✓ Downloaded: {path}")
|
| 361 |
|
| 362 |
except Exception as exc:
|
| 363 |
+
self.btn.configure(text="⚠ Retry", state="normal", fg_color=DANGER)
|
| 364 |
self.pct_lbl.configure(text=f"Error: {exc}")
|
| 365 |
self.status_cb(f"✗ Failed: {path} — {exc}")
|
|
|
|
| 366 |
if os.path.exists(dest):
|
| 367 |
try:
|
| 368 |
os.remove(dest)
|
|
|
|
| 376 |
def __init__(self):
|
| 377 |
super().__init__()
|
| 378 |
self.title("Chahuadev Hub")
|
| 379 |
+
self.geometry("1080x720")
|
| 380 |
+
self.minsize(900, 580)
|
| 381 |
+
self.configure(fg_color=BG_BASE)
|
| 382 |
+
self._filter = "All"
|
| 383 |
+
self._cards = []
|
| 384 |
+
self._all_files = []
|
| 385 |
+
self._skeletons = []
|
| 386 |
+
self._nav = "downloads"
|
| 387 |
|
| 388 |
self._build_layout()
|
| 389 |
threading.Thread(target=self._fetch_files, daemon=True).start()
|
|
|
|
| 395 |
self.grid_columnconfigure(1, weight=1)
|
| 396 |
|
| 397 |
# ── Sidebar ──────────────────────────────────────────────────────────
|
| 398 |
+
self.sidebar = ctk.CTkFrame(self, width=220, corner_radius=0,
|
| 399 |
fg_color=SIDEBAR_BG)
|
| 400 |
self.sidebar.grid(row=0, column=0, rowspan=2, sticky="nsew")
|
| 401 |
self.sidebar.grid_propagate(False)
|
| 402 |
+
self.sidebar.grid_rowconfigure(20, weight=1)
|
| 403 |
|
| 404 |
+
ctk.CTkLabel(self.sidebar, text="CHAHUADEV\nHUB",
|
| 405 |
+
font=ctk.CTkFont(size=22, weight="bold"),
|
| 406 |
+
text_color="#7c3aed").grid(
|
| 407 |
+
row=0, column=0, padx=20, pady=(28, 4)
|
| 408 |
+
)
|
| 409 |
+
ctk.CTkLabel(self.sidebar, text="Official App Distribution",
|
| 410 |
+
font=ctk.CTkFont(size=10), text_color=MUTED).grid(
|
| 411 |
+
row=1, column=0, padx=20, pady=(0, 24)
|
| 412 |
+
)
|
| 413 |
|
| 414 |
+
# ─ Navigation ─
|
| 415 |
+
ctk.CTkLabel(self.sidebar, text="NAVIGATE",
|
| 416 |
+
font=ctk.CTkFont(size=10, weight="bold"),
|
| 417 |
+
text_color=MUTED).grid(row=2, column=0, padx=20, sticky="w")
|
| 418 |
|
| 419 |
+
self._nav_btns = {}
|
| 420 |
+
for i, (label, key) in enumerate([
|
| 421 |
+
(" ⬇ Downloads", "downloads"),
|
| 422 |
+
(" � Explorer", "explorer"),
|
| 423 |
+
(" �📋 Changelog", "changelog"),
|
| 424 |
+
], start=3):
|
| 425 |
+
btn = ctk.CTkButton(
|
| 426 |
+
self.sidebar, text=label, anchor="w",
|
| 427 |
+
fg_color=ACCENT if key == "downloads" else "transparent",
|
| 428 |
+
hover_color=ACCENT_DARK,
|
| 429 |
+
command=lambda k=key: self._switch_nav(k)
|
| 430 |
+
)
|
| 431 |
+
btn.grid(row=i, column=0, padx=12, pady=3, sticky="ew")
|
| 432 |
+
self._nav_btns[key] = btn
|
| 433 |
+
|
| 434 |
+
# ─ Filter ─
|
| 435 |
ctk.CTkLabel(self.sidebar, text="FILTER BY PLATFORM",
|
| 436 |
font=ctk.CTkFont(size=10, weight="bold"),
|
| 437 |
+
text_color=MUTED).grid(row=6, column=0, padx=20, pady=(20, 4), sticky="w")
|
| 438 |
|
| 439 |
self._filter_btns = {}
|
| 440 |
for i, (label, key) in enumerate([
|
| 441 |
(" All Files", "All"),
|
| 442 |
+
(" 🪟 Windows", "Windows"),
|
| 443 |
+
(" 🐧 Linux", "Linux"),
|
| 444 |
+
], start=7):
|
| 445 |
btn = ctk.CTkButton(
|
| 446 |
self.sidebar, text=label, anchor="w",
|
| 447 |
fg_color=ACCENT if key == "All" else "transparent",
|
| 448 |
+
hover_color=ACCENT_DARK,
|
| 449 |
+
command=lambda k=key: self._set_filter(k)
|
| 450 |
)
|
| 451 |
+
btn.grid(row=i, column=0, padx=12, pady=3, sticky="ew")
|
| 452 |
self._filter_btns[key] = btn
|
| 453 |
|
| 454 |
+
# ─ Bottom actions ─
|
| 455 |
ctk.CTkButton(
|
| 456 |
self.sidebar, text="📂 Open Downloads",
|
| 457 |
+
fg_color="transparent", hover_color=SURFACE,
|
| 458 |
command=self._open_download_dir,
|
| 459 |
+
).grid(row=20, column=0, padx=12, pady=(0, 6), sticky="ew")
|
| 460 |
|
| 461 |
ctk.CTkButton(
|
| 462 |
self.sidebar, text="🔄 Refresh",
|
| 463 |
+
fg_color="transparent", hover_color=SURFACE,
|
| 464 |
command=self._refresh,
|
| 465 |
+
).grid(row=21, column=0, padx=12, pady=(0, 6), sticky="ew")
|
| 466 |
+
|
| 467 |
+
ctk.CTkButton(
|
| 468 |
+
self.sidebar, text="🔗 Hugging Face",
|
| 469 |
+
fg_color="transparent", hover_color=SURFACE,
|
| 470 |
+
command=lambda: webbrowser.open(f"https://huggingface.co/{HF_REPO}")
|
| 471 |
+
).grid(row=22, column=0, padx=12, pady=(0, 20), sticky="ew")
|
| 472 |
|
| 473 |
# ── Main area ────────────────────────────────────────────────────────
|
| 474 |
+
self.main = ctk.CTkFrame(self, fg_color=HEADER_BG, corner_radius=0)
|
| 475 |
+
self.main.grid(row=0, column=1, sticky="nsew")
|
| 476 |
+
self.main.grid_rowconfigure(2, weight=1)
|
| 477 |
+
self.main.grid_columnconfigure(0, weight=1)
|
| 478 |
|
| 479 |
# Header bar
|
| 480 |
+
hdr = ctk.CTkFrame(self.main, fg_color=BG_BASE, corner_radius=0, height=64)
|
| 481 |
hdr.grid(row=0, column=0, sticky="ew")
|
| 482 |
hdr.grid_columnconfigure(0, weight=1)
|
| 483 |
hdr.grid_propagate(False)
|
| 484 |
|
| 485 |
self.hdr_title = ctk.CTkLabel(
|
| 486 |
hdr, text="Available Downloads",
|
| 487 |
+
font=ctk.CTkFont(size=18, weight="bold"),
|
| 488 |
+
text_color=TEXT, anchor="w"
|
| 489 |
)
|
| 490 |
self.hdr_title.grid(row=0, column=0, padx=24, pady=18, sticky="w")
|
| 491 |
|
| 492 |
self.hdr_count = ctk.CTkLabel(
|
| 493 |
+
hdr, text="Fetching…",
|
| 494 |
+
font=ctk.CTkFont(size=12), text_color=MUTED, anchor="e"
|
| 495 |
)
|
| 496 |
self.hdr_count.grid(row=0, column=1, padx=24, pady=18, sticky="e")
|
| 497 |
|
| 498 |
+
# Stats cards row
|
| 499 |
+
stats_row = ctk.CTkFrame(self.main, fg_color=HEADER_BG, corner_radius=0, height=110)
|
| 500 |
+
stats_row.grid(row=1, column=0, sticky="ew", padx=20, pady=(10, 0))
|
| 501 |
+
stats_row.grid_columnconfigure((0, 1, 2), weight=1)
|
| 502 |
+
stats_row.grid_propagate(False)
|
| 503 |
+
|
| 504 |
+
self._stat_total = StatCard(stats_row, "Total Files", "—", ACCENT, "📦")
|
| 505 |
+
self._stat_win = StatCard(stats_row, "Windows Files", "—", WIN_COLOR, "🪟")
|
| 506 |
+
self._stat_linux = StatCard(stats_row, "Linux Files", "—", LINUX_COLOR,"🐧")
|
| 507 |
+
self._stat_total.grid(row=0, column=0, padx=(0, 8), pady=0, sticky="nsew")
|
| 508 |
+
self._stat_win.grid (row=0, column=1, padx=8, pady=0, sticky="nsew")
|
| 509 |
+
self._stat_linux.grid(row=0, column=2, padx=(8, 0), pady=0, sticky="nsew")
|
| 510 |
+
|
| 511 |
+
# Content frame (holds downloads & changelog panels)
|
| 512 |
+
self.content_frame = ctk.CTkFrame(self.main, fg_color=HEADER_BG, corner_radius=0)
|
| 513 |
+
self.content_frame.grid(row=2, column=0, sticky="nsew", padx=0, pady=(12, 0))
|
| 514 |
+
self.content_frame.grid_rowconfigure(0, weight=1)
|
| 515 |
+
self.content_frame.grid_columnconfigure(0, weight=1)
|
| 516 |
+
|
| 517 |
+
# Downloads panel
|
| 518 |
+
self.downloads_panel = ctk.CTkScrollableFrame(
|
| 519 |
+
self.content_frame, fg_color=HEADER_BG, corner_radius=0
|
| 520 |
+
)
|
| 521 |
+
self.downloads_panel.grid(row=0, column=0, sticky="nsew")
|
| 522 |
+
self.downloads_panel.grid_columnconfigure(0, weight=1)
|
| 523 |
+
|
| 524 |
+
for i in range(4):
|
| 525 |
+
sk = SkeletonCard(self.downloads_panel)
|
| 526 |
+
sk.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 527 |
+
self._skeletons.append(sk)
|
| 528 |
+
|
| 529 |
+
# ── Explorer panel (hidden initially) ────────────────────────────────
|
| 530 |
+
self.explorer_panel = ctk.CTkFrame(
|
| 531 |
+
self.content_frame, fg_color=HEADER_BG, corner_radius=0
|
| 532 |
+
)
|
| 533 |
+
self.explorer_panel.grid(row=0, column=0, sticky="nsew")
|
| 534 |
+
self.explorer_panel.grid_rowconfigure(0, weight=1)
|
| 535 |
+
self.explorer_panel.grid_columnconfigure(0, weight=0, minsize=280)
|
| 536 |
+
self.explorer_panel.grid_columnconfigure(1, weight=1)
|
| 537 |
+
self.explorer_panel.grid_remove()
|
| 538 |
+
|
| 539 |
+
# Left: repo list
|
| 540 |
+
self._repo_list_frame = ctk.CTkScrollableFrame(
|
| 541 |
+
self.explorer_panel, fg_color=SURFACE, corner_radius=0, width=260
|
| 542 |
+
)
|
| 543 |
+
self._repo_list_frame.grid(row=0, column=0, sticky="nsew", padx=(0, 1))
|
| 544 |
+
self._repo_list_frame.grid_columnconfigure(0, weight=1)
|
| 545 |
+
|
| 546 |
+
self._repo_loading_lbl = ctk.CTkLabel(
|
| 547 |
+
self._repo_list_frame, text="⏳ Fetching repos…",
|
| 548 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 549 |
+
)
|
| 550 |
+
self._repo_loading_lbl.grid(row=0, column=0, pady=40)
|
| 551 |
|
| 552 |
+
# Right: commit detail
|
| 553 |
+
self._commit_frame = ctk.CTkFrame(
|
| 554 |
+
self.explorer_panel, fg_color=HEADER_BG, corner_radius=0
|
|
|
|
| 555 |
)
|
| 556 |
+
self._commit_frame.grid(row=0, column=1, sticky="nsew")
|
| 557 |
+
self._commit_frame.grid_rowconfigure(1, weight=1)
|
| 558 |
+
self._commit_frame.grid_columnconfigure(0, weight=1)
|
| 559 |
+
|
| 560 |
+
self._commit_hdr = ctk.CTkLabel(
|
| 561 |
+
self._commit_frame,
|
| 562 |
+
text="← Select a repo to view commits",
|
| 563 |
+
font=ctk.CTkFont(size=13), text_color=MUTED, anchor="w"
|
| 564 |
+
)
|
| 565 |
+
self._commit_hdr.grid(row=0, column=0, padx=20, pady=14, sticky="w")
|
| 566 |
|
| 567 |
+
self._commit_scroll = ctk.CTkScrollableFrame(
|
| 568 |
+
self._commit_frame, fg_color=HEADER_BG, corner_radius=0
|
| 569 |
+
)
|
| 570 |
+
self._commit_scroll.grid(row=1, column=0, sticky="nsew")
|
| 571 |
+
self._commit_scroll.grid_columnconfigure(0, weight=1)
|
| 572 |
+
|
| 573 |
+
self._repo_cards: list = []
|
| 574 |
+
self._active_repo_card = None
|
| 575 |
+
|
| 576 |
+
# Changelog panel (hidden initially)
|
| 577 |
+
self.changelog_panel = ctk.CTkScrollableFrame(
|
| 578 |
+
self.content_frame, fg_color=HEADER_BG, corner_radius=0
|
| 579 |
+
)
|
| 580 |
+
self.changelog_panel.grid(row=0, column=0, sticky="nsew")
|
| 581 |
+
self.changelog_panel.grid_columnconfigure(0, weight=1)
|
| 582 |
+
self.changelog_panel.grid_remove()
|
| 583 |
+
|
| 584 |
+
self._changelog_lbl = ctk.CTkLabel(
|
| 585 |
+
self.changelog_panel, text="⏳ Loading commit history…",
|
| 586 |
+
font=ctk.CTkFont(size=14), text_color=MUTED
|
| 587 |
+
)
|
| 588 |
+
self._changelog_lbl.grid(row=0, column=0, pady=60)
|
| 589 |
+
|
| 590 |
+
# Status bar
|
| 591 |
self.statusbar = ctk.CTkLabel(
|
| 592 |
+
self, text=f" Download folder: {DOWNLOAD_DIR}",
|
| 593 |
+
font=ctk.CTkFont(size=10), text_color=MUTED,
|
| 594 |
+
fg_color=BG_BASE, anchor="w", corner_radius=0
|
| 595 |
)
|
| 596 |
+
self.statusbar.grid(row=1, column=1, sticky="ew", padx=0, pady=0)
|
| 597 |
|
| 598 |
+
# ── Navigation ───────────────────────────────────────────────────────────
|
| 599 |
+
def _switch_nav(self, key: str):
|
| 600 |
+
self._nav = key
|
| 601 |
+
for k, btn in self._nav_btns.items():
|
| 602 |
+
btn.configure(fg_color=ACCENT if k == key else "transparent")
|
| 603 |
+
|
| 604 |
+
self.downloads_panel.grid_remove()
|
| 605 |
+
self.explorer_panel.grid_remove()
|
| 606 |
+
self.changelog_panel.grid_remove()
|
| 607 |
+
|
| 608 |
+
if key == "downloads":
|
| 609 |
+
self.hdr_title.configure(text="Available Downloads")
|
| 610 |
+
self.downloads_panel.grid()
|
| 611 |
+
elif key == "explorer":
|
| 612 |
+
self.hdr_title.configure(text="🔍 Repo Explorer — huggingface.co/chahuadev")
|
| 613 |
+
self.hdr_count.configure(text="")
|
| 614 |
+
self.explorer_panel.grid()
|
| 615 |
+
if not hasattr(self, "_explorer_loaded"):
|
| 616 |
+
threading.Thread(target=self._fetch_all_repos, daemon=True).start()
|
| 617 |
+
else:
|
| 618 |
+
self.hdr_title.configure(text="Changelog — Commit History")
|
| 619 |
+
self.changelog_panel.grid()
|
| 620 |
+
if not hasattr(self, "_changelog_loaded"):
|
| 621 |
+
threading.Thread(target=self._fetch_changelog, daemon=True).start()
|
| 622 |
+
|
| 623 |
+
# ── API fetch — files ─────────────────────────────────────────────────────
|
| 624 |
def _fetch_files(self):
|
| 625 |
try:
|
| 626 |
resp = requests.get(HF_API_URL, timeout=15)
|
| 627 |
resp.raise_for_status()
|
| 628 |
files = resp.json()
|
|
|
|
| 629 |
blobs = [f for f in files
|
| 630 |
if f.get("type") == "file" and f["path"] not in SKIP_FILES]
|
| 631 |
self.after(0, self._populate_cards, blobs)
|
|
|
|
| 633 |
self.after(0, self._show_error, str(exc))
|
| 634 |
|
| 635 |
def _populate_cards(self, files: list):
|
| 636 |
+
for sk in self._skeletons:
|
| 637 |
+
sk.destroy()
|
| 638 |
+
self._skeletons.clear()
|
| 639 |
self._all_files = files
|
| 640 |
+
self._update_stats(files)
|
| 641 |
self._render_cards(files)
|
| 642 |
|
| 643 |
def _render_cards(self, files: list):
|
|
|
|
| 646 |
self._cards.clear()
|
| 647 |
|
| 648 |
for i, f in enumerate(files):
|
| 649 |
+
card = AppCard(self.downloads_panel, f, DOWNLOAD_DIR, self._set_status)
|
| 650 |
card.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 651 |
self._cards.append(card)
|
| 652 |
|
|
|
|
| 655 |
self._set_status(f"Loaded {count} files from huggingface.co/{HF_REPO}")
|
| 656 |
|
| 657 |
def _show_error(self, msg: str):
|
| 658 |
+
for sk in self._skeletons:
|
| 659 |
+
sk.destroy()
|
| 660 |
+
self._skeletons.clear()
|
| 661 |
+
ctk.CTkLabel(
|
| 662 |
+
self.downloads_panel,
|
| 663 |
text=f"⚠ Failed to connect to Hugging Face\n{msg}",
|
| 664 |
+
font=ctk.CTkFont(size=14), text_color=DANGER
|
| 665 |
+
).grid(row=0, column=0, pady=60)
|
| 666 |
self._set_status(f"✗ Error: {msg}")
|
| 667 |
|
| 668 |
+
def _update_stats(self, files: list):
|
| 669 |
+
total = len(files)
|
| 670 |
+
wins = sum(1 for f in files if ".exe" in f["path"].lower())
|
| 671 |
+
lins = sum(1 for f in files if ".appimage" in f["path"].lower())
|
| 672 |
+
self._stat_total.update_value(str(total))
|
| 673 |
+
self._stat_win.update_value(str(wins))
|
| 674 |
+
self._stat_linux.update_value(str(lins))
|
| 675 |
+
|
| 676 |
+
# ── API fetch — ALL repos (Explorer) ─────────────────────────────────────
|
| 677 |
+
def _fetch_all_repos(self):
|
| 678 |
+
results = []
|
| 679 |
+
for url, rtype in [
|
| 680 |
+
(HF_DATASETS_API, "dataset"),
|
| 681 |
+
(HF_MODELS_API, "model"),
|
| 682 |
+
(HF_SPACES_API, "space"),
|
| 683 |
+
]:
|
| 684 |
+
try:
|
| 685 |
+
resp = requests.get(url, timeout=15)
|
| 686 |
+
resp.raise_for_status()
|
| 687 |
+
for r in resp.json():
|
| 688 |
+
results.append((r, rtype))
|
| 689 |
+
except Exception:
|
| 690 |
+
pass
|
| 691 |
+
results.sort(
|
| 692 |
+
key=lambda x: x[0].get("lastModified") or x[0].get("updatedAt") or "",
|
| 693 |
+
reverse=True
|
| 694 |
+
)
|
| 695 |
+
self.after(0, self._populate_repos, results)
|
| 696 |
+
|
| 697 |
+
def _populate_repos(self, results: list):
|
| 698 |
+
self._explorer_loaded = True
|
| 699 |
+
if hasattr(self, "_repo_loading_lbl") and self._repo_loading_lbl.winfo_exists():
|
| 700 |
+
self._repo_loading_lbl.destroy()
|
| 701 |
+
|
| 702 |
+
total = len(results)
|
| 703 |
+
types: dict = {}
|
| 704 |
+
for _, t in results:
|
| 705 |
+
types[t] = types.get(t, 0) + 1
|
| 706 |
+
parts = [f"{total} repos"]
|
| 707 |
+
for t in ("dataset", "model", "space"):
|
| 708 |
+
if types.get(t):
|
| 709 |
+
m = REPO_TYPE_META[t]
|
| 710 |
+
parts.append(f"{m['icon']} {types[t]} {m['label']}s")
|
| 711 |
+
self.hdr_count.configure(text=" · ".join(parts))
|
| 712 |
+
self._set_status(f"Loaded {total} repos from huggingface.co/{HF_AUTHOR}")
|
| 713 |
+
|
| 714 |
+
for i, (repo, rtype) in enumerate(results):
|
| 715 |
+
card = RepoCard(self._repo_list_frame, repo, rtype, self._on_repo_select)
|
| 716 |
+
card.grid(row=i, column=0, padx=8, pady=4, sticky="ew")
|
| 717 |
+
self._repo_cards.append(card)
|
| 718 |
+
|
| 719 |
+
def _on_repo_select(self, repo: dict, repo_type: str):
|
| 720 |
+
repo_id = repo.get("id") or repo.get("modelId", "")
|
| 721 |
+
for card in self._repo_cards:
|
| 722 |
+
cid = card._repo.get("id") or card._repo.get("modelId", "")
|
| 723 |
+
card.set_active(cid == repo_id)
|
| 724 |
+
|
| 725 |
+
for w in self._commit_scroll.winfo_children():
|
| 726 |
+
w.destroy()
|
| 727 |
+
self._commit_hdr.configure(text=f"📋 Commits — {repo_id}", text_color=TEXT)
|
| 728 |
+
|
| 729 |
+
lbl = ctk.CTkLabel(
|
| 730 |
+
self._commit_scroll, text="⏳ Loading commits…",
|
| 731 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 732 |
+
)
|
| 733 |
+
lbl.grid(row=0, column=0, pady=40)
|
| 734 |
+
threading.Thread(
|
| 735 |
+
target=self._fetch_repo_commits,
|
| 736 |
+
args=(repo_id, repo_type),
|
| 737 |
+
daemon=True
|
| 738 |
+
).start()
|
| 739 |
+
|
| 740 |
+
def _fetch_repo_commits(self, repo_id: str, repo_type: str):
|
| 741 |
+
url = f"https://huggingface.co/api/{repo_type}s/{repo_id}/commits/main"
|
| 742 |
+
try:
|
| 743 |
+
resp = requests.get(url, timeout=15)
|
| 744 |
+
resp.raise_for_status()
|
| 745 |
+
commits = resp.json()
|
| 746 |
+
self.after(0, self._show_repo_commits, commits, repo_id)
|
| 747 |
+
except Exception as exc:
|
| 748 |
+
self.after(0, self._show_repo_commits_error, str(exc))
|
| 749 |
+
|
| 750 |
+
def _show_repo_commits(self, commits: list, repo_id: str):
|
| 751 |
+
for w in self._commit_scroll.winfo_children():
|
| 752 |
+
w.destroy()
|
| 753 |
+
if not commits:
|
| 754 |
+
ctk.CTkLabel(
|
| 755 |
+
self._commit_scroll, text="No commits found",
|
| 756 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 757 |
+
).grid(row=0, column=0, pady=40)
|
| 758 |
+
return
|
| 759 |
+
for i, commit in enumerate(commits):
|
| 760 |
+
entry = ChangelogEntry(self._commit_scroll, commit)
|
| 761 |
+
entry.grid(row=i, column=0, padx=12, pady=5, sticky="ew")
|
| 762 |
+
self._commit_scroll.grid_columnconfigure(0, weight=1)
|
| 763 |
+
self._set_status(f"{len(commits)} commits — {repo_id}")
|
| 764 |
+
|
| 765 |
+
def _show_repo_commits_error(self, msg: str):
|
| 766 |
+
for w in self._commit_scroll.winfo_children():
|
| 767 |
+
w.destroy()
|
| 768 |
+
ctk.CTkLabel(
|
| 769 |
+
self._commit_scroll, text=f"⚠ {msg}",
|
| 770 |
+
font=ctk.CTkFont(size=13), text_color=DANGER
|
| 771 |
+
).grid(row=0, column=0, pady=40)
|
| 772 |
+
|
| 773 |
+
# ── API fetch — changelog ─────────────────────────────────────────────────
|
| 774 |
+
def _fetch_changelog(self):
|
| 775 |
+
try:
|
| 776 |
+
resp = requests.get(HF_COMMITS_URL, timeout=15)
|
| 777 |
+
resp.raise_for_status()
|
| 778 |
+
commits = resp.json()
|
| 779 |
+
self.after(0, self._populate_changelog, commits)
|
| 780 |
+
except Exception as exc:
|
| 781 |
+
self.after(0, self._changelog_error, str(exc))
|
| 782 |
+
|
| 783 |
+
def _populate_changelog(self, commits: list):
|
| 784 |
+
self._changelog_loaded = True
|
| 785 |
+
self._changelog_lbl.destroy()
|
| 786 |
+
for i, commit in enumerate(commits):
|
| 787 |
+
entry = ChangelogEntry(self.changelog_panel, commit)
|
| 788 |
+
entry.grid(row=i, column=0, padx=20, pady=6, sticky="ew")
|
| 789 |
+
self._set_status(f"Loaded {len(commits)} commits from Hugging Face")
|
| 790 |
+
|
| 791 |
+
def _changelog_error(self, msg: str):
|
| 792 |
+
self._changelog_lbl.configure(
|
| 793 |
+
text=f"⚠ Failed to load changelog\n{msg}", text_color=DANGER
|
| 794 |
+
)
|
| 795 |
+
|
| 796 |
# ── Filter ────────────────────────────────────────────────────────────────
|
| 797 |
def _set_filter(self, key: str):
|
| 798 |
self._filter = key
|
| 799 |
for k, btn in self._filter_btns.items():
|
| 800 |
btn.configure(fg_color=ACCENT if k == key else "transparent")
|
| 801 |
+
if not self._all_files:
|
|
|
|
| 802 |
return
|
|
|
|
| 803 |
if key == "All":
|
| 804 |
filtered = self._all_files
|
| 805 |
elif key == "Windows":
|
| 806 |
filtered = [f for f in self._all_files if ".exe" in f["path"].lower()]
|
| 807 |
+
else:
|
| 808 |
filtered = [f for f in self._all_files if ".appimage" in f["path"].lower()]
|
|
|
|
| 809 |
self._render_cards(filtered)
|
| 810 |
|
| 811 |
# ── Helpers ───────────────────────────────────────────────────────────────
|
|
|
|
| 814 |
|
| 815 |
def _open_download_dir(self):
|
| 816 |
os.makedirs(DOWNLOAD_DIR, exist_ok=True)
|
| 817 |
+
if os.name == "nt":
|
| 818 |
+
os.startfile(DOWNLOAD_DIR)
|
| 819 |
+
else:
|
| 820 |
+
import subprocess
|
| 821 |
+
subprocess.Popen(["xdg-open", DOWNLOAD_DIR])
|
| 822 |
|
| 823 |
def _refresh(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 824 |
for card in self._cards:
|
| 825 |
card.destroy()
|
| 826 |
self._cards.clear()
|
| 827 |
+
self._all_files = []
|
| 828 |
+
self._stat_total.update_value("—")
|
| 829 |
+
self._stat_win.update_value("—")
|
| 830 |
+
self._stat_linux.update_value("—")
|
| 831 |
+
self.hdr_count.configure(text="Fetching…")
|
| 832 |
+
|
| 833 |
+
for i in range(4):
|
| 834 |
+
sk = SkeletonCard(self.downloads_panel)
|
| 835 |
+
sk.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 836 |
+
self._skeletons.append(sk)
|
| 837 |
+
|
| 838 |
+
if hasattr(self, "_changelog_loaded"):
|
| 839 |
+
del self._changelog_loaded
|
| 840 |
+
for w in self.changelog_panel.winfo_children():
|
| 841 |
+
w.destroy()
|
| 842 |
+
self._changelog_lbl = ctk.CTkLabel(
|
| 843 |
+
self.changelog_panel, text="⏳ Loading commit history…",
|
| 844 |
+
font=ctk.CTkFont(size=14), text_color=MUTED
|
| 845 |
+
)
|
| 846 |
+
self._changelog_lbl.grid(row=0, column=0, pady=60)
|
| 847 |
+
|
| 848 |
+
# Reset explorer
|
| 849 |
+
if hasattr(self, "_explorer_loaded"):
|
| 850 |
+
del self._explorer_loaded
|
| 851 |
+
for card in self._repo_cards:
|
| 852 |
+
card.destroy()
|
| 853 |
+
self._repo_cards.clear()
|
| 854 |
+
self._active_repo_card = None
|
| 855 |
+
for w in self._commit_scroll.winfo_children():
|
| 856 |
+
w.destroy()
|
| 857 |
+
self._commit_hdr.configure(
|
| 858 |
+
text="← Select a repo to view commits", text_color=MUTED
|
| 859 |
+
)
|
| 860 |
+
self._repo_loading_lbl = ctk.CTkLabel(
|
| 861 |
+
self._repo_list_frame, text="⏳ Fetching repos…",
|
| 862 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 863 |
+
)
|
| 864 |
+
self._repo_loading_lbl.grid(row=0, column=0, pady=40)
|
| 865 |
+
|
| 866 |
+
threading.Thread(target=self._fetch_files, daemon=True).start()
|
| 867 |
|
| 868 |
|
| 869 |
# ════════════════════════════════════════════════════════════════════════════
|
chahuadev_hub/main.py
CHANGED
|
@@ -2,21 +2,33 @@ import customtkinter as ctk
|
|
| 2 |
import threading
|
| 3 |
import urllib.parse
|
| 4 |
import requests
|
| 5 |
-
import json
|
| 6 |
import os
|
| 7 |
-
import
|
| 8 |
|
| 9 |
# ── CONFIG ──────────────────────────────────────────────────────────────────
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# ── SKIP non-app files ───────────────────────────────────────────────────────
|
| 16 |
SKIP_FILES = {".gitattributes", "README.md", "chahuadev-framework-binaries.png",
|
| 17 |
"emoji-cleaner-app.png"}
|
| 18 |
|
| 19 |
-
# ── APP METADATA
|
| 20 |
APP_META = {
|
| 21 |
"Chahuadev Framework": {
|
| 22 |
"icon": "⚙️",
|
|
@@ -32,6 +44,27 @@ APP_META = {
|
|
| 32 |
},
|
| 33 |
}
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def format_size(n):
|
| 36 |
for unit in ("B", "KB", "MB", "GB"):
|
| 37 |
if n < 1024:
|
|
@@ -39,31 +72,177 @@ def format_size(n):
|
|
| 39 |
n /= 1024
|
| 40 |
return f"{n:.1f} TB"
|
| 41 |
|
|
|
|
| 42 |
def guess_app_name(path):
|
| 43 |
name = path.replace("-win-ia32.exe", "").replace("-win-x64.exe", "")
|
| 44 |
name = name.replace("-1.0.0.AppImage", "").replace(".AppImage", "").replace(".exe", "")
|
| 45 |
name = name.replace("-", " ").strip()
|
| 46 |
return name
|
| 47 |
|
|
|
|
| 48 |
def guess_platform(path):
|
| 49 |
p = path.lower()
|
| 50 |
if "ia32" in p:
|
| 51 |
-
return "Windows 32-bit",
|
| 52 |
if "x64" in p or ".exe" in p:
|
| 53 |
-
return "Windows 64-bit",
|
| 54 |
if ".appimage" in p:
|
| 55 |
-
return "Linux AppImage",
|
| 56 |
-
return "Unknown",
|
| 57 |
|
| 58 |
-
# ── THEME ────────────────────────────────────────────────────────────────────
|
| 59 |
-
ctk.set_appearance_mode("dark")
|
| 60 |
-
ctk.set_default_color_theme("blue")
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
# ════════════════════════════════════════════════════════════════════════════
|
|
@@ -71,61 +250,68 @@ class AppCard(ctk.CTkFrame):
|
|
| 71 |
"""Single file download card."""
|
| 72 |
|
| 73 |
def __init__(self, master, file_info: dict, download_dir: str, status_cb):
|
| 74 |
-
super().__init__(master, fg_color=CARD_BG, corner_radius=10
|
|
|
|
| 75 |
|
| 76 |
self.file_info = file_info
|
| 77 |
self.download_dir = download_dir
|
| 78 |
self.status_cb = status_cb
|
| 79 |
self._thread = None
|
| 80 |
|
| 81 |
-
path
|
| 82 |
-
size
|
| 83 |
app_name = guess_app_name(path)
|
| 84 |
-
meta
|
| 85 |
plat, plat_color = guess_platform(path)
|
| 86 |
|
| 87 |
self.columnconfigure(1, weight=1)
|
| 88 |
|
| 89 |
# Icon
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
# App name
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
| 98 |
|
| 99 |
# Description + size
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
|
| 106 |
# Platform badge
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
# Filename label (small)
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
# Download button
|
| 118 |
self.btn = ctk.CTkButton(self, text="⬇ Download", width=130,
|
|
|
|
| 119 |
command=self._start_download)
|
| 120 |
self.btn.grid(row=0, column=3, rowspan=2, padx=16, pady=16)
|
| 121 |
|
| 122 |
# Progress bar (hidden initially)
|
| 123 |
-
self.pbar = ctk.CTkProgressBar(self, width=130
|
|
|
|
| 124 |
self.pbar.set(0)
|
| 125 |
|
| 126 |
# Percent label
|
| 127 |
self.pct_lbl = ctk.CTkLabel(self, text="", font=ctk.CTkFont(size=10),
|
| 128 |
-
text_color=
|
| 129 |
|
| 130 |
# ── download logic ────────────────────────────────────────────────────────
|
| 131 |
def _start_download(self):
|
|
@@ -143,7 +329,7 @@ class AppCard(ctk.CTkFrame):
|
|
| 143 |
total = self.file_info.get("size", 0)
|
| 144 |
url = f"{HF_CDN_BASE}/{urllib.parse.quote(path)}"
|
| 145 |
dest = os.path.join(self.download_dir, path)
|
| 146 |
-
chunk_size = 65536
|
| 147 |
|
| 148 |
try:
|
| 149 |
self.btn.configure(text="Connecting…")
|
|
@@ -163,23 +349,20 @@ class AppCard(ctk.CTkFrame):
|
|
| 163 |
text=f"{format_size(downloaded)} / {format_size(total)} ({pct*100:.0f}%)"
|
| 164 |
)
|
| 165 |
|
| 166 |
-
# ── Verify size ───────────────────────────────────────────────────
|
| 167 |
if total > 0 and downloaded != total:
|
| 168 |
raise IOError(
|
| 169 |
f"Incomplete download: got {format_size(downloaded)}, expected {format_size(total)}"
|
| 170 |
)
|
| 171 |
|
| 172 |
-
# ── Done ─────────────────────────────────────────────────────────
|
| 173 |
self.btn.configure(text="✓ Done", fg_color=SUCCESS, state="normal")
|
| 174 |
self.pbar.set(1)
|
| 175 |
self.pct_lbl.configure(text=f"Saved → {dest}")
|
| 176 |
self.status_cb(f"✓ Downloaded: {path}")
|
| 177 |
|
| 178 |
except Exception as exc:
|
| 179 |
-
self.btn.configure(text="⚠ Retry", state="normal", fg_color=
|
| 180 |
self.pct_lbl.configure(text=f"Error: {exc}")
|
| 181 |
self.status_cb(f"✗ Failed: {path} — {exc}")
|
| 182 |
-
# Remove incomplete file if it exists
|
| 183 |
if os.path.exists(dest):
|
| 184 |
try:
|
| 185 |
os.remove(dest)
|
|
@@ -193,10 +376,14 @@ class ChahuadevHub(ctk.CTk):
|
|
| 193 |
def __init__(self):
|
| 194 |
super().__init__()
|
| 195 |
self.title("Chahuadev Hub")
|
| 196 |
-
self.geometry("
|
| 197 |
-
self.minsize(
|
| 198 |
-
self.
|
| 199 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
self._build_layout()
|
| 202 |
threading.Thread(target=self._fetch_files, daemon=True).start()
|
|
@@ -208,104 +395,237 @@ class ChahuadevHub(ctk.CTk):
|
|
| 208 |
self.grid_columnconfigure(1, weight=1)
|
| 209 |
|
| 210 |
# ── Sidebar ──────────────────────────────────────────────────────────
|
| 211 |
-
self.sidebar = ctk.CTkFrame(self, width=
|
| 212 |
fg_color=SIDEBAR_BG)
|
| 213 |
self.sidebar.grid(row=0, column=0, rowspan=2, sticky="nsew")
|
| 214 |
self.sidebar.grid_propagate(False)
|
| 215 |
-
self.sidebar.grid_rowconfigure(
|
| 216 |
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
ctk.CTkLabel(self.sidebar, text="FILTER BY PLATFORM",
|
| 227 |
font=ctk.CTkFont(size=10, weight="bold"),
|
| 228 |
-
text_color=
|
| 229 |
|
| 230 |
self._filter_btns = {}
|
| 231 |
for i, (label, key) in enumerate([
|
| 232 |
(" All Files", "All"),
|
| 233 |
-
(" Windows", "Windows"),
|
| 234 |
-
(" Linux", "Linux"),
|
| 235 |
-
], start=
|
| 236 |
btn = ctk.CTkButton(
|
| 237 |
self.sidebar, text=label, anchor="w",
|
| 238 |
fg_color=ACCENT if key == "All" else "transparent",
|
| 239 |
-
hover_color=
|
| 240 |
-
command=lambda k=key: self._set_filter(k)
|
| 241 |
)
|
| 242 |
-
btn.grid(row=i, column=0, padx=12, pady=
|
| 243 |
self._filter_btns[key] = btn
|
| 244 |
|
| 245 |
-
#
|
| 246 |
ctk.CTkButton(
|
| 247 |
self.sidebar, text="📂 Open Downloads",
|
| 248 |
-
fg_color="transparent", hover_color=
|
| 249 |
command=self._open_download_dir,
|
| 250 |
-
).grid(row=
|
| 251 |
|
| 252 |
ctk.CTkButton(
|
| 253 |
self.sidebar, text="🔄 Refresh",
|
| 254 |
-
fg_color="transparent", hover_color=
|
| 255 |
command=self._refresh,
|
| 256 |
-
).grid(row=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
# ── Main area ────────────────────────────────────────────────────────
|
| 259 |
-
main = ctk.CTkFrame(self, fg_color=HEADER_BG, corner_radius=0)
|
| 260 |
-
main.grid(row=0, column=1, sticky="nsew")
|
| 261 |
-
main.grid_rowconfigure(
|
| 262 |
-
main.grid_columnconfigure(0, weight=1)
|
| 263 |
|
| 264 |
# Header bar
|
| 265 |
-
hdr = ctk.CTkFrame(main, fg_color=
|
| 266 |
hdr.grid(row=0, column=0, sticky="ew")
|
| 267 |
hdr.grid_columnconfigure(0, weight=1)
|
| 268 |
hdr.grid_propagate(False)
|
| 269 |
|
| 270 |
self.hdr_title = ctk.CTkLabel(
|
| 271 |
hdr, text="Available Downloads",
|
| 272 |
-
font=ctk.CTkFont(size=18, weight="bold"),
|
|
|
|
| 273 |
)
|
| 274 |
self.hdr_title.grid(row=0, column=0, padx=24, pady=18, sticky="w")
|
| 275 |
|
| 276 |
self.hdr_count = ctk.CTkLabel(
|
| 277 |
-
hdr, text="
|
| 278 |
-
text_color=
|
| 279 |
)
|
| 280 |
self.hdr_count.grid(row=0, column=1, padx=24, pady=18, sticky="e")
|
| 281 |
|
| 282 |
-
#
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
-
#
|
| 288 |
-
self.
|
| 289 |
-
self.
|
| 290 |
-
font=ctk.CTkFont(size=14), text_color="#6b7280"
|
| 291 |
)
|
| 292 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
self.statusbar = ctk.CTkLabel(
|
| 296 |
-
self, text=f"Download folder: {DOWNLOAD_DIR}",
|
| 297 |
-
font=ctk.CTkFont(size=10), text_color=
|
| 298 |
-
fg_color=
|
| 299 |
)
|
| 300 |
-
self.statusbar.grid(row=1, column=1, sticky="ew", padx=
|
| 301 |
|
| 302 |
-
# ──
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
def _fetch_files(self):
|
| 304 |
try:
|
| 305 |
resp = requests.get(HF_API_URL, timeout=15)
|
| 306 |
resp.raise_for_status()
|
| 307 |
files = resp.json()
|
| 308 |
-
# Keep only "blob" type (actual files) and skip metadata files
|
| 309 |
blobs = [f for f in files
|
| 310 |
if f.get("type") == "file" and f["path"] not in SKIP_FILES]
|
| 311 |
self.after(0, self._populate_cards, blobs)
|
|
@@ -313,8 +633,11 @@ class ChahuadevHub(ctk.CTk):
|
|
| 313 |
self.after(0, self._show_error, str(exc))
|
| 314 |
|
| 315 |
def _populate_cards(self, files: list):
|
| 316 |
-
self.
|
|
|
|
|
|
|
| 317 |
self._all_files = files
|
|
|
|
| 318 |
self._render_cards(files)
|
| 319 |
|
| 320 |
def _render_cards(self, files: list):
|
|
@@ -323,7 +646,7 @@ class ChahuadevHub(ctk.CTk):
|
|
| 323 |
self._cards.clear()
|
| 324 |
|
| 325 |
for i, f in enumerate(files):
|
| 326 |
-
card = AppCard(self.
|
| 327 |
card.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 328 |
self._cards.append(card)
|
| 329 |
|
|
@@ -332,28 +655,157 @@ class ChahuadevHub(ctk.CTk):
|
|
| 332 |
self._set_status(f"Loaded {count} files from huggingface.co/{HF_REPO}")
|
| 333 |
|
| 334 |
def _show_error(self, msg: str):
|
| 335 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
text=f"⚠ Failed to connect to Hugging Face\n{msg}",
|
| 337 |
-
text_color=
|
| 338 |
-
)
|
| 339 |
self._set_status(f"✗ Error: {msg}")
|
| 340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
# ── Filter ────────────────────────────────────────────────────────────────
|
| 342 |
def _set_filter(self, key: str):
|
| 343 |
self._filter = key
|
| 344 |
for k, btn in self._filter_btns.items():
|
| 345 |
btn.configure(fg_color=ACCENT if k == key else "transparent")
|
| 346 |
-
|
| 347 |
-
if not hasattr(self, "_all_files"):
|
| 348 |
return
|
| 349 |
-
|
| 350 |
if key == "All":
|
| 351 |
filtered = self._all_files
|
| 352 |
elif key == "Windows":
|
| 353 |
filtered = [f for f in self._all_files if ".exe" in f["path"].lower()]
|
| 354 |
-
else:
|
| 355 |
filtered = [f for f in self._all_files if ".appimage" in f["path"].lower()]
|
| 356 |
-
|
| 357 |
self._render_cards(filtered)
|
| 358 |
|
| 359 |
# ── Helpers ───────────────────────────────────────────────────────────────
|
|
@@ -362,22 +814,56 @@ class ChahuadevHub(ctk.CTk):
|
|
| 362 |
|
| 363 |
def _open_download_dir(self):
|
| 364 |
os.makedirs(DOWNLOAD_DIR, exist_ok=True)
|
| 365 |
-
os.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
|
| 367 |
def _refresh(self):
|
| 368 |
-
self._cards_clear()
|
| 369 |
-
self.loading_lbl = ctk.CTkLabel(
|
| 370 |
-
self.scroll, text="⏳ Refreshing…",
|
| 371 |
-
font=ctk.CTkFont(size=14), text_color="#6b7280"
|
| 372 |
-
)
|
| 373 |
-
self.loading_lbl.grid(row=0, column=0, pady=60)
|
| 374 |
-
self.hdr_count.configure(text="Loading…")
|
| 375 |
-
threading.Thread(target=self._fetch_files, daemon=True).start()
|
| 376 |
-
|
| 377 |
-
def _cards_clear(self):
|
| 378 |
for card in self._cards:
|
| 379 |
card.destroy()
|
| 380 |
self._cards.clear()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
|
| 382 |
|
| 383 |
# ════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 2 |
import threading
|
| 3 |
import urllib.parse
|
| 4 |
import requests
|
|
|
|
| 5 |
import os
|
| 6 |
+
import webbrowser
|
| 7 |
|
| 8 |
# ── CONFIG ──────────────────────────────────────────────────────────────────
|
| 9 |
+
HF_AUTHOR = "chahuadev"
|
| 10 |
+
HF_REPO = "chahuadev/chahuadev-framework-binaries"
|
| 11 |
+
HF_API_URL = f"https://huggingface.co/api/datasets/{HF_REPO}/tree/main"
|
| 12 |
+
HF_COMMITS_URL = f"https://huggingface.co/api/datasets/{HF_REPO}/commits/main"
|
| 13 |
+
HF_CDN_BASE = f"https://huggingface.co/datasets/{HF_REPO}/resolve/main"
|
| 14 |
+
DOWNLOAD_DIR = os.path.join(os.path.expanduser("~"), "Downloads", "ChahuadevHub")
|
| 15 |
+
|
| 16 |
+
# ── HF Explorer API ──────────────────────────────────────────────────────────
|
| 17 |
+
HF_DATASETS_API = f"https://huggingface.co/api/datasets?author={HF_AUTHOR}&full=true"
|
| 18 |
+
HF_MODELS_API = f"https://huggingface.co/api/models?author={HF_AUTHOR}&full=true"
|
| 19 |
+
HF_SPACES_API = f"https://huggingface.co/api/spaces?author={HF_AUTHOR}&full=true"
|
| 20 |
+
|
| 21 |
+
REPO_TYPE_META = {
|
| 22 |
+
"dataset": {"icon": "🗄️", "color": "#8b5cf6", "label": "Dataset"},
|
| 23 |
+
"model": {"icon": "🤖", "color": "#3b82f6", "label": "Model"},
|
| 24 |
+
"space": {"icon": "🚀", "color": "#10b981", "label": "Space"},
|
| 25 |
+
}
|
| 26 |
|
| 27 |
# ── SKIP non-app files ───────────────────────────────────────────────────────
|
| 28 |
SKIP_FILES = {".gitattributes", "README.md", "chahuadev-framework-binaries.png",
|
| 29 |
"emoji-cleaner-app.png"}
|
| 30 |
|
| 31 |
+
# ── APP METADATA ─────────────────────────────────────────────────────────────
|
| 32 |
APP_META = {
|
| 33 |
"Chahuadev Framework": {
|
| 34 |
"icon": "⚙️",
|
|
|
|
| 44 |
},
|
| 45 |
}
|
| 46 |
|
| 47 |
+
# ── ENTERPRISE PALETTE ────────────────────────────────────────────────────────
|
| 48 |
+
ctk.set_appearance_mode("dark")
|
| 49 |
+
ctk.set_default_color_theme("blue")
|
| 50 |
+
|
| 51 |
+
BG_BASE = "#09090f"
|
| 52 |
+
SIDEBAR_BG = "#0f172a" # slate-900
|
| 53 |
+
SURFACE = "#1e293b" # slate-800
|
| 54 |
+
CARD_BG = "#1e293b"
|
| 55 |
+
HEADER_BG = "#0f172a"
|
| 56 |
+
BORDER = "#334155" # slate-700
|
| 57 |
+
MUTED = "#64748b" # slate-500
|
| 58 |
+
TEXT = "#f1f5f9" # slate-100
|
| 59 |
+
TEXT_DIM = "#94a3b8" # slate-400
|
| 60 |
+
ACCENT = "#3b82f6" # blue-500
|
| 61 |
+
ACCENT_DARK = "#1d4ed8" # blue-700
|
| 62 |
+
SUCCESS = "#10b981"
|
| 63 |
+
DANGER = "#ef4444"
|
| 64 |
+
WIN_COLOR = "#3b82f6"
|
| 65 |
+
LINUX_COLOR = "#f59e0b" # amber-500
|
| 66 |
+
|
| 67 |
+
|
| 68 |
def format_size(n):
|
| 69 |
for unit in ("B", "KB", "MB", "GB"):
|
| 70 |
if n < 1024:
|
|
|
|
| 72 |
n /= 1024
|
| 73 |
return f"{n:.1f} TB"
|
| 74 |
|
| 75 |
+
|
| 76 |
def guess_app_name(path):
|
| 77 |
name = path.replace("-win-ia32.exe", "").replace("-win-x64.exe", "")
|
| 78 |
name = name.replace("-1.0.0.AppImage", "").replace(".AppImage", "").replace(".exe", "")
|
| 79 |
name = name.replace("-", " ").strip()
|
| 80 |
return name
|
| 81 |
|
| 82 |
+
|
| 83 |
def guess_platform(path):
|
| 84 |
p = path.lower()
|
| 85 |
if "ia32" in p:
|
| 86 |
+
return "Windows 32-bit", WIN_COLOR
|
| 87 |
if "x64" in p or ".exe" in p:
|
| 88 |
+
return "Windows 64-bit", WIN_COLOR
|
| 89 |
if ".appimage" in p:
|
| 90 |
+
return "Linux AppImage", LINUX_COLOR
|
| 91 |
+
return "Unknown", MUTED
|
| 92 |
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 95 |
+
class StatCard(ctk.CTkFrame):
|
| 96 |
+
"""Summary stat card shown at top of dashboard."""
|
| 97 |
+
|
| 98 |
+
def __init__(self, master, label: str, value: str, accent: str, icon: str):
|
| 99 |
+
super().__init__(master, fg_color=SURFACE, corner_radius=10,
|
| 100 |
+
border_width=1, border_color=BORDER)
|
| 101 |
+
self.columnconfigure(0, weight=1)
|
| 102 |
+
ctk.CTkLabel(self, text=icon, font=ctk.CTkFont(size=20)).grid(
|
| 103 |
+
row=0, column=0, padx=16, pady=(14, 2), sticky="w"
|
| 104 |
+
)
|
| 105 |
+
self._val_lbl = ctk.CTkLabel(
|
| 106 |
+
self, text=value,
|
| 107 |
+
font=ctk.CTkFont(size=28, weight="bold"),
|
| 108 |
+
text_color=accent, anchor="w"
|
| 109 |
+
)
|
| 110 |
+
self._val_lbl.grid(row=1, column=0, padx=16, pady=0, sticky="w")
|
| 111 |
+
ctk.CTkLabel(
|
| 112 |
+
self, text=label, font=ctk.CTkFont(size=11),
|
| 113 |
+
text_color=TEXT_DIM, anchor="w"
|
| 114 |
+
).grid(row=2, column=0, padx=16, pady=(0, 14), sticky="w")
|
| 115 |
+
|
| 116 |
+
def update_value(self, value: str):
|
| 117 |
+
self._val_lbl.configure(text=value)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 121 |
+
class SkeletonCard(ctk.CTkFrame):
|
| 122 |
+
"""Animated placeholder shown while file list is loading."""
|
| 123 |
+
|
| 124 |
+
def __init__(self, master):
|
| 125 |
+
super().__init__(master, fg_color=CARD_BG, corner_radius=10,
|
| 126 |
+
border_width=1, border_color=BORDER, height=80)
|
| 127 |
+
self.grid_propagate(False)
|
| 128 |
+
self.columnconfigure(1, weight=1)
|
| 129 |
+
self._step = 0
|
| 130 |
+
self._colors = [BORDER, SURFACE, BORDER]
|
| 131 |
+
|
| 132 |
+
self._icon = ctk.CTkFrame(self, width=36, height=36, corner_radius=18,
|
| 133 |
+
fg_color=BORDER)
|
| 134 |
+
self._icon.grid(row=0, column=0, rowspan=2, padx=16, pady=16)
|
| 135 |
+
self._icon.grid_propagate(False)
|
| 136 |
+
|
| 137 |
+
self._title = ctk.CTkFrame(self, height=14, corner_radius=4, fg_color=BORDER)
|
| 138 |
+
self._title.grid(row=0, column=1, padx=6, pady=(18, 4), sticky="ew")
|
| 139 |
+
self._title.grid_propagate(False)
|
| 140 |
+
|
| 141 |
+
self._sub = ctk.CTkFrame(self, height=10, corner_radius=4, fg_color=SURFACE)
|
| 142 |
+
self._sub.grid(row=1, column=1, padx=6, pady=(0, 18), sticky="ew")
|
| 143 |
+
self._sub.grid_propagate(False)
|
| 144 |
+
|
| 145 |
+
self.columnconfigure(2, weight=0, minsize=140)
|
| 146 |
+
self._btn_ph = ctk.CTkFrame(self, width=120, height=34, corner_radius=6,
|
| 147 |
+
fg_color=BORDER)
|
| 148 |
+
self._btn_ph.grid(row=0, column=3, rowspan=2, padx=16, pady=16)
|
| 149 |
+
self._btn_ph.grid_propagate(False)
|
| 150 |
+
|
| 151 |
+
self._animate()
|
| 152 |
+
|
| 153 |
+
def _animate(self):
|
| 154 |
+
if not self.winfo_exists():
|
| 155 |
+
return
|
| 156 |
+
self._step = (self._step + 1) % len(self._colors)
|
| 157 |
+
self._title.configure(fg_color=self._colors[self._step])
|
| 158 |
+
self._sub.configure(fg_color=self._colors[(self._step + 1) % len(self._colors)])
|
| 159 |
+
self.after(500, self._animate)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 163 |
+
class ChangelogEntry(ctk.CTkFrame):
|
| 164 |
+
"""One commit entry in the Changelog panel."""
|
| 165 |
+
|
| 166 |
+
def __init__(self, master, commit: dict):
|
| 167 |
+
super().__init__(master, fg_color=SURFACE, corner_radius=8,
|
| 168 |
+
border_width=1, border_color=BORDER)
|
| 169 |
+
self.columnconfigure(0, weight=1)
|
| 170 |
+
|
| 171 |
+
title = commit.get("title") or commit.get("message", "—")
|
| 172 |
+
sha = (commit.get("id") or "")[:7]
|
| 173 |
+
date = (commit.get("date") or "")[:10]
|
| 174 |
+
author = commit.get("authors") or [{}]
|
| 175 |
+
author_name = author[0].get("name", "—") if author else "—"
|
| 176 |
+
|
| 177 |
+
ctk.CTkLabel(self, text=title,
|
| 178 |
+
font=ctk.CTkFont(size=13, weight="bold"),
|
| 179 |
+
text_color=TEXT, anchor="w", wraplength=560).grid(
|
| 180 |
+
row=0, column=0, padx=14, pady=(12, 2), sticky="w"
|
| 181 |
+
)
|
| 182 |
+
ctk.CTkLabel(self, text=f"#{sha} · {author_name} · {date}",
|
| 183 |
+
font=ctk.CTkFont(size=10),
|
| 184 |
+
text_color=TEXT_DIM, anchor="w").grid(
|
| 185 |
+
row=1, column=0, padx=14, pady=(0, 12), sticky="w"
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
# ════════════════════════════════════════════════════════════════════════════
|
| 190 |
+
class RepoCard(ctk.CTkFrame):
|
| 191 |
+
"""Clickable repo card in Explorer panel."""
|
| 192 |
+
|
| 193 |
+
def __init__(self, master, repo: dict, repo_type: str, on_select):
|
| 194 |
+
meta = REPO_TYPE_META.get(repo_type, {"icon": "📦", "color": ACCENT, "label": repo_type})
|
| 195 |
+
self._repo = repo
|
| 196 |
+
self._repo_type = repo_type
|
| 197 |
+
self._on_select = on_select
|
| 198 |
+
super().__init__(master, fg_color=SURFACE, corner_radius=8,
|
| 199 |
+
border_width=1, border_color=BORDER, cursor="hand2")
|
| 200 |
+
self.columnconfigure(1, weight=1)
|
| 201 |
+
|
| 202 |
+
ctk.CTkLabel(self, text=meta["icon"], font=ctk.CTkFont(size=18)).grid(
|
| 203 |
+
row=0, column=0, rowspan=2, padx=(12, 6), pady=10
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
repo_id = repo.get("id") or repo.get("modelId", "")
|
| 207 |
+
short_id = repo_id.split("/")[-1] if "/" in repo_id else repo_id
|
| 208 |
+
last_mod = (repo.get("lastModified") or repo.get("updatedAt") or "")[:10]
|
| 209 |
+
downloads = repo.get("downloads") or repo.get("downloadsAllTime") or ""
|
| 210 |
+
private = "🔒" if repo.get("private") else ""
|
| 211 |
+
|
| 212 |
+
self._name_lbl = ctk.CTkLabel(
|
| 213 |
+
self, text=short_id,
|
| 214 |
+
font=ctk.CTkFont(size=12, weight="bold"),
|
| 215 |
+
text_color=TEXT, anchor="w"
|
| 216 |
+
)
|
| 217 |
+
self._name_lbl.grid(row=0, column=1, padx=4, pady=(10, 1), sticky="w")
|
| 218 |
+
|
| 219 |
+
info_parts = [meta["label"]]
|
| 220 |
+
if downloads:
|
| 221 |
+
info_parts.append(f"↓{downloads}")
|
| 222 |
+
if last_mod:
|
| 223 |
+
info_parts.append(last_mod)
|
| 224 |
+
if private:
|
| 225 |
+
info_parts.append(private)
|
| 226 |
+
ctk.CTkLabel(
|
| 227 |
+
self, text=" · ".join(info_parts),
|
| 228 |
+
font=ctk.CTkFont(size=10), text_color=TEXT_DIM, anchor="w"
|
| 229 |
+
).grid(row=1, column=1, padx=4, pady=(0, 10), sticky="w")
|
| 230 |
+
|
| 231 |
+
ctk.CTkLabel(
|
| 232 |
+
self, text=meta["label"],
|
| 233 |
+
fg_color=meta["color"], corner_radius=4,
|
| 234 |
+
font=ctk.CTkFont(size=9, weight="bold"), padx=6, pady=1,
|
| 235 |
+
text_color="white"
|
| 236 |
+
).grid(row=0, column=2, padx=8, pady=(10, 0), sticky="e")
|
| 237 |
+
|
| 238 |
+
for w in (self, self._name_lbl):
|
| 239 |
+
w.bind("<Button-1>", lambda e: self._on_select(self._repo, self._repo_type))
|
| 240 |
+
|
| 241 |
+
def set_active(self, active: bool):
|
| 242 |
+
self.configure(
|
| 243 |
+
fg_color="#1e3a5f" if active else SURFACE,
|
| 244 |
+
border_color=ACCENT if active else BORDER
|
| 245 |
+
)
|
| 246 |
|
| 247 |
|
| 248 |
# ════════════════════════════════════════════════════════════════════════════
|
|
|
|
| 250 |
"""Single file download card."""
|
| 251 |
|
| 252 |
def __init__(self, master, file_info: dict, download_dir: str, status_cb):
|
| 253 |
+
super().__init__(master, fg_color=CARD_BG, corner_radius=10,
|
| 254 |
+
border_width=1, border_color=BORDER)
|
| 255 |
|
| 256 |
self.file_info = file_info
|
| 257 |
self.download_dir = download_dir
|
| 258 |
self.status_cb = status_cb
|
| 259 |
self._thread = None
|
| 260 |
|
| 261 |
+
path = file_info["path"]
|
| 262 |
+
size = file_info.get("size", 0)
|
| 263 |
app_name = guess_app_name(path)
|
| 264 |
+
meta = APP_META.get(app_name, {"icon": "📦", "desc": path})
|
| 265 |
plat, plat_color = guess_platform(path)
|
| 266 |
|
| 267 |
self.columnconfigure(1, weight=1)
|
| 268 |
|
| 269 |
# Icon
|
| 270 |
+
ctk.CTkLabel(self, text=meta["icon"], font=ctk.CTkFont(size=32)).grid(
|
| 271 |
+
row=0, column=0, rowspan=2, padx=(16, 10), pady=16
|
| 272 |
+
)
|
| 273 |
|
| 274 |
# App name
|
| 275 |
+
ctk.CTkLabel(self, text=app_name,
|
| 276 |
+
font=ctk.CTkFont(size=15, weight="bold"),
|
| 277 |
+
text_color=TEXT, anchor="w").grid(
|
| 278 |
+
row=0, column=1, sticky="sw", padx=4, pady=(14, 0)
|
| 279 |
+
)
|
| 280 |
|
| 281 |
# Description + size
|
| 282 |
+
ctk.CTkLabel(self, text=f"{meta['desc']} • {format_size(size)}",
|
| 283 |
+
font=ctk.CTkFont(size=11),
|
| 284 |
+
text_color=TEXT_DIM, anchor="w").grid(
|
| 285 |
+
row=1, column=1, sticky="nw", padx=4, pady=(0, 14)
|
| 286 |
+
)
|
| 287 |
|
| 288 |
# Platform badge
|
| 289 |
+
ctk.CTkLabel(self, text=plat, fg_color=plat_color,
|
| 290 |
+
corner_radius=6, font=ctk.CTkFont(size=10, weight="bold"),
|
| 291 |
+
padx=8, pady=2).grid(
|
| 292 |
+
row=0, column=2, padx=8, pady=(14, 0), sticky="e"
|
| 293 |
+
)
|
| 294 |
|
| 295 |
# Filename label (small)
|
| 296 |
+
ctk.CTkLabel(self, text=path, font=ctk.CTkFont(size=10),
|
| 297 |
+
text_color=MUTED, anchor="e").grid(
|
| 298 |
+
row=1, column=2, padx=8, pady=(0, 14), sticky="e"
|
| 299 |
+
)
|
| 300 |
|
| 301 |
# Download button
|
| 302 |
self.btn = ctk.CTkButton(self, text="⬇ Download", width=130,
|
| 303 |
+
fg_color=ACCENT, hover_color=ACCENT_DARK,
|
| 304 |
command=self._start_download)
|
| 305 |
self.btn.grid(row=0, column=3, rowspan=2, padx=16, pady=16)
|
| 306 |
|
| 307 |
# Progress bar (hidden initially)
|
| 308 |
+
self.pbar = ctk.CTkProgressBar(self, width=130,
|
| 309 |
+
progress_color=ACCENT, fg_color=BORDER)
|
| 310 |
self.pbar.set(0)
|
| 311 |
|
| 312 |
# Percent label
|
| 313 |
self.pct_lbl = ctk.CTkLabel(self, text="", font=ctk.CTkFont(size=10),
|
| 314 |
+
text_color=TEXT_DIM)
|
| 315 |
|
| 316 |
# ── download logic ────────────────────────────────────────────────────────
|
| 317 |
def _start_download(self):
|
|
|
|
| 329 |
total = self.file_info.get("size", 0)
|
| 330 |
url = f"{HF_CDN_BASE}/{urllib.parse.quote(path)}"
|
| 331 |
dest = os.path.join(self.download_dir, path)
|
| 332 |
+
chunk_size = 65536
|
| 333 |
|
| 334 |
try:
|
| 335 |
self.btn.configure(text="Connecting…")
|
|
|
|
| 349 |
text=f"{format_size(downloaded)} / {format_size(total)} ({pct*100:.0f}%)"
|
| 350 |
)
|
| 351 |
|
|
|
|
| 352 |
if total > 0 and downloaded != total:
|
| 353 |
raise IOError(
|
| 354 |
f"Incomplete download: got {format_size(downloaded)}, expected {format_size(total)}"
|
| 355 |
)
|
| 356 |
|
|
|
|
| 357 |
self.btn.configure(text="✓ Done", fg_color=SUCCESS, state="normal")
|
| 358 |
self.pbar.set(1)
|
| 359 |
self.pct_lbl.configure(text=f"Saved → {dest}")
|
| 360 |
self.status_cb(f"✓ Downloaded: {path}")
|
| 361 |
|
| 362 |
except Exception as exc:
|
| 363 |
+
self.btn.configure(text="⚠ Retry", state="normal", fg_color=DANGER)
|
| 364 |
self.pct_lbl.configure(text=f"Error: {exc}")
|
| 365 |
self.status_cb(f"✗ Failed: {path} — {exc}")
|
|
|
|
| 366 |
if os.path.exists(dest):
|
| 367 |
try:
|
| 368 |
os.remove(dest)
|
|
|
|
| 376 |
def __init__(self):
|
| 377 |
super().__init__()
|
| 378 |
self.title("Chahuadev Hub")
|
| 379 |
+
self.geometry("1080x720")
|
| 380 |
+
self.minsize(900, 580)
|
| 381 |
+
self.configure(fg_color=BG_BASE)
|
| 382 |
+
self._filter = "All"
|
| 383 |
+
self._cards = []
|
| 384 |
+
self._all_files = []
|
| 385 |
+
self._skeletons = []
|
| 386 |
+
self._nav = "downloads"
|
| 387 |
|
| 388 |
self._build_layout()
|
| 389 |
threading.Thread(target=self._fetch_files, daemon=True).start()
|
|
|
|
| 395 |
self.grid_columnconfigure(1, weight=1)
|
| 396 |
|
| 397 |
# ── Sidebar ──────────────────────────────────────────────────────────
|
| 398 |
+
self.sidebar = ctk.CTkFrame(self, width=220, corner_radius=0,
|
| 399 |
fg_color=SIDEBAR_BG)
|
| 400 |
self.sidebar.grid(row=0, column=0, rowspan=2, sticky="nsew")
|
| 401 |
self.sidebar.grid_propagate(False)
|
| 402 |
+
self.sidebar.grid_rowconfigure(20, weight=1)
|
| 403 |
|
| 404 |
+
ctk.CTkLabel(self.sidebar, text="CHAHUADEV\nHUB",
|
| 405 |
+
font=ctk.CTkFont(size=22, weight="bold"),
|
| 406 |
+
text_color="#7c3aed").grid(
|
| 407 |
+
row=0, column=0, padx=20, pady=(28, 4)
|
| 408 |
+
)
|
| 409 |
+
ctk.CTkLabel(self.sidebar, text="Official App Distribution",
|
| 410 |
+
font=ctk.CTkFont(size=10), text_color=MUTED).grid(
|
| 411 |
+
row=1, column=0, padx=20, pady=(0, 24)
|
| 412 |
+
)
|
| 413 |
|
| 414 |
+
# ─ Navigation ─
|
| 415 |
+
ctk.CTkLabel(self.sidebar, text="NAVIGATE",
|
| 416 |
+
font=ctk.CTkFont(size=10, weight="bold"),
|
| 417 |
+
text_color=MUTED).grid(row=2, column=0, padx=20, sticky="w")
|
| 418 |
|
| 419 |
+
self._nav_btns = {}
|
| 420 |
+
for i, (label, key) in enumerate([
|
| 421 |
+
(" ⬇ Downloads", "downloads"),
|
| 422 |
+
(" � Explorer", "explorer"),
|
| 423 |
+
(" �📋 Changelog", "changelog"),
|
| 424 |
+
], start=3):
|
| 425 |
+
btn = ctk.CTkButton(
|
| 426 |
+
self.sidebar, text=label, anchor="w",
|
| 427 |
+
fg_color=ACCENT if key == "downloads" else "transparent",
|
| 428 |
+
hover_color=ACCENT_DARK,
|
| 429 |
+
command=lambda k=key: self._switch_nav(k)
|
| 430 |
+
)
|
| 431 |
+
btn.grid(row=i, column=0, padx=12, pady=3, sticky="ew")
|
| 432 |
+
self._nav_btns[key] = btn
|
| 433 |
+
|
| 434 |
+
# ─ Filter ─
|
| 435 |
ctk.CTkLabel(self.sidebar, text="FILTER BY PLATFORM",
|
| 436 |
font=ctk.CTkFont(size=10, weight="bold"),
|
| 437 |
+
text_color=MUTED).grid(row=6, column=0, padx=20, pady=(20, 4), sticky="w")
|
| 438 |
|
| 439 |
self._filter_btns = {}
|
| 440 |
for i, (label, key) in enumerate([
|
| 441 |
(" All Files", "All"),
|
| 442 |
+
(" 🪟 Windows", "Windows"),
|
| 443 |
+
(" 🐧 Linux", "Linux"),
|
| 444 |
+
], start=7):
|
| 445 |
btn = ctk.CTkButton(
|
| 446 |
self.sidebar, text=label, anchor="w",
|
| 447 |
fg_color=ACCENT if key == "All" else "transparent",
|
| 448 |
+
hover_color=ACCENT_DARK,
|
| 449 |
+
command=lambda k=key: self._set_filter(k)
|
| 450 |
)
|
| 451 |
+
btn.grid(row=i, column=0, padx=12, pady=3, sticky="ew")
|
| 452 |
self._filter_btns[key] = btn
|
| 453 |
|
| 454 |
+
# ─ Bottom actions ─
|
| 455 |
ctk.CTkButton(
|
| 456 |
self.sidebar, text="📂 Open Downloads",
|
| 457 |
+
fg_color="transparent", hover_color=SURFACE,
|
| 458 |
command=self._open_download_dir,
|
| 459 |
+
).grid(row=20, column=0, padx=12, pady=(0, 6), sticky="ew")
|
| 460 |
|
| 461 |
ctk.CTkButton(
|
| 462 |
self.sidebar, text="🔄 Refresh",
|
| 463 |
+
fg_color="transparent", hover_color=SURFACE,
|
| 464 |
command=self._refresh,
|
| 465 |
+
).grid(row=21, column=0, padx=12, pady=(0, 6), sticky="ew")
|
| 466 |
+
|
| 467 |
+
ctk.CTkButton(
|
| 468 |
+
self.sidebar, text="🔗 Hugging Face",
|
| 469 |
+
fg_color="transparent", hover_color=SURFACE,
|
| 470 |
+
command=lambda: webbrowser.open(f"https://huggingface.co/{HF_REPO}")
|
| 471 |
+
).grid(row=22, column=0, padx=12, pady=(0, 20), sticky="ew")
|
| 472 |
|
| 473 |
# ── Main area ────────────────────────────────────────────────────────
|
| 474 |
+
self.main = ctk.CTkFrame(self, fg_color=HEADER_BG, corner_radius=0)
|
| 475 |
+
self.main.grid(row=0, column=1, sticky="nsew")
|
| 476 |
+
self.main.grid_rowconfigure(2, weight=1)
|
| 477 |
+
self.main.grid_columnconfigure(0, weight=1)
|
| 478 |
|
| 479 |
# Header bar
|
| 480 |
+
hdr = ctk.CTkFrame(self.main, fg_color=BG_BASE, corner_radius=0, height=64)
|
| 481 |
hdr.grid(row=0, column=0, sticky="ew")
|
| 482 |
hdr.grid_columnconfigure(0, weight=1)
|
| 483 |
hdr.grid_propagate(False)
|
| 484 |
|
| 485 |
self.hdr_title = ctk.CTkLabel(
|
| 486 |
hdr, text="Available Downloads",
|
| 487 |
+
font=ctk.CTkFont(size=18, weight="bold"),
|
| 488 |
+
text_color=TEXT, anchor="w"
|
| 489 |
)
|
| 490 |
self.hdr_title.grid(row=0, column=0, padx=24, pady=18, sticky="w")
|
| 491 |
|
| 492 |
self.hdr_count = ctk.CTkLabel(
|
| 493 |
+
hdr, text="Fetching…",
|
| 494 |
+
font=ctk.CTkFont(size=12), text_color=MUTED, anchor="e"
|
| 495 |
)
|
| 496 |
self.hdr_count.grid(row=0, column=1, padx=24, pady=18, sticky="e")
|
| 497 |
|
| 498 |
+
# Stats cards row
|
| 499 |
+
stats_row = ctk.CTkFrame(self.main, fg_color=HEADER_BG, corner_radius=0, height=110)
|
| 500 |
+
stats_row.grid(row=1, column=0, sticky="ew", padx=20, pady=(10, 0))
|
| 501 |
+
stats_row.grid_columnconfigure((0, 1, 2), weight=1)
|
| 502 |
+
stats_row.grid_propagate(False)
|
| 503 |
+
|
| 504 |
+
self._stat_total = StatCard(stats_row, "Total Files", "—", ACCENT, "📦")
|
| 505 |
+
self._stat_win = StatCard(stats_row, "Windows Files", "—", WIN_COLOR, "🪟")
|
| 506 |
+
self._stat_linux = StatCard(stats_row, "Linux Files", "—", LINUX_COLOR,"🐧")
|
| 507 |
+
self._stat_total.grid(row=0, column=0, padx=(0, 8), pady=0, sticky="nsew")
|
| 508 |
+
self._stat_win.grid (row=0, column=1, padx=8, pady=0, sticky="nsew")
|
| 509 |
+
self._stat_linux.grid(row=0, column=2, padx=(8, 0), pady=0, sticky="nsew")
|
| 510 |
+
|
| 511 |
+
# Content frame (holds downloads & changelog panels)
|
| 512 |
+
self.content_frame = ctk.CTkFrame(self.main, fg_color=HEADER_BG, corner_radius=0)
|
| 513 |
+
self.content_frame.grid(row=2, column=0, sticky="nsew", padx=0, pady=(12, 0))
|
| 514 |
+
self.content_frame.grid_rowconfigure(0, weight=1)
|
| 515 |
+
self.content_frame.grid_columnconfigure(0, weight=1)
|
| 516 |
+
|
| 517 |
+
# Downloads panel
|
| 518 |
+
self.downloads_panel = ctk.CTkScrollableFrame(
|
| 519 |
+
self.content_frame, fg_color=HEADER_BG, corner_radius=0
|
| 520 |
+
)
|
| 521 |
+
self.downloads_panel.grid(row=0, column=0, sticky="nsew")
|
| 522 |
+
self.downloads_panel.grid_columnconfigure(0, weight=1)
|
| 523 |
+
|
| 524 |
+
for i in range(4):
|
| 525 |
+
sk = SkeletonCard(self.downloads_panel)
|
| 526 |
+
sk.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 527 |
+
self._skeletons.append(sk)
|
| 528 |
+
|
| 529 |
+
# ── Explorer panel (hidden initially) ────────────────────────────────
|
| 530 |
+
self.explorer_panel = ctk.CTkFrame(
|
| 531 |
+
self.content_frame, fg_color=HEADER_BG, corner_radius=0
|
| 532 |
+
)
|
| 533 |
+
self.explorer_panel.grid(row=0, column=0, sticky="nsew")
|
| 534 |
+
self.explorer_panel.grid_rowconfigure(0, weight=1)
|
| 535 |
+
self.explorer_panel.grid_columnconfigure(0, weight=0, minsize=280)
|
| 536 |
+
self.explorer_panel.grid_columnconfigure(1, weight=1)
|
| 537 |
+
self.explorer_panel.grid_remove()
|
| 538 |
+
|
| 539 |
+
# Left: repo list
|
| 540 |
+
self._repo_list_frame = ctk.CTkScrollableFrame(
|
| 541 |
+
self.explorer_panel, fg_color=SURFACE, corner_radius=0, width=260
|
| 542 |
+
)
|
| 543 |
+
self._repo_list_frame.grid(row=0, column=0, sticky="nsew", padx=(0, 1))
|
| 544 |
+
self._repo_list_frame.grid_columnconfigure(0, weight=1)
|
| 545 |
+
|
| 546 |
+
self._repo_loading_lbl = ctk.CTkLabel(
|
| 547 |
+
self._repo_list_frame, text="⏳ Fetching repos…",
|
| 548 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 549 |
+
)
|
| 550 |
+
self._repo_loading_lbl.grid(row=0, column=0, pady=40)
|
| 551 |
|
| 552 |
+
# Right: commit detail
|
| 553 |
+
self._commit_frame = ctk.CTkFrame(
|
| 554 |
+
self.explorer_panel, fg_color=HEADER_BG, corner_radius=0
|
|
|
|
| 555 |
)
|
| 556 |
+
self._commit_frame.grid(row=0, column=1, sticky="nsew")
|
| 557 |
+
self._commit_frame.grid_rowconfigure(1, weight=1)
|
| 558 |
+
self._commit_frame.grid_columnconfigure(0, weight=1)
|
| 559 |
+
|
| 560 |
+
self._commit_hdr = ctk.CTkLabel(
|
| 561 |
+
self._commit_frame,
|
| 562 |
+
text="← Select a repo to view commits",
|
| 563 |
+
font=ctk.CTkFont(size=13), text_color=MUTED, anchor="w"
|
| 564 |
+
)
|
| 565 |
+
self._commit_hdr.grid(row=0, column=0, padx=20, pady=14, sticky="w")
|
| 566 |
|
| 567 |
+
self._commit_scroll = ctk.CTkScrollableFrame(
|
| 568 |
+
self._commit_frame, fg_color=HEADER_BG, corner_radius=0
|
| 569 |
+
)
|
| 570 |
+
self._commit_scroll.grid(row=1, column=0, sticky="nsew")
|
| 571 |
+
self._commit_scroll.grid_columnconfigure(0, weight=1)
|
| 572 |
+
|
| 573 |
+
self._repo_cards: list = []
|
| 574 |
+
self._active_repo_card = None
|
| 575 |
+
|
| 576 |
+
# Changelog panel (hidden initially)
|
| 577 |
+
self.changelog_panel = ctk.CTkScrollableFrame(
|
| 578 |
+
self.content_frame, fg_color=HEADER_BG, corner_radius=0
|
| 579 |
+
)
|
| 580 |
+
self.changelog_panel.grid(row=0, column=0, sticky="nsew")
|
| 581 |
+
self.changelog_panel.grid_columnconfigure(0, weight=1)
|
| 582 |
+
self.changelog_panel.grid_remove()
|
| 583 |
+
|
| 584 |
+
self._changelog_lbl = ctk.CTkLabel(
|
| 585 |
+
self.changelog_panel, text="⏳ Loading commit history…",
|
| 586 |
+
font=ctk.CTkFont(size=14), text_color=MUTED
|
| 587 |
+
)
|
| 588 |
+
self._changelog_lbl.grid(row=0, column=0, pady=60)
|
| 589 |
+
|
| 590 |
+
# Status bar
|
| 591 |
self.statusbar = ctk.CTkLabel(
|
| 592 |
+
self, text=f" Download folder: {DOWNLOAD_DIR}",
|
| 593 |
+
font=ctk.CTkFont(size=10), text_color=MUTED,
|
| 594 |
+
fg_color=BG_BASE, anchor="w", corner_radius=0
|
| 595 |
)
|
| 596 |
+
self.statusbar.grid(row=1, column=1, sticky="ew", padx=0, pady=0)
|
| 597 |
|
| 598 |
+
# ── Navigation ───────────────────────────────────────────────────────────
|
| 599 |
+
def _switch_nav(self, key: str):
|
| 600 |
+
self._nav = key
|
| 601 |
+
for k, btn in self._nav_btns.items():
|
| 602 |
+
btn.configure(fg_color=ACCENT if k == key else "transparent")
|
| 603 |
+
|
| 604 |
+
self.downloads_panel.grid_remove()
|
| 605 |
+
self.explorer_panel.grid_remove()
|
| 606 |
+
self.changelog_panel.grid_remove()
|
| 607 |
+
|
| 608 |
+
if key == "downloads":
|
| 609 |
+
self.hdr_title.configure(text="Available Downloads")
|
| 610 |
+
self.downloads_panel.grid()
|
| 611 |
+
elif key == "explorer":
|
| 612 |
+
self.hdr_title.configure(text="🔍 Repo Explorer — huggingface.co/chahuadev")
|
| 613 |
+
self.hdr_count.configure(text="")
|
| 614 |
+
self.explorer_panel.grid()
|
| 615 |
+
if not hasattr(self, "_explorer_loaded"):
|
| 616 |
+
threading.Thread(target=self._fetch_all_repos, daemon=True).start()
|
| 617 |
+
else:
|
| 618 |
+
self.hdr_title.configure(text="Changelog — Commit History")
|
| 619 |
+
self.changelog_panel.grid()
|
| 620 |
+
if not hasattr(self, "_changelog_loaded"):
|
| 621 |
+
threading.Thread(target=self._fetch_changelog, daemon=True).start()
|
| 622 |
+
|
| 623 |
+
# ── API fetch — files ─────────────────────────────────────────────────────
|
| 624 |
def _fetch_files(self):
|
| 625 |
try:
|
| 626 |
resp = requests.get(HF_API_URL, timeout=15)
|
| 627 |
resp.raise_for_status()
|
| 628 |
files = resp.json()
|
|
|
|
| 629 |
blobs = [f for f in files
|
| 630 |
if f.get("type") == "file" and f["path"] not in SKIP_FILES]
|
| 631 |
self.after(0, self._populate_cards, blobs)
|
|
|
|
| 633 |
self.after(0, self._show_error, str(exc))
|
| 634 |
|
| 635 |
def _populate_cards(self, files: list):
|
| 636 |
+
for sk in self._skeletons:
|
| 637 |
+
sk.destroy()
|
| 638 |
+
self._skeletons.clear()
|
| 639 |
self._all_files = files
|
| 640 |
+
self._update_stats(files)
|
| 641 |
self._render_cards(files)
|
| 642 |
|
| 643 |
def _render_cards(self, files: list):
|
|
|
|
| 646 |
self._cards.clear()
|
| 647 |
|
| 648 |
for i, f in enumerate(files):
|
| 649 |
+
card = AppCard(self.downloads_panel, f, DOWNLOAD_DIR, self._set_status)
|
| 650 |
card.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 651 |
self._cards.append(card)
|
| 652 |
|
|
|
|
| 655 |
self._set_status(f"Loaded {count} files from huggingface.co/{HF_REPO}")
|
| 656 |
|
| 657 |
def _show_error(self, msg: str):
|
| 658 |
+
for sk in self._skeletons:
|
| 659 |
+
sk.destroy()
|
| 660 |
+
self._skeletons.clear()
|
| 661 |
+
ctk.CTkLabel(
|
| 662 |
+
self.downloads_panel,
|
| 663 |
text=f"⚠ Failed to connect to Hugging Face\n{msg}",
|
| 664 |
+
font=ctk.CTkFont(size=14), text_color=DANGER
|
| 665 |
+
).grid(row=0, column=0, pady=60)
|
| 666 |
self._set_status(f"✗ Error: {msg}")
|
| 667 |
|
| 668 |
+
def _update_stats(self, files: list):
|
| 669 |
+
total = len(files)
|
| 670 |
+
wins = sum(1 for f in files if ".exe" in f["path"].lower())
|
| 671 |
+
lins = sum(1 for f in files if ".appimage" in f["path"].lower())
|
| 672 |
+
self._stat_total.update_value(str(total))
|
| 673 |
+
self._stat_win.update_value(str(wins))
|
| 674 |
+
self._stat_linux.update_value(str(lins))
|
| 675 |
+
|
| 676 |
+
# ── API fetch — ALL repos (Explorer) ─────────────────────────────────────
|
| 677 |
+
def _fetch_all_repos(self):
|
| 678 |
+
results = []
|
| 679 |
+
for url, rtype in [
|
| 680 |
+
(HF_DATASETS_API, "dataset"),
|
| 681 |
+
(HF_MODELS_API, "model"),
|
| 682 |
+
(HF_SPACES_API, "space"),
|
| 683 |
+
]:
|
| 684 |
+
try:
|
| 685 |
+
resp = requests.get(url, timeout=15)
|
| 686 |
+
resp.raise_for_status()
|
| 687 |
+
for r in resp.json():
|
| 688 |
+
results.append((r, rtype))
|
| 689 |
+
except Exception:
|
| 690 |
+
pass
|
| 691 |
+
results.sort(
|
| 692 |
+
key=lambda x: x[0].get("lastModified") or x[0].get("updatedAt") or "",
|
| 693 |
+
reverse=True
|
| 694 |
+
)
|
| 695 |
+
self.after(0, self._populate_repos, results)
|
| 696 |
+
|
| 697 |
+
def _populate_repos(self, results: list):
|
| 698 |
+
self._explorer_loaded = True
|
| 699 |
+
if hasattr(self, "_repo_loading_lbl") and self._repo_loading_lbl.winfo_exists():
|
| 700 |
+
self._repo_loading_lbl.destroy()
|
| 701 |
+
|
| 702 |
+
total = len(results)
|
| 703 |
+
types: dict = {}
|
| 704 |
+
for _, t in results:
|
| 705 |
+
types[t] = types.get(t, 0) + 1
|
| 706 |
+
parts = [f"{total} repos"]
|
| 707 |
+
for t in ("dataset", "model", "space"):
|
| 708 |
+
if types.get(t):
|
| 709 |
+
m = REPO_TYPE_META[t]
|
| 710 |
+
parts.append(f"{m['icon']} {types[t]} {m['label']}s")
|
| 711 |
+
self.hdr_count.configure(text=" · ".join(parts))
|
| 712 |
+
self._set_status(f"Loaded {total} repos from huggingface.co/{HF_AUTHOR}")
|
| 713 |
+
|
| 714 |
+
for i, (repo, rtype) in enumerate(results):
|
| 715 |
+
card = RepoCard(self._repo_list_frame, repo, rtype, self._on_repo_select)
|
| 716 |
+
card.grid(row=i, column=0, padx=8, pady=4, sticky="ew")
|
| 717 |
+
self._repo_cards.append(card)
|
| 718 |
+
|
| 719 |
+
def _on_repo_select(self, repo: dict, repo_type: str):
|
| 720 |
+
repo_id = repo.get("id") or repo.get("modelId", "")
|
| 721 |
+
for card in self._repo_cards:
|
| 722 |
+
cid = card._repo.get("id") or card._repo.get("modelId", "")
|
| 723 |
+
card.set_active(cid == repo_id)
|
| 724 |
+
|
| 725 |
+
for w in self._commit_scroll.winfo_children():
|
| 726 |
+
w.destroy()
|
| 727 |
+
self._commit_hdr.configure(text=f"📋 Commits — {repo_id}", text_color=TEXT)
|
| 728 |
+
|
| 729 |
+
lbl = ctk.CTkLabel(
|
| 730 |
+
self._commit_scroll, text="⏳ Loading commits…",
|
| 731 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 732 |
+
)
|
| 733 |
+
lbl.grid(row=0, column=0, pady=40)
|
| 734 |
+
threading.Thread(
|
| 735 |
+
target=self._fetch_repo_commits,
|
| 736 |
+
args=(repo_id, repo_type),
|
| 737 |
+
daemon=True
|
| 738 |
+
).start()
|
| 739 |
+
|
| 740 |
+
def _fetch_repo_commits(self, repo_id: str, repo_type: str):
|
| 741 |
+
url = f"https://huggingface.co/api/{repo_type}s/{repo_id}/commits/main"
|
| 742 |
+
try:
|
| 743 |
+
resp = requests.get(url, timeout=15)
|
| 744 |
+
resp.raise_for_status()
|
| 745 |
+
commits = resp.json()
|
| 746 |
+
self.after(0, self._show_repo_commits, commits, repo_id)
|
| 747 |
+
except Exception as exc:
|
| 748 |
+
self.after(0, self._show_repo_commits_error, str(exc))
|
| 749 |
+
|
| 750 |
+
def _show_repo_commits(self, commits: list, repo_id: str):
|
| 751 |
+
for w in self._commit_scroll.winfo_children():
|
| 752 |
+
w.destroy()
|
| 753 |
+
if not commits:
|
| 754 |
+
ctk.CTkLabel(
|
| 755 |
+
self._commit_scroll, text="No commits found",
|
| 756 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 757 |
+
).grid(row=0, column=0, pady=40)
|
| 758 |
+
return
|
| 759 |
+
for i, commit in enumerate(commits):
|
| 760 |
+
entry = ChangelogEntry(self._commit_scroll, commit)
|
| 761 |
+
entry.grid(row=i, column=0, padx=12, pady=5, sticky="ew")
|
| 762 |
+
self._commit_scroll.grid_columnconfigure(0, weight=1)
|
| 763 |
+
self._set_status(f"{len(commits)} commits — {repo_id}")
|
| 764 |
+
|
| 765 |
+
def _show_repo_commits_error(self, msg: str):
|
| 766 |
+
for w in self._commit_scroll.winfo_children():
|
| 767 |
+
w.destroy()
|
| 768 |
+
ctk.CTkLabel(
|
| 769 |
+
self._commit_scroll, text=f"⚠ {msg}",
|
| 770 |
+
font=ctk.CTkFont(size=13), text_color=DANGER
|
| 771 |
+
).grid(row=0, column=0, pady=40)
|
| 772 |
+
|
| 773 |
+
# ── API fetch — changelog ─────────────────────────────────────────────────
|
| 774 |
+
def _fetch_changelog(self):
|
| 775 |
+
try:
|
| 776 |
+
resp = requests.get(HF_COMMITS_URL, timeout=15)
|
| 777 |
+
resp.raise_for_status()
|
| 778 |
+
commits = resp.json()
|
| 779 |
+
self.after(0, self._populate_changelog, commits)
|
| 780 |
+
except Exception as exc:
|
| 781 |
+
self.after(0, self._changelog_error, str(exc))
|
| 782 |
+
|
| 783 |
+
def _populate_changelog(self, commits: list):
|
| 784 |
+
self._changelog_loaded = True
|
| 785 |
+
self._changelog_lbl.destroy()
|
| 786 |
+
for i, commit in enumerate(commits):
|
| 787 |
+
entry = ChangelogEntry(self.changelog_panel, commit)
|
| 788 |
+
entry.grid(row=i, column=0, padx=20, pady=6, sticky="ew")
|
| 789 |
+
self._set_status(f"Loaded {len(commits)} commits from Hugging Face")
|
| 790 |
+
|
| 791 |
+
def _changelog_error(self, msg: str):
|
| 792 |
+
self._changelog_lbl.configure(
|
| 793 |
+
text=f"⚠ Failed to load changelog\n{msg}", text_color=DANGER
|
| 794 |
+
)
|
| 795 |
+
|
| 796 |
# ── Filter ────────────────────────────────────────────────────────────────
|
| 797 |
def _set_filter(self, key: str):
|
| 798 |
self._filter = key
|
| 799 |
for k, btn in self._filter_btns.items():
|
| 800 |
btn.configure(fg_color=ACCENT if k == key else "transparent")
|
| 801 |
+
if not self._all_files:
|
|
|
|
| 802 |
return
|
|
|
|
| 803 |
if key == "All":
|
| 804 |
filtered = self._all_files
|
| 805 |
elif key == "Windows":
|
| 806 |
filtered = [f for f in self._all_files if ".exe" in f["path"].lower()]
|
| 807 |
+
else:
|
| 808 |
filtered = [f for f in self._all_files if ".appimage" in f["path"].lower()]
|
|
|
|
| 809 |
self._render_cards(filtered)
|
| 810 |
|
| 811 |
# ── Helpers ───────────────────────────────────────────────────────────────
|
|
|
|
| 814 |
|
| 815 |
def _open_download_dir(self):
|
| 816 |
os.makedirs(DOWNLOAD_DIR, exist_ok=True)
|
| 817 |
+
if os.name == "nt":
|
| 818 |
+
os.startfile(DOWNLOAD_DIR)
|
| 819 |
+
else:
|
| 820 |
+
import subprocess
|
| 821 |
+
subprocess.Popen(["xdg-open", DOWNLOAD_DIR])
|
| 822 |
|
| 823 |
def _refresh(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 824 |
for card in self._cards:
|
| 825 |
card.destroy()
|
| 826 |
self._cards.clear()
|
| 827 |
+
self._all_files = []
|
| 828 |
+
self._stat_total.update_value("—")
|
| 829 |
+
self._stat_win.update_value("—")
|
| 830 |
+
self._stat_linux.update_value("—")
|
| 831 |
+
self.hdr_count.configure(text="Fetching…")
|
| 832 |
+
|
| 833 |
+
for i in range(4):
|
| 834 |
+
sk = SkeletonCard(self.downloads_panel)
|
| 835 |
+
sk.grid(row=i, column=0, padx=20, pady=8, sticky="ew")
|
| 836 |
+
self._skeletons.append(sk)
|
| 837 |
+
|
| 838 |
+
if hasattr(self, "_changelog_loaded"):
|
| 839 |
+
del self._changelog_loaded
|
| 840 |
+
for w in self.changelog_panel.winfo_children():
|
| 841 |
+
w.destroy()
|
| 842 |
+
self._changelog_lbl = ctk.CTkLabel(
|
| 843 |
+
self.changelog_panel, text="⏳ Loading commit history…",
|
| 844 |
+
font=ctk.CTkFont(size=14), text_color=MUTED
|
| 845 |
+
)
|
| 846 |
+
self._changelog_lbl.grid(row=0, column=0, pady=60)
|
| 847 |
+
|
| 848 |
+
# Reset explorer
|
| 849 |
+
if hasattr(self, "_explorer_loaded"):
|
| 850 |
+
del self._explorer_loaded
|
| 851 |
+
for card in self._repo_cards:
|
| 852 |
+
card.destroy()
|
| 853 |
+
self._repo_cards.clear()
|
| 854 |
+
self._active_repo_card = None
|
| 855 |
+
for w in self._commit_scroll.winfo_children():
|
| 856 |
+
w.destroy()
|
| 857 |
+
self._commit_hdr.configure(
|
| 858 |
+
text="← Select a repo to view commits", text_color=MUTED
|
| 859 |
+
)
|
| 860 |
+
self._repo_loading_lbl = ctk.CTkLabel(
|
| 861 |
+
self._repo_list_frame, text="⏳ Fetching repos…",
|
| 862 |
+
font=ctk.CTkFont(size=13), text_color=MUTED
|
| 863 |
+
)
|
| 864 |
+
self._repo_loading_lbl.grid(row=0, column=0, pady=40)
|
| 865 |
+
|
| 866 |
+
threading.Thread(target=self._fetch_files, daemon=True).start()
|
| 867 |
|
| 868 |
|
| 869 |
# ════════════════════════════════════════════════════════════════════════════
|
packages/@chahuadev/chahuadev-hub-app/README.md
CHANGED
|
@@ -54,11 +54,41 @@ sudo npm install -g @chahuadev/chahuadev-hub-app --foreground-scripts --force
|
|
| 54 |
```bash
|
| 55 |
chahuadev-hub
|
| 56 |
```
|
|
|
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
---
|
| 59 |
|
| 60 |
## �️ Troubleshooting
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
### ENOTEMPTY error on Linux (directory not empty)
|
| 63 |
|
| 64 |
If you see `ENOTEMPTY` during install, a previous failed install left files behind. Clear them first:
|
|
@@ -83,6 +113,28 @@ source ~/.bashrc
|
|
| 83 |
chahuadev-hub
|
| 84 |
```
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
---
|
| 87 |
|
| 88 |
## �🚀 What It Does
|
|
|
|
| 54 |
```bash
|
| 55 |
chahuadev-hub
|
| 56 |
```
|
| 57 |
+
> **Note:** Downloaded apps will be automatically saved to your `Downloads/ChahuadevHub` folder.
|
| 58 |
|
| 59 |
+
> **If the command fails, go into the bin folder and run it directly:**
|
| 60 |
+
>
|
| 61 |
+
> ```bash
|
| 62 |
+
> cd ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app/bin
|
| 63 |
+
> ./chahuadev_hub
|
| 64 |
+
> ```
|
| 65 |
+
>
|
| 66 |
+
> If you installed with `sudo`, the folder may be under `/usr/local/lib/` instead:
|
| 67 |
+
> ```bash
|
| 68 |
+
> cd /usr/local/lib/node_modules/@chahuadev/chahuadev-hub-app/bin
|
| 69 |
+
> ./chahuadev_hub
|
| 70 |
+
> ```
|
| 71 |
---
|
| 72 |
|
| 73 |
## �️ Troubleshooting
|
| 74 |
|
| 75 |
+
### `node\r: No such file or directory` error (Linux)
|
| 76 |
+
|
| 77 |
+
This means the installed `index.js` has Windows line endings (CRLF). Fixed in v1.0.4+.
|
| 78 |
+
If you're on an older version, reinstall:
|
| 79 |
+
|
| 80 |
+
```bash
|
| 81 |
+
rm -rf ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app
|
| 82 |
+
npm install -g @chahuadev/chahuadev-hub-app --foreground-scripts --force
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
Or run the binary directly without going through the Node wrapper:
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
cd ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app/bin
|
| 89 |
+
./chahuadev_hub
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
### ENOTEMPTY error on Linux (directory not empty)
|
| 93 |
|
| 94 |
If you see `ENOTEMPTY` during install, a previous failed install left files behind. Clear them first:
|
|
|
|
| 113 |
chahuadev-hub
|
| 114 |
```
|
| 115 |
|
| 116 |
+
### `ModuleNotFoundError: No module named 'tkinter'` (Linux)
|
| 117 |
+
|
| 118 |
+
The Linux binary requires `tkinter` to be present at build time. If you see this error, the downloaded binary was built on a system without `tkinter` installed. You need to build from source:
|
| 119 |
+
|
| 120 |
+
```bash
|
| 121 |
+
# 1. Install tkinter
|
| 122 |
+
sudo apt-get install python3-tk python3-dev -y
|
| 123 |
+
|
| 124 |
+
# 2. Install Python dependencies
|
| 125 |
+
pip3 install customtkinter requests pyinstaller
|
| 126 |
+
|
| 127 |
+
# 3. Go into the project folder
|
| 128 |
+
cd /path/to/Chahuadev-Hub-Python
|
| 129 |
+
|
| 130 |
+
# 4. Build the binary
|
| 131 |
+
python3 -m PyInstaller --onefile chahuadev_hub.py
|
| 132 |
+
|
| 133 |
+
# 5. Run it
|
| 134 |
+
cd dist
|
| 135 |
+
./chahuadev_hub
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
---
|
| 139 |
|
| 140 |
## �🚀 What It Does
|
packages/@chahuadev/chahuadev-hub-app/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@chahuadev/chahuadev-hub-app",
|
| 3 |
-
"version": "1.0.
|
| 4 |
"description": "Chahuadev Hub — Official app launcher and distribution hub by Chahuadev",
|
| 5 |
"main": "index.js",
|
| 6 |
"bin": {
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@chahuadev/chahuadev-hub-app",
|
| 3 |
+
"version": "1.0.6",
|
| 4 |
"description": "Chahuadev Hub — Official app launcher and distribution hub by Chahuadev",
|
| 5 |
"main": "index.js",
|
| 6 |
"bin": {
|