Backend for songs.zachdecook.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/usr/bin/php
<?php
define('LARAVEL_START', microtime(true));
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../load-eloquent.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
use App\Playlist;
use App\Song;
$playlist = Playlist::where('name',ltrim(getenv('PATH_INFO'),'/'))->first();
if($playlist){
$qs = getenv('QUERY_STRING');
if($qs){
$song = Song::find((int)$qs);
if(!$song){
printf("10 Enter a song id to add to this playlist \r\n");
return;
}
$playlist->songs()->toggle([$song->id]);
printf("30 " . $playlist->name . "\r\n");return;
}
printf("20 text/gemini\r\n");
} else {
printf("30 " . Playlist::inRandomOrder()->first()->name . "\r\n");return;
}
$songs = $playlist->songs()->pluck('title','songs.id');
?>
# <?= $playlist->name ?>
=> /playlist.gmi/<?=$playlist->name?>?q Add/remove from playlist.
<?php foreach($songs as $id => $title): ?>
=> /song.gmi.php/<?=$id?> <?= $title ?>
<?php endforeach; ?>
|