From: Vincent Vanwaelscappel Date: Tue, 10 Jan 2023 17:56:24 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ff085274ea5a57384f17a153fb9ce4420248f8eb;p=songbook.git . --- diff --git a/app/Http/Controllers/FrontController.php b/app/Http/Controllers/FrontController.php index 291f0f1..e2de20d 100644 --- a/app/Http/Controllers/FrontController.php +++ b/app/Http/Controllers/FrontController.php @@ -18,6 +18,14 @@ use Notion\Pages\Properties\Title; class FrontController extends Controller { + public static $notionFileFields = [ + 'demos' => ['notion' => 'Démos Voix', 'cat' => '🎤 Démos'], + 'instru' => ['notion' => 'Instru', 'cat' => '🎸 Instru'], + 'record' => ['notion' => 'Enregistrement', 'cat' => '💿️ Enregistrement'], + 'tabs' => ['notion' => 'Partition', 'cat' => '🎼 Partition'], + 'archives' => ['notion' => 'Archives et autres fichiers', 'cat' => '🗃️ Archives'] + ]; + public static function defaultCollection() { return redirect('/' . Collection::withoutGlobalScope('ownerclause')->find(1)->slug); } @@ -186,6 +194,12 @@ class FrontController extends Controller { } + /** @var Checkbox $hideProperty */ + $hideProperty = $song->getProprety('Cacher dans l\'app'); + if ($hideProperty->checked) { + continue; + } + $s = []; /** @var Title $titleProperty */ @@ -194,12 +208,31 @@ class FrontController extends Controller { $orderProperty = $song->getProprety('Ordre'); /** @var RichTextProperty $notesProperty */ $notesProperty = $song->getProprety('Notes générales'); - /** @var \Notion\Pages\Properties\Files $filesProperty */ - $filesProperty = $song->getProprety('Files & media'); - /** @var Checkbox $hideProperty */ - $hideProperty = $song->getProprety('Cacher dans l\'app'); - if ($hideProperty->checked) { - continue; + + $audioId = 0; + foreach (self::$notionFileFields as $key => $f) { + /** @var \Notion\Pages\Properties\Files $filesProperty */ + $filesProperty = $song->getProprety($f['notion']); + if (!isset($s[$key])) { + $s[$key] = []; + } + foreach ($filesProperty->files as $file) { + $ext = self::parseExtensionFromAmazonURL($file->url); + $isAudio = in_array($ext, $audios); + if ($isAudio) { + $audioId++; + $aid = $audioId; + } else { + $aid = 0; + } + $e = explode('.', $file->name); + if (count($e) > 1) { + array_pop($e); + $name = implode('.', $e); + } + $name = $name ?: self::parseFileNameFromAmazonURL($file->url); + $s[$key][] = ['name' => $name, 'opturl' => $file->url, 'url' => $file->url, 'ext' => $ext, 'audio' => $aid]; + } } $s['id'] = $song->id; @@ -208,18 +241,6 @@ class FrontController extends Controller { $s['lyrics'] = $pageContents; $s['notes'] = self::_blockToHtml($notesProperty); $s['notion_url'] = $song->url; - - $s['files'] = []; - $s['audios'] = []; - foreach ($filesProperty->files as $file) { - $ext = self::parseExtensionFromAmazonURL($file->url); - if (in_array($ext, $audios)) { - $s['audios'][] = ['name' => self::parseFileNameFromAmazonURL($file->url), 'url' => $file->url, 'ext' => $ext]; - } else { - $s['files'][] = ['name' => self::parseFileNameFromAmazonURL($file->url), 'url' => $file->url, 'ext' => $ext]; - } - } - $res[$s['order']] = new \App\Notion\Song($s, $collection->notion_database); } ksort($res); diff --git a/app/Notion/Song.php b/app/Notion/Song.php index 101fefc..ff35878 100644 --- a/app/Notion/Song.php +++ b/app/Notion/Song.php @@ -2,10 +2,11 @@ namespace App\Notion; +use App\Http\Controllers\FrontController; use Cubist\Util\Data; use Cubist\Util\Str; -class Song extends Data{ +class Song extends Data { public function getUrl() { return Str::slug($this->getTitle()) . '.html'; @@ -31,25 +32,24 @@ class Song extends Data{ return $this->get('order'); } - public function getNotionURL(){ + public function getNotionURL() { return $this->get('notion_url'); } - public function hasSimpleChords(){ + public function hasSimpleChords() { return false; } public function getAudioTracks() { - $res = $this->get('audios'); - foreach ($res as $k=>$v) { - $res[$k]['i']=$k; - $res[$k]['opturl']=$v['url']; + $res = []; + foreach (FrontController::$notionFileFields as $key => $field) { + foreach ($this->get($key, []) as $file) { + if (!$file['audio']) { + continue; + } + $res[] = $file; + } } return $res; } - - public function getFiles(){ - return $this->get('files'); - } - } diff --git a/resources/js/player.js b/resources/js/player.js index 0046519..7976037 100644 --- a/resources/js/player.js +++ b/resources/js/player.js @@ -14,6 +14,7 @@ $('select[data-name="audio"]').val(e[1]); updateSelect($('select[data-name="audio"]')); resetPlayers(); + playAudio(); return false; }); @@ -48,6 +49,7 @@ $('[data-action="play"]').hide(); var audio = window.getOption('audio').toString(); + var t = window.getOption('audio_' + audio + '_tone'); if (t === undefined) { t = 0; diff --git a/resources/views/notion_menu.blade.php b/resources/views/notion_menu.blade.php index ea05a24..f76230d 100644 --- a/resources/views/notion_menu.blade.php +++ b/resources/views/notion_menu.blade.php @@ -72,27 +72,9 @@
  • 💿 {{__('Audio track')}}
  • - @foreach($song->getAudioTracks() as $i=>$track) - @if($collection->transpose && isset($track['tone']) && is_numeric($track['tone'])) -
  • ↕️{{__('Audio key')}}
  • - @endif - @endforeach @endif {{-- @if($partition)--}} {{--
  • 🎼 {{__('Partition')}}
  • --}} diff --git a/resources/views/notion_song.blade.php b/resources/views/notion_song.blade.php index c3c0117..a2d34ec 100644 --- a/resources/views/notion_song.blade.php +++ b/resources/views/notion_song.blade.php @@ -1,5 +1,4 @@ @php - $audioTracks=$song->getAudioTracks(); $simple=$song->hasSimpleChords(); @endphp @@ -13,39 +12,47 @@
    {!! $song->notes !!}
    @endif
    {{$song->credits}}
    - @if(count($audioTracks)) -

    💿 {{__('Audios')}}

    - - @endif - @if(count($song->getFiles())) -

    📄 {{__('Fichiers')}}

    - - @endif - - @if(count($audioTracks)) + + @foreach(\App\Http\Controllers\FrontController::$notionFileFields as $key=>$field) + @if($song->get($key,null)) +

    {{$field['cat']}}

    + + @endif + @endforeach +
    - @foreach($audioTracks as $audio) - + @foreach(\App\Http\Controllers\FrontController::$notionFileFields as $key => $field) + @foreach($song->get($key, []) as $file) + @if($file['audio']) + @php + $hasAudio=true; + @endphp + + @endif + @endforeach @endforeach
    - @endif -@endsection -@section('floating') - @if(count($audioTracks)) - - - - @endif + @endsection + @section('floating') + @if(isset($hasAudio) && $hasAudio) + + + + @endif + @endsection