Integrazione Liturgia: accordioni, navigazione date, proxy CORS, alto contrasto e piano AI
This commit is contained in:
@@ -27,6 +27,10 @@ const routes: Routes = [
|
||||
path: 'propose-canto',
|
||||
loadComponent: () => import('./pages/propose-canto/propose-canto.page').then( m => m.ProposeCantoPage)
|
||||
},
|
||||
{
|
||||
path: 'liturgia',
|
||||
loadChildren: () => import('./pages/liturgia/liturgia.module').then( m => m.LiturgiaPageModule)
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { LiturgiaPage } from './liturgia.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: '',
|
||||
component: LiturgiaPage
|
||||
}
|
||||
])
|
||||
],
|
||||
declarations: [LiturgiaPage]
|
||||
})
|
||||
export class LiturgiaPageModule {}
|
||||
@@ -0,0 +1,71 @@
|
||||
<ion-header [translucent]="true" class="ion-no-border">
|
||||
<ion-toolbar class="bg-gradient">
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button defaultHref="/settings" color="secondary"></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title class="outfit-font">Liturgia del Giorno</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content [fullscreen]="true" class="bg-gradient">
|
||||
<div class="liturgia-container ion-padding">
|
||||
|
||||
<div class="date-header-wrapper ion-margin-bottom">
|
||||
<div class="date-header glass">
|
||||
<div class="date-navigation">
|
||||
<ion-button fill="clear" color="secondary" (click)="liturgyService.prevDay()">
|
||||
<ion-icon name="chevron-back-outline"></ion-icon>
|
||||
</ion-button>
|
||||
<h2 class="outfit-font">{{ getTodayString() }}</h2>
|
||||
<ion-button fill="clear" color="secondary" (click)="liturgyService.nextDay()">
|
||||
<ion-icon name="chevron-forward-outline"></ion-icon>
|
||||
</ion-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="liturgyService.loading()" class="ion-text-center ion-padding">
|
||||
<ion-spinner name="crescent" color="secondary"></ion-spinner>
|
||||
<p class="outfit-font">Caricamento letture...</p>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!liturgyService.loading() && liturgyService.readings() as r" class="readings-content">
|
||||
|
||||
<ion-accordion-group class="glass-accordion ion-margin-bottom">
|
||||
|
||||
<!-- Prima Lettura -->
|
||||
<ion-accordion value="prima" *ngIf="r.primaLettura">
|
||||
<ion-item slot="header" class="transparent-item">
|
||||
<ion-label class="outfit-font reading-title">Prima Lettura</ion-label>
|
||||
</ion-item>
|
||||
<div class="reading-text ion-padding" slot="content" [innerHTML]="r.primaLettura"></div>
|
||||
</ion-accordion>
|
||||
|
||||
<!-- Seconda Lettura -->
|
||||
<ion-accordion value="seconda" *ngIf="r.secondaLettura">
|
||||
<ion-item slot="header" class="transparent-item">
|
||||
<ion-label class="outfit-font reading-title">Seconda Lettura</ion-label>
|
||||
</ion-item>
|
||||
<div class="reading-text ion-padding" slot="content" [innerHTML]="r.secondaLettura"></div>
|
||||
</ion-accordion>
|
||||
|
||||
<!-- Vangelo -->
|
||||
<ion-accordion value="vangelo" *ngIf="r.vangelo">
|
||||
<ion-item slot="header" class="transparent-item">
|
||||
<ion-label class="outfit-font reading-title">Vangelo</ion-label>
|
||||
</ion-item>
|
||||
<div class="reading-text ion-padding" slot="content" [innerHTML]="r.vangelo"></div>
|
||||
</ion-accordion>
|
||||
|
||||
</ion-accordion-group>
|
||||
|
||||
<!-- Le sezioni dei suggerimenti sono state rimosse temporaneamente in attesa dell'implementazione AI lato server -->
|
||||
</div>
|
||||
|
||||
<div *ngIf="!liturgyService.loading() && !liturgyService.readings()" class="ion-text-center ion-padding glass">
|
||||
<p class="outfit-font">Non è stato possibile caricare le letture per oggi.</p>
|
||||
<ion-button fill="clear" color="secondary" (click)="liturgyService.fetchTodayLiturgy()">Riprova</ion-button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</ion-content>
|
||||
@@ -0,0 +1,144 @@
|
||||
.bg-gradient {
|
||||
--background: transparent;
|
||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
||||
}
|
||||
|
||||
.liturgia-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.glass {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 16px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.date-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
.date-navigation {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
color: var(--ion-color-secondary);
|
||||
text-transform: capitalize;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.keywords-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.moment-group {
|
||||
.moment-header {
|
||||
margin-bottom: 8px;
|
||||
ion-badge {
|
||||
font-size: 0.9rem;
|
||||
padding: 6px 12px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.glass-accordion {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 16px;
|
||||
overflow: hidden;
|
||||
|
||||
ion-accordion {
|
||||
--background: transparent;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.reading-title {
|
||||
color: var(--ion-color-secondary);
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.reading-text {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
line-height: 1.6;
|
||||
font-size: 1rem;
|
||||
white-space: pre-wrap;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
|
||||
::ng-deep br {
|
||||
display: block;
|
||||
content: "";
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-title {
|
||||
color: #fff;
|
||||
font-size: 1.2rem;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.song-card {
|
||||
padding: 0;
|
||||
transition: transform 0.2s ease;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.song-title {
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.song-author {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
|
||||
.transparent-item {
|
||||
--background: transparent;
|
||||
--color: #fff;
|
||||
--padding-start: 16px;
|
||||
--padding-end: 16px;
|
||||
}
|
||||
|
||||
/* Alto Contrasto per Liturgia */
|
||||
:host-context(body.high-contrast) {
|
||||
.glass-accordion {
|
||||
// Mantengo il look glass per gli header come richiesto
|
||||
|
||||
ion-accordion {
|
||||
.reading-text {
|
||||
color: #000 !important; // Testo nero
|
||||
background: #fff !important; // Sfondo bianco solido per massimo contrasto
|
||||
padding: 20px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Component, OnInit, inject, signal } from '@angular/core';
|
||||
import { LiturgyService } from '../../services/liturgy.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { Canto } from '../../services/canti.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-liturgia',
|
||||
templateUrl: './liturgia.page.html',
|
||||
styleUrls: ['./liturgia.page.scss'],
|
||||
standalone: false
|
||||
})
|
||||
export class LiturgiaPage implements OnInit {
|
||||
public liturgyService = inject(LiturgyService);
|
||||
private router = inject(Router);
|
||||
|
||||
ngOnInit() {
|
||||
this.liturgyService.fetchTodayLiturgy();
|
||||
}
|
||||
|
||||
suggest() {
|
||||
this.liturgyService.suggestSongs();
|
||||
}
|
||||
|
||||
onDateChange(event: any) {
|
||||
const newDate = event.detail.value.split('T')[0];
|
||||
this.liturgyService.fetchTodayLiturgy(newDate);
|
||||
}
|
||||
|
||||
openSong(song: Canto) {
|
||||
this.router.navigate(['/player'], { queryParams: { id: song.id } });
|
||||
}
|
||||
|
||||
getTodayString(): string {
|
||||
const date = new Date(this.liturgyService.selectedDate());
|
||||
return date.toLocaleDateString('it-IT', {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric'
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,14 @@
|
||||
<h2 class="settings-item-title">Editor e Canti Personali</h2>
|
||||
<p class="settings-item-subtitle">Abilita aggiunta e gestione "Miei"</p>
|
||||
</ion-label>
|
||||
<ion-toggle slot="end" [checked]="settingsService.showEditor()" (ionChange)="settingsService.toggleEditor()" color="secondary"></ion-toggle>
|
||||
<ion-toggle slot="end" [checked]="settingsService.showEditor()" (ionChange)="settingsService.toggleEditor()" color="secondary" [disabled]="true"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item class="transparent-item" lines="none" routerLink="/liturgia" detail="true" button>
|
||||
<ion-icon name="book-outline" slot="start" color="secondary"></ion-icon>
|
||||
<ion-label class="outfit-font">
|
||||
<h2 class="settings-item-title">Liturgia del Giorno</h2>
|
||||
<p class="settings-item-subtitle">Letture e suggerimenti canti</p>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
import { Injectable, inject, signal } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { CantiService, Canto } from './canti.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
export interface LiturgyReadings {
|
||||
date: string;
|
||||
primaLettura?: string;
|
||||
salmo?: string;
|
||||
secondaLettura?: string;
|
||||
vangelo?: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LiturgyService {
|
||||
private http = inject(HttpClient);
|
||||
private cantiService = inject(CantiService);
|
||||
|
||||
public readings = signal<LiturgyReadings | null>(null);
|
||||
public suggestions = signal<Canto[]>([]);
|
||||
public loading = signal<boolean>(false);
|
||||
|
||||
public selectedDate = signal<string>(this.getNextSunday());
|
||||
public keywords = signal<string[]>([]);
|
||||
public groupedSuggestions = signal<{moment: string, canti: Canto[]}[]>([]);
|
||||
|
||||
private PROXY_URL = 'https://corsproxy.io/?';
|
||||
private RSS_URL = 'https://liturgia.silvestrini.org/rss';
|
||||
|
||||
private getNextSunday(): string {
|
||||
const d = new Date();
|
||||
d.setDate(d.getDate() + (7 - d.getDay()) % 7);
|
||||
if (d.getDay() === 0 && new Date().getDay() === 0) {
|
||||
// Keep today if today is Sunday
|
||||
} else if (d.getDay() === 0) {
|
||||
// already sunday
|
||||
} else {
|
||||
d.setDate(d.getDate() + (7 - d.getDay()));
|
||||
}
|
||||
return d.toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
prevDay() {
|
||||
const d = new Date(this.selectedDate());
|
||||
d.setDate(d.getDate() - 1);
|
||||
this.fetchTodayLiturgy(d.toISOString().split('T')[0]);
|
||||
}
|
||||
|
||||
nextDay() {
|
||||
const d = new Date(this.selectedDate());
|
||||
d.setDate(d.getDate() + 1);
|
||||
this.fetchTodayLiturgy(d.toISOString().split('T')[0]);
|
||||
}
|
||||
|
||||
async fetchTodayLiturgy(date?: string) {
|
||||
if (date) this.selectedDate.set(date);
|
||||
const targetDate = this.selectedDate();
|
||||
|
||||
this.loading.set(true);
|
||||
this.suggestions.set([]);
|
||||
this.groupedSuggestions.set([]);
|
||||
this.keywords.set([]);
|
||||
|
||||
try {
|
||||
let xmlText = '';
|
||||
try {
|
||||
xmlText = await firstValueFrom(this.http.get(this.PROXY_URL + encodeURIComponent(this.RSS_URL), { responseType: 'text' }));
|
||||
} catch (e) {
|
||||
const fallbackProxy = 'https://api.allorigins.win/raw?url=';
|
||||
xmlText = await firstValueFrom(this.http.get(fallbackProxy + encodeURIComponent(this.RSS_URL), { responseType: 'text' }));
|
||||
}
|
||||
|
||||
const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlText, 'text/xml');
|
||||
const items = Array.from(xmlDoc.querySelectorAll('item'));
|
||||
|
||||
const lettureItem = items.find(item => {
|
||||
const title = item.querySelector('title')?.textContent || '';
|
||||
const category = item.querySelector('category')?.textContent || '';
|
||||
return title.startsWith(targetDate) && category === 'letture';
|
||||
});
|
||||
|
||||
if (lettureItem) {
|
||||
const description = lettureItem.querySelector('description')?.textContent || '';
|
||||
this.readings.set(this.parseDescription(description, targetDate));
|
||||
} else {
|
||||
this.readings.set(null);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch liturgy', err);
|
||||
this.readings.set(null);
|
||||
} finally {
|
||||
this.loading.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
private parseDescription(html: string, date: string): LiturgyReadings {
|
||||
const readings: LiturgyReadings = { date };
|
||||
|
||||
const parts = html.split(/([A-Z\s]+:)/);
|
||||
|
||||
let currentLabel = '';
|
||||
for (const part of parts) {
|
||||
const trimmed = part.trim();
|
||||
if (trimmed.endsWith(':')) {
|
||||
currentLabel = trimmed.toUpperCase();
|
||||
} else if (trimmed) {
|
||||
if (currentLabel.includes('PRIMA LETTURA')) readings.primaLettura = trimmed;
|
||||
else if (currentLabel.includes('SALMO')) readings.salmo = trimmed;
|
||||
else if (currentLabel.includes('SECONDA LETTURA')) readings.secondaLettura = trimmed;
|
||||
else if (currentLabel.includes('VANGELO')) readings.vangelo = trimmed;
|
||||
}
|
||||
}
|
||||
|
||||
return readings;
|
||||
}
|
||||
|
||||
suggestSongs() {
|
||||
const currentReadings = this.readings();
|
||||
if (!currentReadings) return;
|
||||
|
||||
const allText = [
|
||||
currentReadings.primaLettura,
|
||||
currentReadings.salmo,
|
||||
currentReadings.secondaLettura,
|
||||
currentReadings.vangelo
|
||||
].join(' ').toLowerCase();
|
||||
|
||||
const stopWords = new Set(['il', 'lo', 'la', 'i', 'gli', 'le', 'di', 'a', 'da', 'in', 'con', 'su', 'per', 'tra', 'fra', 'e', 'o', 'che', 'non', 'si', 'del', 'al', 'dal', 'nel', 'col', 'sul', 'mio', 'tuo', 'suo', 'noi', 'voi', 'loro', 'mio', 'mia', 'miei', 'mie']);
|
||||
const words = allText.match(/\b(\w+)\b/g) || [];
|
||||
const keywords = Array.from(new Set(words.filter(w => w.length > 3 && !stopWords.has(w))));
|
||||
this.keywords.set(keywords.slice(0, 20));
|
||||
|
||||
const songs = this.cantiService.canti();
|
||||
const scoredSongs = songs.map(song => {
|
||||
let score = 0;
|
||||
const titleLower = song.titolo.toLowerCase();
|
||||
const lyricsLower = (song.testo || '').toLowerCase();
|
||||
|
||||
keywords.forEach(kw => {
|
||||
if (titleLower.includes(kw)) score += 10;
|
||||
const regex = new RegExp(`\\b${kw}\\b`, 'g');
|
||||
const matches = lyricsLower.match(regex);
|
||||
if (matches) score += matches.length;
|
||||
});
|
||||
|
||||
return { song, score };
|
||||
});
|
||||
|
||||
const results = scoredSongs
|
||||
.filter(s => s.score > 0)
|
||||
.sort((a, b) => b.score - a.score);
|
||||
|
||||
const moments = this.cantiService.indiceLiturgico();
|
||||
const grouped: {moment: string, canti: Canto[]}[] = [];
|
||||
|
||||
moments.forEach(m => {
|
||||
const cantiInMoment = results
|
||||
.filter(s => s.song.id_momenti?.includes(m.id))
|
||||
.slice(0, 3)
|
||||
.map(s => s.song);
|
||||
|
||||
if (cantiInMoment.length > 0) {
|
||||
grouped.push({ moment: m.tag_name, canti: cantiInMoment });
|
||||
}
|
||||
});
|
||||
|
||||
this.groupedSuggestions.set(grouped);
|
||||
this.suggestions.set(results.slice(0, 20).map(s => s.song));
|
||||
}
|
||||
}
|
||||
@@ -35,10 +35,13 @@ export class SettingsService {
|
||||
this.fullscreenMode.set(savedFullscreen === 'true');
|
||||
}
|
||||
|
||||
/*
|
||||
const savedEditor = localStorage.getItem('show-editor');
|
||||
if (savedEditor !== null) {
|
||||
this.showEditor.set(savedEditor === 'true');
|
||||
}
|
||||
*/
|
||||
this.showEditor.set(false); // Funzione temporaneamente disabilitata
|
||||
|
||||
const savedAutoAdvance = localStorage.getItem('auto-advance');
|
||||
if (savedAutoAdvance !== null) {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export const VERSION = '2026.05.16.1715';
|
||||
export const VERSION = '2026.05.16.1840';
|
||||
|
||||
Reference in New Issue
Block a user