From 753593fe0d25a5cc58ca84fbbccc24bd9c6e6e1e Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Tue, 28 Sep 2021 16:05:12 +0000 Subject: misc gemini additions --- chordsdata | 2 +- laravel/applyedit.php | 13 ++++++++++--- laravel/public/playlist.gmi | 3 ++- laravel/public/song.gmi.php | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/chordsdata b/chordsdata index 8f767ce..e0426e6 160000 --- a/chordsdata +++ b/chordsdata @@ -1 +1 @@ -Subproject commit 8f767cef5ccd8754d6c4b86d08bc8f76a3a0e0dc +Subproject commit e0426e668ca5b34f551e697166bc32f5d3c27764 diff --git a/laravel/applyedit.php b/laravel/applyedit.php index b9aa619..bd9f296 100755 --- a/laravel/applyedit.php +++ b/laravel/applyedit.php @@ -8,12 +8,20 @@ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); use App\Song; $imap = imap_open($mailbox, $username, $password); +if (!$imap){ + printf("no imap :("); + exit(1); +} $check = imap_check($imap); $number = $check->Nmsgs; +if (!$check){ + printf("no check :("); + exit(1); +} // Just check the newest 10 messages. -for($i = 0; $i < 10; $i++) { +for($i = 0; $i < 30; $i++) { // TODO: Process these in order? $header = imap_header($imap, $number - $i); - if (strpos($header->to[0]->mailbox, "+songs")){ + if (isset($header->to[0]) && strpos($header->to[0]->mailbox, "+songs")){ $json = json_decode($header->subject); $song = Song::findOrFail($json->id); $body = quoted_printable_decode(imap_body($imap, $number - $i)); @@ -25,7 +33,6 @@ for($i = 0; $i < 10; $i++) { $song->save(); imap_delete($imap, $number - $i); printf("updated song {$song->id}"); - exit(0); } } exit(0); diff --git a/laravel/public/playlist.gmi b/laravel/public/playlist.gmi index d384b6d..95d5c30 100755 --- a/laravel/public/playlist.gmi +++ b/laravel/public/playlist.gmi @@ -18,10 +18,11 @@ if($playlist){ 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; + printf("30 " . Playlist::inRandomOrder()->first()->name . "\r\n");return; } $songs = $playlist->songs()->pluck('title','songs.id'); ?> diff --git a/laravel/public/song.gmi.php b/laravel/public/song.gmi.php index edf9b2a..7da3606 100755 --- a/laravel/public/song.gmi.php +++ b/laravel/public/song.gmi.php @@ -25,6 +25,8 @@ printf("30 " . Song::inRandomOrder()->first()->id . "\r\n");return; => id ?>?q Transpose from plain_key ?> +audio ? "=> {$song->audio} Listen to this song" : "" ?> + ```chord sheet textTranspose(getenv('QUERY_STRING')??'') ?> -- cgit 1.4.1