Update athan applet to v1.0.2 (flicker-free live mode, table padding box) and rebuild registry index

This commit is contained in:
Gravitiny Team
2026-10-03 06:49:37 +03:00
parent 2959d29cf8
commit 33ccaf31be
4 changed files with 100 additions and 39 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "athan",
"name": "Athan",
"version": "1.0.1",
"version": "1.0.2",
"description": "Location-aware prayer schedule engine with countdown, timeline charts, and live interactive alarm.",
"author": "Hamza Tariq <hamza@luxhebros.com>",
"license": "MIT",
+5 -3
View File
@@ -84,7 +84,7 @@ def run_cli(args: Optional[List[str]] = None) -> int:
return 0
if "-V" in raw_args or "--version" in raw_args:
print(catalog.format("app.version_output", name="Athan", version="1.0.0", author="Hamza Tariq"))
print(catalog.format("app.version_output", name="Athan", version="1.0.2", author="Hamza Tariq"))
return 0
cfg_mgr = AthanConfigManager()
@@ -146,7 +146,8 @@ def run_cli(args: Optional[List[str]] = None) -> int:
# Command: live / monitor
elif command in ["live", "monitor"]:
try:
sys.stdout.write("\033[?25l") # Hide cursor
# Clear screen once and hide cursor
sys.stdout.write("\033[?25l\033[2J")
sys.stdout.flush()
alarm_triggered = False
@@ -155,7 +156,8 @@ def run_cli(args: Optional[List[str]] = None) -> int:
current_p, next_p, sec_rem = timings.get_current_and_next()
dash = AthanRenderer.render_live_monitor(timings)
sys.stdout.write(f"\033[H\033[2J{dash}\n")
# Overwrite in-place at top-left without clearing screen
sys.stdout.write(f"\033[H{dash}\n")
sys.stdout.flush()
# Check if countdown hit 0
+92 -33
View File
@@ -1,10 +1,13 @@
import datetime
from typing import Dict, List, Optional
from src.api import PrayerTimings
from src.catalog import catalog
class AthanRenderer:
"""Renders formatted prayer tables, 24-hour ASCII timeline charts, and live countdown dashboards."""
"""Renders pixel-perfect, aesthetic ASCII prayer tables, timeline graphs, and live monitors."""
BOX_WIDTH = 70
@staticmethod
def format_countdown(seconds: int) -> str:
@@ -13,17 +16,40 @@ class AthanRenderer:
secs = seconds % 60
return f"{hours:02d}h {mins:02d}m {secs:02d}s"
@classmethod
def _pad_line(cls, content: str, width: int = BOX_WIDTH) -> str:
"""Pads a line so that left and right borders are always perfectly aligned."""
inner_space = width - 4
if len(content) > inner_space:
content = content[:inner_space - 3] + "..."
padding = " " * (inner_space - len(content))
return f"│ {content}{padding} │"
@classmethod
def render_table(cls, timings: PrayerTimings) -> str:
current_p, next_p, sec_rem = timings.get_current_and_next()
title = catalog.format("table.title", city=timings.city, country=timings.country)
# Header border calculation
top_dashes = max(0, cls.BOX_WIDTH - len(title) - 5)
top_border = f"┌─ {title} {'─' * top_dashes}┐"
if len(top_border) > cls.BOX_WIDTH:
top_border = top_border[:cls.BOX_WIDTH - 1] + "┐"
elif len(top_border) < cls.BOX_WIDTH:
top_border = top_border[:-1] + ("─" * (cls.BOX_WIDTH - len(top_border))) + "┐"
mid_border = "├" + ("─" * (cls.BOX_WIDTH - 2)) + "┤"
bottom_border = "└" + ("─" * (cls.BOX_WIDTH - 2)) + "┘"
date_line = f"{timings.date_gregorian} | {timings.date_hijri}"
header_row = f"{'Prayer':<22} {'Time':<10} {'Status':<30}"
lines = [
"┌─ " + title + " " + "─" * max(0, 56 - len(title)) + "┐",
"│" + f" {timings.date_gregorian} | {timings.date_hijri}".ljust(60) + "│",
"├" + "─" * 60 + "┤",
f"│ {'Prayer':<20} {'Time':<15} {'Status':<20} │",
"├" + "─" * 60 + "┤",
top_border,
cls._pad_line(date_line),
mid_border,
cls._pad_line(header_row),
mid_border,
]
order = ["Fajr", "Sunrise", "Dhuhr", "Asr", "Maghrib", "Isha"]
@@ -38,44 +64,62 @@ class AthanRenderer:
else:
status_str = ""
lines.append(f"│ {p_label:<20} {time_val:<15} {status_str:<20} │")
row_text = f"{p_label:<22} {time_val:<10} {status_str:<30}"
lines.append(cls._pad_line(row_text))
lines.append("└" + "─" * 60 + "┘")
lines.append(bottom_border)
return "\n".join(lines)
@classmethod
def render_timeline_chart(cls, timings: PrayerTimings) -> str:
now = datetime.datetime.now()
cur_min = now.hour * 60 + now.minute
current_p, next_p, sec_rem = timings.get_current_and_next()
current_p, next_p, sec_rem = timings.get_current_and_next(now)
# 24 hour bar mapping: 24h = 48 chars (1 char = 30 minutes)
chart_len = 48
title = f"24-HOUR PRAYER TIMELINE ({timings.city})"
top_dashes = max(0, cls.BOX_WIDTH - len(title) - 5)
top_border = f"┌─ {title} {'─' * top_dashes}┐"
if len(top_border) > cls.BOX_WIDTH:
top_border = top_border[:cls.BOX_WIDTH - 1] + "┐"
elif len(top_border) < cls.BOX_WIDTH:
top_border = top_border[:-1] + ("─" * (cls.BOX_WIDTH - len(top_border))) + "┐"
bottom_border = "└" + ("─" * (cls.BOX_WIDTH - 2)) + "┘"
# 24-hour bar: 52 characters (1 char = ~27.7 minutes)
chart_len = 54
bar = ["─"] * chart_len
# Place prayer marks
order = ["Fajr", "Sunrise", "Dhuhr", "Asr", "Maghrib", "Isha"]
marks: Dict[int, str] = {}
for p in order:
m = timings.get_minutes(timings.timings[p])
idx = min(chart_len - 1, m // 30)
idx = min(chart_len - 1, int((m / (24 * 60)) * chart_len))
bar[idx] = "◆"
# Place current time mark
cur_idx = min(chart_len - 1, cur_min // 30)
cur_idx = min(chart_len - 1, int((cur_min / (24 * 60)) * chart_len))
bar[cur_idx] = "█"
bar_str = "".join(bar)
time_labels = "00:00 06:00 12:00 18:00 24:00"
cur_label = catalog.get(f"prayers.{current_p}", current_p)
next_label = catalog.get(f"prayers.{next_p}", next_p)
cur_time_info = f"[█] Current Time : {now.strftime('%H:%M:%S')} (Active: {cur_label})"
next_time_info = f"[◆] Next Prayer : {next_label} at {timings.timings[next_p]} ({cls.format_countdown(sec_rem)})"
lines = [
f"┌─ 24-HOUR PRAYER TIMELINE ({timings.city}) ───────────────────────┐",
"│ │",
"│ 00:00 06:00 12:00 18:00 24:00 │",
f"│ {bar_str} │",
"│ │",
f"│ [█] Current Time: {now.strftime('%H:%M:%S')} (Active: {catalog.get(f'prayers.{current_p}', current_p)})".ljust(61) + "│",
f"│ [◆] Next Prayer : {catalog.get(f'prayers.{next_p}', next_p)} at {timings.timings[next_p]} ({cls.format_countdown(sec_rem)})".ljust(61) + "│",
"└────────────────────────────────────────────────────────────┘",
top_border,
cls._pad_line(""),
cls._pad_line(f" {time_labels}"),
cls._pad_line(f" {bar_str}"),
cls._pad_line(""),
cls._pad_line(cur_time_info),
cls._pad_line(next_time_info),
cls._pad_line(""),
bottom_border,
]
return "\n".join(lines)
@@ -84,18 +128,33 @@ class AthanRenderer:
now = datetime.datetime.now()
current_p, next_p, sec_rem = timings.get_current_and_next(now)
countdown_str = cls.format_countdown(sec_rem)
next_label = catalog.get(f"prayers.{next_p}", next_p).upper()
top_border = "┌─ ATHAN LIVE PRAYER MONITOR & ALARM ──────────────────────── [LIVE] ─┐"
if len(top_border) < cls.BOX_WIDTH:
top_border = top_border[:-1] + ("─" * (cls.BOX_WIDTH - len(top_border))) + "┐"
mid_border = "├" + ("─" * (cls.BOX_WIDTH - 2)) + "┤"
bottom_hint = f"└─────────────────────────────────── [ Press 'q' or ESC to Exit ] ───┘"
if len(bottom_hint) < cls.BOX_WIDTH:
bottom_hint = bottom_hint[:-1] + ("─" * (cls.BOX_WIDTH - len(bottom_hint))) + "┘"
header_info = f"Location: {timings.city}, {timings.country} | Time: {now.strftime('%H:%M:%S')}"
next_info = f" NEXT PRAYER : {next_label:<25} AT {timings.timings[next_p]}"
count_info = f" COUNTDOWN : {countdown_str:<40}"
summary_info = f"Fajr: {timings.timings['Fajr']} | Dhuhr: {timings.timings['Dhuhr']} | Asr: {timings.timings['Asr']} | Maghrib: {timings.timings['Maghrib']} | Isha: {timings.timings['Isha']}"
lines = [
"┌─ ATHAN LIVE PRAYER MONITOR & ALARM ──────────────────────── [LIVE] ─┐",
f"│ Location: {timings.city}, {timings.country} | Current Time: {now.strftime('%H:%M:%S')}".ljust(70) + "│",
"├" + "─" * 70 + "┤",
"│ │",
f"│ NEXT PRAYER : {catalog.get(f'prayers.{next_p}', next_p).upper():<25} AT {timings.timings[next_p]} │",
f"│ COUNTDOWN : {countdown_str:<40} │",
"│ │",
"├" + "─" * 70 + "┤",
f"│ Fajr: {timings.timings['Fajr']} | Dhuhr: {timings.timings['Dhuhr']} | Asr: {timings.timings['Asr']} | Maghrib: {timings.timings['Maghrib']} | Isha: {timings.timings['Isha']} │",
"│ │",
f"└─────────────────────────────────── [ Press 'q' or ESC to Exit ] ─────┘",
top_border,
cls._pad_line(header_info),
mid_border,
cls._pad_line(""),
cls._pad_line(next_info),
cls._pad_line(count_info),
cls._pad_line(""),
mid_border,
cls._pad_line(summary_info),
cls._pad_line(""),
bottom_hint,
]
return "\n".join(lines)