modificato deploy verso contabo
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
<ion-button fill="clear" (click)="editOrCloneCanto()" *ngIf="settingsService.showEditor() && !isLandscapeActive()" style="margin: 0; --padding-start: 6px; --padding-end: 6px;">
|
||||
<ion-icon slot="icon-only" name="create-outline" color="secondary" style="font-size: 1.3rem;"></ion-icon>
|
||||
</ion-button>
|
||||
<ion-button fill="clear" (click)="shareCanto()" *ngIf="!isLandscapeActive()" style="margin: 0; --padding-start: 6px; --padding-end: 6px;">
|
||||
<ion-icon slot="icon-only" name="share-social-outline" color="secondary" style="font-size: 1.3rem;"></ion-icon>
|
||||
</ion-button>
|
||||
<ion-button fill="clear" (click)="toggleChords()" *ngIf="!isLandscapeActive()" style="margin: 0; --padding-start: 6px; --padding-end: 6px;">
|
||||
<ion-icon slot="icon-only"
|
||||
[name]="showChords() ? 'musical-notes-outline' : 'text-outline'"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, OnDestroy, signal, computed, effect, inject, ElementRef, AfterViewInit, untracked, HostListener } from '@angular/core';
|
||||
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
||||
import { DomSanitizer, SafeResourceUrl, Meta } from '@angular/platform-browser';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { AlertController, ToastController, GestureController } from '@ionic/angular';
|
||||
import { CantiService, Canto } from '../../services/canti.service';
|
||||
@@ -150,6 +150,7 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private el = inject(ElementRef);
|
||||
private sanitizer = inject(DomSanitizer);
|
||||
public faceDetector = inject(FaceDetectorService);
|
||||
private meta = inject(Meta);
|
||||
|
||||
public enableCameraNavigation = signal<boolean>(false);
|
||||
|
||||
@@ -212,6 +213,9 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (!found) {
|
||||
found = this.playlistService.remoteCustomSongs().find(c => c.id === id || String(c.id_canti) === id);
|
||||
}
|
||||
if (!found) {
|
||||
found = this.playlistService.remoteShareCanti().find(c => c.id === id || String(c.id_canti) === id);
|
||||
}
|
||||
if (!found) {
|
||||
found = comunitaCantiPers.find(c => c.id === id);
|
||||
}
|
||||
@@ -237,6 +241,15 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.cantiService.getStorage()?.set('last_song_id', id);
|
||||
this.channel.postMessage({ type: 'SYNC_CANTO', id: found.id });
|
||||
this.channel.postMessage({ type: 'SYNC_INDEX', index: 0 });
|
||||
|
||||
// Update Open Graph Image tag dynamically
|
||||
const thumb = this.cantiService.getYoutubeThumb(found.link_youtube);
|
||||
if (thumb) {
|
||||
this.meta.updateTag({ property: 'og:image', content: thumb });
|
||||
} else {
|
||||
this.meta.updateTag({ property: 'og:image', content: window.location.origin + '/assets/icon/favicon.png' });
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
const scrollEl = this.el.nativeElement.querySelector('.lyrics-container');
|
||||
if (scrollEl) {
|
||||
@@ -1037,6 +1050,84 @@ export class PlayerPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
async shareCanto() {
|
||||
const c = this.canto();
|
||||
if (!c) return;
|
||||
|
||||
const isStandard = !c.id.startsWith('my_') && !c.id.startsWith('remote_share_') && !c.nonValidato;
|
||||
|
||||
try {
|
||||
let shareLink = '';
|
||||
if (isStandard) {
|
||||
shareLink = `https://www.canticristiani.it/?id=${c.id}`;
|
||||
} else {
|
||||
await this.playlistService.syncLocalDataToServer();
|
||||
const uid = this.settingsService.userUuid();
|
||||
shareLink = `https://www.canticristiani.it/?song-uid=${uid}&song-id=${c.id_canti}`;
|
||||
}
|
||||
|
||||
let fileToShare: File | null = null;
|
||||
const thumbUrl = this.cantiService.getYoutubeThumb(c.link_youtube);
|
||||
|
||||
// Try to fetch YouTube thumbnail first if available
|
||||
if (thumbUrl) {
|
||||
try {
|
||||
const response = await Promise.race([
|
||||
fetch(thumbUrl),
|
||||
new Promise<Response>((_, reject) => setTimeout(() => reject(new Error('Timeout')), 3000))
|
||||
]);
|
||||
if (response.ok) {
|
||||
const blob = await response.blob();
|
||||
fileToShare = new File([blob], 'song_thumbnail.jpg', { type: 'image/jpeg' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Share] Failed to fetch YouTube thumbnail due to CORS or timeout:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// If no YouTube thumb or fetch failed, fallback to local canticristiani logo (favicon)
|
||||
if (!fileToShare) {
|
||||
try {
|
||||
const response = await fetch('assets/icon/favicon.png');
|
||||
if (response.ok) {
|
||||
const blob = await response.blob();
|
||||
fileToShare = new File([blob], 'canticristiani_logo.png', { type: 'image/png' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Share] Failed to fetch local logo:', e);
|
||||
}
|
||||
}
|
||||
|
||||
const shareDataObj: any = {
|
||||
title: `Condividi Canto: ${c.titolo}`,
|
||||
text: isStandard
|
||||
? `Ecco il canto "${c.titolo}" dall'app Canti Cristiani. Clicca sul link per aprirlo:\n\n`
|
||||
: `Ecco il canto "${c.titolo}" per l'app Canti Cristiani. Clicca sul link per aggiungerlo:\n\n`,
|
||||
url: shareLink
|
||||
};
|
||||
|
||||
if (fileToShare && navigator.canShare && navigator.canShare({ files: [fileToShare] })) {
|
||||
shareDataObj.files = [fileToShare];
|
||||
}
|
||||
|
||||
if (navigator.share) {
|
||||
await navigator.share(shareDataObj);
|
||||
} else {
|
||||
if (navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(shareLink);
|
||||
const toast = await this.toastCtrl.create({
|
||||
message: 'Link di condivisione copiato negli appunti!',
|
||||
duration: 2500,
|
||||
color: 'success'
|
||||
});
|
||||
await toast.present();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to share song', err);
|
||||
}
|
||||
}
|
||||
|
||||
private initPlayer(id: string) {
|
||||
if (!this.youtubePlayerService.isPlayerSupported()) {
|
||||
return;
|
||||
|
||||
@@ -131,7 +131,8 @@ export class ProposeCantoPage implements OnInit {
|
||||
const song = [
|
||||
...this.cantiService.canti(),
|
||||
...this.myCantiService.myCanti(),
|
||||
...this.playlistService.remoteCustomSongs()
|
||||
...this.playlistService.remoteCustomSongs(),
|
||||
...this.playlistService.remoteShareCanti()
|
||||
].find(c => c.id === editId);
|
||||
|
||||
if (song) {
|
||||
@@ -961,6 +962,10 @@ export class ProposeCantoPage implements OnInit {
|
||||
await this.playlistService.replaceSongIdInPlaylists(this.editId, savedCanto.id);
|
||||
}
|
||||
|
||||
if (this.editId && this.editId.startsWith('remote_share_')) {
|
||||
await this.playlistService.deleteRemoteShareCanto(this.editId);
|
||||
}
|
||||
|
||||
if (this.editId && savedCanto && savedCanto.id && this.editId !== savedCanto.id) {
|
||||
this.router.navigate(['/player'], { queryParams: { id: savedCanto.id }, replaceUrl: true });
|
||||
} else {
|
||||
|
||||
@@ -156,7 +156,9 @@ export class SettingsPage {
|
||||
id_canti: Number(item.id_canti),
|
||||
titolo: item.titolo || 'Senza Titolo',
|
||||
testo: item.testo || '',
|
||||
accordi: item.testo?.includes('[') ? item.testo : undefined,
|
||||
accordi: item.accordi || (item.testo?.includes('[') ? item.testo : undefined),
|
||||
autore: item.autore || '',
|
||||
link_youtube: item.link_youtube || '',
|
||||
id_momenti: item.momenti?.map((m: any) => Number(m)).filter((m: any) => !isNaN(m)) || []
|
||||
}));
|
||||
|
||||
@@ -342,7 +344,9 @@ export class SettingsPage {
|
||||
id_canti: Number(item.id_canti),
|
||||
titolo: item.titolo || 'Senza Titolo',
|
||||
testo: item.testo || '',
|
||||
accordi: item.testo?.includes('[') ? item.testo : undefined,
|
||||
accordi: item.accordi || (item.testo?.includes('[') ? item.testo : undefined),
|
||||
autore: item.autore || '',
|
||||
link_youtube: item.link_youtube || '',
|
||||
id_momenti: item.momenti?.map((m: any) => Number(m)).filter((m: any) => !isNaN(m)) || []
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user