use App\Models\CollectionList;
use App\Models\Song;
use Cubist\Backpack\Http\Controllers\CubistPWAController;
+use Cubist\Util\Files\Files;
use Illuminate\Support\Facades\Session;
public function song($collection, $song)
{
+ /** @var Collection $collection */
$collection = Collection::where('slug', $collection)->first();
if (null === $collection) {
abort(404);
}
+ /** @var Song $song */
$song = Song::where('slug', $song)->first();
if (null === $song) {
abort(404);
return $p;
}
$lists = CollectionList::where('collection', $collection->id)->get();
- return view('song', ['menu' => true, 'song' => $song, 'collection' => $collection, 'collection_songs' => $this->_getSongsOfCollection($collection->id, $lists), 'collection_lists' => $lists]);
+ $partition = $song->getFirstMediaInField('partition');
+ if ($partition) {
+ $partition = $partition->getUrl();
+ }
+ $lyrics_html = '';
+ $lyrics_doc = $song->getFirstMediaInField('lyrics_doc');
+ dd($lyrics_doc);
+
+ if ($lyrics_doc) {
+ $path = $lyrics_doc->getPath();
+ $html_path = $path . '.html';
+ dd(`libreoffice --convert-to HTML:HTML --outdir $html_path $path`);
+ if (!file_exists($html_path)) {
+
+ }
+ $lyrics_html = file_get_contents($html_path);
+ }
+ return view('song', ['menu' => true, 'lyrics_html' => $lyrics_html, 'song' => $song, 'collection' => $collection, 'partition' => $partition, 'collection_songs' => $this->_getSongsOfCollection($collection->id, $lists), 'collection_lists' => $lists]);
}
protected function _getSongsOfCollection($id, $lists)
return response(json_encode($res))->header('Content-Type', 'application/manifest+json');
}
+
+ public function downloadAssets($songId)
+ {
+ /** @var Song $song */
+ $song = Song::find($songId);
+ $fields = ['partition', 'lyrics_doc'];
+ $files = [];
+ $tmp = Files::tempnam() . '.zip';
+ $zip = new \ZipArchive();
+ $zip->open($tmp, \ZipArchive::CREATE);
+ foreach ($fields as $field) {
+ $media = $song->getFirstMediaInField($field);
+ if ($media) {
+ $files[] = $media->getPath();
+ }
+ }
+ foreach ($song->getAudioTracks() as $track) {
+ $files[] = $track['path'];
+ }
+ foreach ($files as $file) {
+ $f = new \SplFileInfo($file);
+ $zip->addFile($file, $f->getFilename());
+ }
+ $zip->close();
+ return response()->download($tmp, $song->title . '.zip')->deleteFileAfterSend();
+ }
}
+
$this->addField('chorale', Checkbox::class, 'Chorale', ['default' => false, 'database_default' => false]);
$this->addField('collections', \App\Field\CollectionList::class, 'Collections');
$this->addField('tempo', Tempo::class, 'Suggested tempo', ['column' => true, 'default' => 80]);
- $this->addField('partition', Files::class, 'Partition', ['acceptedFiles' => '*.pdf', 'when' => ['chorale' => 1]]);
- $this->addField('lyrics_doc', Files::class, 'Paroles', ['acceptedFiles' => '*.doc', 'when' => ['chorale' => 1]]);
+ $this->addField('partition', Files::class, 'Partition', ['acceptedFiles' => 'application/pdf', 'when' => ['chorale' => 1]]);
+ $this->addField('lyrics_doc', Files::class, 'Paroles', ['acceptedFiles' => 'application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain,text/html', 'when' => ['chorale' => 1]]);
$this->addField('audio', BunchOfFieldsMultiple::class, 'Audio tracks', ['bunch' => AudioTrack::class, 'new_label' => 'New audio track']);
$this->addField('lyrics', BunchOfFieldsMultiple::class, 'Song Parts', ['bunch' => SongPortion::class, 'new_label' => 'New song part', 'when' => ['chorale' => 0]]);
// $this->addField('youtube', URL::class, 'Youtube link');
{
- "name": "enhydra/songbook",
- "type": "project",
- "description": "Songbook",
- "keywords": [
- "framework",
- "laravel"
- ],
- "repositories": [
- {
- "type": "composer",
- "url": "https://composer.cubedesigners.com/"
- }
- ],
- "license": "MIT",
- "require": {
- "php": ">=7.4",
- "ext-json": "*",
- "ext-simplexml": "*",
- "ext-tidy": "*",
- "ext-zip": "*",
- "cubist/cms-back": "dev-master",
- "fruitcake/laravel-cors": "^2.2",
- "league/csv": "^9.8",
- "mxl/laravel-job": "^1.3",
- "norkunas/youtube-dl-php": "dev-master",
- "php-ffmpeg/php-ffmpeg": "^0.18.0",
- "phpoffice/phpspreadsheet": "^1.23",
- "predis/predis": "^1.1",
- "ext-libxml": "*",
- "ext-dom": "*"
- },
- "require-dev": {
- "barryvdh/laravel-ide-helper": "^2.10",
- "facade/ignition": "^2.3",
- "filp/whoops": "^2.14",
- "laravel/tinker": "^2.1",
- "mockery/mockery": "^1.4",
- "nunomaduro/collision": "^4.2",
- "phpunit/phpunit": "^8.5"
- },
- "config": {
- "optimize-autoloader": true,
- "preferred-install": "dist",
- "sort-packages": true
- },
- "extra": {
- "laravel": {
- "dont-discover": []
- }
- },
- "autoload": {
- "psr-4": {
- "App\\": "app/"
- },
- "classmap": [
- ]
- },
- "autoload-dev": {
- "psr-4": {
- "Tests\\": "tests/"
- }
- },
- "minimum-stability": "dev",
- "prefer-stable": true,
- "scripts": {
- "post-autoload-dump": [
- "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
- "@php artisan package:discover --ansi"
+ "name": "enhydra/songbook",
+ "type": "project",
+ "description": "Songbook",
+ "keywords": [
+ "framework",
+ "laravel"
],
- "post-root-package-install": [
- "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
+ "repositories": [
+ {
+ "type": "composer",
+ "url": "https://composer.cubedesigners.com/"
+ }
],
- "post-create-project-cmd": [
- "@php artisan key:generate --ansi"
- ]
- }
+ "license": "MIT",
+ "require": {
+ "php": ">=7.4",
+ "ext-json": "*",
+ "ext-simplexml": "*",
+ "ext-tidy": "*",
+ "ext-zip": "*",
+ "ext-libxml": "*",
+ "ext-dom": "*",
+ "ext-redis": "*",
+ "cubist/cms-back": "dev-master",
+ "fruitcake/laravel-cors": "^2.2",
+ "league/csv": "^9.8",
+ "mxl/laravel-job": "^1.3",
+ "norkunas/youtube-dl-php": "dev-master",
+ "php-ffmpeg/php-ffmpeg": "^0.18.0",
+ "phpoffice/phpspreadsheet": "^1.23"
+ },
+ "require-dev": {
+ "barryvdh/laravel-ide-helper": "^2.10",
+ "facade/ignition": "^2.3",
+ "filp/whoops": "^2.14",
+ "laravel/tinker": "^2.1",
+ "mockery/mockery": "^1.4",
+ "nunomaduro/collision": "^4.2",
+ "phpunit/phpunit": "^8.5"
+ },
+ "config": {
+ "optimize-autoloader": true,
+ "preferred-install": "dist",
+ "sort-packages": true
+ },
+ "extra": {
+ "laravel": {
+ "dont-discover": []
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "App\\": "app/"
+ },
+ "classmap": [
+ ]
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Tests\\": "tests/"
+ }
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true,
+ "scripts": {
+ "post-autoload-dump": [
+ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
+ "@php artisan package:discover --ansi"
+ ],
+ "post-root-package-install": [
+ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
+ ],
+ "post-create-project-cmd": [
+ "@php artisan key:generate --ansi"
+ ]
+ }
}
+++ /dev/null
-body {
- font-family: 'Nunito', sans-serif;
-}
-
-main.song {
- .lyrics{
- white-space: pre-line;
- }
-}
+++ /dev/null
-body{
-
-}
margin: 0
padding: 0
box-sizing: border-box
+ outline-width: 0
h1, h2, h3, h4, h5, h6
font-family: $slab
padding: 20px 0 0 0
color: #cc0000
+
input
display: block
margin: 25px auto
input[type=password]
text-align: left
+ outline-width: 1px
outline-color: var(--theme-color)
input[type=submit]
color: #fff
cursor: pointer
-
@import "../../node_modules/mmenu-light/dist/mmenu-light.css"
@import "../../node_modules/plyr/dist/plyr.css"
+++ /dev/null
-body {
- font-family: 'Nunito', sans-serif;
-}
-
-main.song {
- .lyrics{
- white-space: pre-line;
- }
-}
</ul>
</li>
@if(isset($song))
-
@if($song->hasChords())
<li><a href="#" class="noaction">🎤 {{__('Show lyrics')}} <input type="checkbox"
class="checkbox-switch"
data-default="0"></a>
</li>
@endif
- <li><a href="#" class="clickselect">↕️ {{__('Key')}} <select data-name="tone"
- name="tone_{{$song->id}}">
- @for($i=-5;$i<=6;$i++)
- <option value="{{$i}}"
- @if($i===0) selected @endif>{{$tones[(12+$song->key+$i)%12].$song->mode}} @if($i>0)
- (+{{$i}}
- )
- @elseif($i<0)
- ({{$i}})
- @endif </option>
- @endfor
- </select><span></span></a></li>
+ @if($collection->transpose)
+ <li><a href="#" class="clickselect">↕️ {{__('Key')}} <select data-name="tone"
+ name="tone_{{$song->id}}">
+ @for($i=-5;$i<=6;$i++)
+ <option value="{{$i}}"
+ @if($i===0) selected @endif>{{$tones[(12+$song->key+$i)%12].$song->mode}} @if($i>0)
+ (+{{$i}}
+ )
+ @elseif($i<0)
+ ({{$i}})
+ @endif </option>
+ @endfor
+ </select><span></span></a></li>
+ @endif
@else
<li class="hidden"><a href="#" class="noaction">{{__('Show chords')}} <input type="checkbox"
class="checkbox-switch"
@endforeach
</select><span></span></a></li>
@foreach($song->getAudioTracks() as $i=>$track)
- @if(isset($track['tone']) && is_numeric($track['tone']))
+ @if($collection->transpose && isset($track['tone']) && is_numeric($track['tone']))
<li data-audio="{{$i}}"><a href="#" class="clickselect">↕️{{__('Audio key')}} <select
class="audiotone"
data-name="audio_{{$i}}_tone"
@endif
@endforeach
@endif
+ @if($partition)
+ <li><a target="_blank" href="{{$partition}}">🎼 {{__('Partition')}}</a></li>
+ @endif
+ @if($collection->download_assets)
+ <li><a href="/downloadassets/{{$song->id}}">⬇️ {{__('Télécharger')}}</a></li>
+ @endif
@endif
+
<li>
<span><img
src="https://api.qrserver.com/v1/create-qr-code/?size=50x50&data={{rawurlencode('https://songbook.enhydra.fr/'.$collection->slug)}}"
Route::get('{collection}.webmanifest', [FrontController::class, 'manifest']);
Route::any('{collection}', [FrontController::class, 'collection']);
Route::any('{collection}/{song}.html', [FrontController::class, 'song']);
+Route::get('downloadassets/{songid}', [FrontController::class, 'downloadAssets']);