added calendars for kisfenyo
This commit is contained in:
@@ -1100,15 +1100,17 @@ data:
|
||||
@APP.get("/calendar/events")
|
||||
def calendar_events_api(
|
||||
count: int = Query(default=5, ge=1, le=50, description="Number of events to return"),
|
||||
days: int = Query(default=30, ge=1, le=365, description="Days to look ahead")
|
||||
days: int = Query(default=30, ge=1, le=365, description="Days to look ahead"),
|
||||
calendars: str = Query(default="", description="Comma-separated list of calendar names to include (empty = all)")
|
||||
):
|
||||
"""
|
||||
Returns upcoming calendar events from configured iCal feeds.
|
||||
Merges multiple calendars and sorts by start time.
|
||||
Use 'calendars' parameter to filter specific calendars (e.g., calendars=Családi,Órák)
|
||||
"""
|
||||
calendars = _parse_ical_urls()
|
||||
all_calendars = _parse_ical_urls()
|
||||
|
||||
if not calendars:
|
||||
if not all_calendars:
|
||||
return Response(
|
||||
content=json.dumps({
|
||||
"error": "No calendars configured",
|
||||
@@ -1119,10 +1121,17 @@ data:
|
||||
media_type="application/json; charset=utf-8"
|
||||
)
|
||||
|
||||
# Filter calendars if specified
|
||||
if calendars.strip():
|
||||
requested = [c.strip() for c in calendars.split(",") if c.strip()]
|
||||
filtered_calendars = {k: v for k, v in all_calendars.items() if k in requested}
|
||||
else:
|
||||
filtered_calendars = all_calendars
|
||||
|
||||
all_events = []
|
||||
calendar_status = {}
|
||||
|
||||
for name, url in calendars.items():
|
||||
for name, url in filtered_calendars.items():
|
||||
ical_text = _fetch_ical(url)
|
||||
if ical_text:
|
||||
events = _parse_ical_events(ical_text, name, days)
|
||||
|
||||
@@ -850,6 +850,110 @@ data:
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
# Calendar Events Widget (Családi only)
|
||||
- type: custom-api
|
||||
title: Family Calendar
|
||||
cache: 5m
|
||||
url: http://glance-helper.glance-system.svc.cluster.local:8000/calendar/events
|
||||
parameters:
|
||||
count: 10
|
||||
days: 14
|
||||
calendars: Családi
|
||||
template: |
|
||||
{{ $events := .JSON.Array "events" }}
|
||||
{{ $count := len $events }}
|
||||
{{ $showCount := 5 }}
|
||||
{{ $hasMore := gt $count $showCount }}
|
||||
|
||||
<style>
|
||||
.cal-widget { display: flex; flex-direction: column; gap: 6px; }
|
||||
.cal-meta { opacity: .65; font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
|
||||
.cal-empty { opacity: 0.5; font-size: 13px; padding: 8px 0; }
|
||||
.cal-list { display: flex; flex-direction: column; gap: 4px; }
|
||||
.cal-item {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 8px;
|
||||
background: rgba(255,255,255,0.04);
|
||||
align-items: start;
|
||||
}
|
||||
.cal-item:hover { background: rgba(255,255,255,0.08); }
|
||||
.cal-title {
|
||||
font-weight: 600;
|
||||
opacity: 0.95;
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.cal-time {
|
||||
font-size: 12px;
|
||||
opacity: 0.7;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.cal-date { font-weight: 600; }
|
||||
.cal-hour { opacity: 0.8; }
|
||||
.cal-allday {
|
||||
font-size: 10px;
|
||||
opacity: 0.6;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
/* Collapse/expand styling */
|
||||
.cal-hidden { display: none; }
|
||||
.cal-toggle {
|
||||
font-size: 12px;
|
||||
opacity: 0.6;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.cal-toggle:hover { opacity: 0.9; background: rgba(255,255,255,0.05); }
|
||||
#cal-expand-fam:checked ~ .cal-list .cal-extra { display: grid; }
|
||||
#cal-expand-fam:checked ~ .cal-toggle-more { display: none; }
|
||||
#cal-expand-fam:not(:checked) ~ .cal-toggle-less { display: none; }
|
||||
</style>
|
||||
|
||||
<div class="cal-widget">
|
||||
{{ if lt $count 1 }}
|
||||
<div class="cal-empty">No events in near future</div>
|
||||
{{ else }}
|
||||
{{ if $hasMore }}<input type="checkbox" id="cal-expand-fam" style="display:none;">{{ end }}
|
||||
<div class="cal-list">
|
||||
{{ range $i, $e := $events }}
|
||||
{{ $isExtra := ge $i $showCount }}
|
||||
{{ $isAllDay := $e.Bool "is_all_day" }}
|
||||
{{ $title := $e.String "title" }}
|
||||
{{ $startDate := $e.String "start_date" }}
|
||||
{{ $startTime := $e.String "start_time" }}
|
||||
|
||||
<div class="cal-item{{ if $isExtra }} cal-extra cal-hidden{{ end }}">
|
||||
<div>
|
||||
<div class="cal-title">{{ $title }}</div>
|
||||
</div>
|
||||
<div class="cal-time">
|
||||
<div class="cal-date">{{ $startDate }}</div>
|
||||
{{ if $isAllDay }}
|
||||
<div class="cal-allday">Whole day</div>
|
||||
{{ else }}
|
||||
<div class="cal-hour">{{ $startTime }}</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ if $hasMore }}
|
||||
<label class="cal-toggle cal-toggle-more" for="cal-expand-fam">Show more ({{ sub $count $showCount }} more) ▼</label>
|
||||
<label class="cal-toggle cal-toggle-less" for="cal-expand-fam">Show less ▲</label>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
- type: bookmarks
|
||||
title: Productivity Self-Hosted
|
||||
groups:
|
||||
|
||||
Reference in New Issue
Block a user