Update athan applet to v1.0.2 (flicker-free live mode, table padding box) and rebuild registry index
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "athan",
|
"id": "athan",
|
||||||
"name": "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.",
|
"description": "Location-aware prayer schedule engine with countdown, timeline charts, and live interactive alarm.",
|
||||||
"author": "Hamza Tariq <hamza@luxhebros.com>",
|
"author": "Hamza Tariq <hamza@luxhebros.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ def run_cli(args: Optional[List[str]] = None) -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
if "-V" in raw_args or "--version" in raw_args:
|
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
|
return 0
|
||||||
|
|
||||||
cfg_mgr = AthanConfigManager()
|
cfg_mgr = AthanConfigManager()
|
||||||
@@ -146,7 +146,8 @@ def run_cli(args: Optional[List[str]] = None) -> int:
|
|||||||
# Command: live / monitor
|
# Command: live / monitor
|
||||||
elif command in ["live", "monitor"]:
|
elif command in ["live", "monitor"]:
|
||||||
try:
|
try:
|
||||||
sys.stdout.write("\033[?25l") # Hide cursor
|
# Clear screen once and hide cursor
|
||||||
|
sys.stdout.write("\033[?25l\033[2J")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
alarm_triggered = False
|
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()
|
current_p, next_p, sec_rem = timings.get_current_and_next()
|
||||||
dash = AthanRenderer.render_live_monitor(timings)
|
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()
|
sys.stdout.flush()
|
||||||
|
|
||||||
# Check if countdown hit 0
|
# Check if countdown hit 0
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
from typing import Dict, List, Optional
|
||||||
from src.api import PrayerTimings
|
from src.api import PrayerTimings
|
||||||
from src.catalog import catalog
|
from src.catalog import catalog
|
||||||
|
|
||||||
|
|
||||||
class AthanRenderer:
|
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
|
@staticmethod
|
||||||
def format_countdown(seconds: int) -> str:
|
def format_countdown(seconds: int) -> str:
|
||||||
@@ -13,17 +16,40 @@ class AthanRenderer:
|
|||||||
secs = seconds % 60
|
secs = seconds % 60
|
||||||
return f"{hours:02d}h {mins:02d}m {secs:02d}s"
|
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
|
@classmethod
|
||||||
def render_table(cls, timings: PrayerTimings) -> str:
|
def render_table(cls, timings: PrayerTimings) -> str:
|
||||||
current_p, next_p, sec_rem = timings.get_current_and_next()
|
current_p, next_p, sec_rem = timings.get_current_and_next()
|
||||||
title = catalog.format("table.title", city=timings.city, country=timings.country)
|
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 = [
|
lines = [
|
||||||
"┌─ " + title + " " + "─" * max(0, 56 - len(title)) + "┐",
|
top_border,
|
||||||
"│" + f" {timings.date_gregorian} | {timings.date_hijri}".ljust(60) + "│",
|
cls._pad_line(date_line),
|
||||||
"├" + "─" * 60 + "┤",
|
mid_border,
|
||||||
f"│ {'Prayer':<20} {'Time':<15} {'Status':<20} │",
|
cls._pad_line(header_row),
|
||||||
"├" + "─" * 60 + "┤",
|
mid_border,
|
||||||
]
|
]
|
||||||
|
|
||||||
order = ["Fajr", "Sunrise", "Dhuhr", "Asr", "Maghrib", "Isha"]
|
order = ["Fajr", "Sunrise", "Dhuhr", "Asr", "Maghrib", "Isha"]
|
||||||
@@ -38,44 +64,62 @@ class AthanRenderer:
|
|||||||
else:
|
else:
|
||||||
status_str = ""
|
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)
|
return "\n".join(lines)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def render_timeline_chart(cls, timings: PrayerTimings) -> str:
|
def render_timeline_chart(cls, timings: PrayerTimings) -> str:
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
cur_min = now.hour * 60 + now.minute
|
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)
|
title = f"24-HOUR PRAYER TIMELINE ({timings.city})"
|
||||||
chart_len = 48
|
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
|
bar = ["─"] * chart_len
|
||||||
|
|
||||||
# Place prayer marks
|
# Place prayer marks
|
||||||
order = ["Fajr", "Sunrise", "Dhuhr", "Asr", "Maghrib", "Isha"]
|
order = ["Fajr", "Sunrise", "Dhuhr", "Asr", "Maghrib", "Isha"]
|
||||||
marks: Dict[int, str] = {}
|
|
||||||
for p in order:
|
for p in order:
|
||||||
m = timings.get_minutes(timings.timings[p])
|
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] = "◆"
|
bar[idx] = "◆"
|
||||||
|
|
||||||
# Place current time mark
|
# 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[cur_idx] = "█"
|
||||||
|
|
||||||
bar_str = "".join(bar)
|
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 = [
|
lines = [
|
||||||
f"┌─ 24-HOUR PRAYER TIMELINE ({timings.city}) ───────────────────────┐",
|
top_border,
|
||||||
"│ │",
|
cls._pad_line(""),
|
||||||
"│ 00:00 06:00 12:00 18:00 24:00 │",
|
cls._pad_line(f" {time_labels}"),
|
||||||
f"│ {bar_str} │",
|
cls._pad_line(f" {bar_str}"),
|
||||||
"│ │",
|
cls._pad_line(""),
|
||||||
f"│ [█] Current Time: {now.strftime('%H:%M:%S')} (Active: {catalog.get(f'prayers.{current_p}', current_p)})".ljust(61) + "│",
|
cls._pad_line(cur_time_info),
|
||||||
f"│ [◆] Next Prayer : {catalog.get(f'prayers.{next_p}', next_p)} at {timings.timings[next_p]} ({cls.format_countdown(sec_rem)})".ljust(61) + "│",
|
cls._pad_line(next_time_info),
|
||||||
"└────────────────────────────────────────────────────────────┘",
|
cls._pad_line(""),
|
||||||
|
bottom_border,
|
||||||
]
|
]
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
@@ -84,18 +128,33 @@ class AthanRenderer:
|
|||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
current_p, next_p, sec_rem = timings.get_current_and_next(now)
|
current_p, next_p, sec_rem = timings.get_current_and_next(now)
|
||||||
countdown_str = cls.format_countdown(sec_rem)
|
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 = [
|
lines = [
|
||||||
"┌─ ATHAN LIVE PRAYER MONITOR & ALARM ──────────────────────── [LIVE] ─┐",
|
top_border,
|
||||||
f"│ Location: {timings.city}, {timings.country} | Current Time: {now.strftime('%H:%M:%S')}".ljust(70) + "│",
|
cls._pad_line(header_info),
|
||||||
"├" + "─" * 70 + "┤",
|
mid_border,
|
||||||
"│ │",
|
cls._pad_line(""),
|
||||||
f"│ NEXT PRAYER : {catalog.get(f'prayers.{next_p}', next_p).upper():<25} AT {timings.timings[next_p]} │",
|
cls._pad_line(next_info),
|
||||||
f"│ COUNTDOWN : {countdown_str:<40} │",
|
cls._pad_line(count_info),
|
||||||
"│ │",
|
cls._pad_line(""),
|
||||||
"├" + "─" * 70 + "┤",
|
mid_border,
|
||||||
f"│ Fajr: {timings.timings['Fajr']} | Dhuhr: {timings.timings['Dhuhr']} | Asr: {timings.timings['Asr']} | Maghrib: {timings.timings['Maghrib']} | Isha: {timings.timings['Isha']} │",
|
cls._pad_line(summary_info),
|
||||||
"│ │",
|
cls._pad_line(""),
|
||||||
f"└─────────────────────────────────── [ Press 'q' or ESC to Exit ] ─────┘",
|
bottom_hint,
|
||||||
]
|
]
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"schema_version": "1.0.0",
|
"schema_version": "1.0.0",
|
||||||
"updated_at": "2026-10-03T03:39:30.108591+00:00",
|
"updated_at": "2026-10-03T03:49:30.659752+00:00",
|
||||||
"total_applets": 6,
|
"total_applets": 6,
|
||||||
"applets": {
|
"applets": {
|
||||||
"lex": {
|
"lex": {
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
"athan": {
|
"athan": {
|
||||||
"id": "athan",
|
"id": "athan",
|
||||||
"name": "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.",
|
"description": "Location-aware prayer schedule engine with countdown, timeline charts, and live interactive alarm.",
|
||||||
"author": "Hamza Tariq <hamza@luxhebros.com>",
|
"author": "Hamza Tariq <hamza@luxhebros.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
Reference in New Issue
Block a user