From 4b3c5b7646c089e7366bffeb7944d86a78b46266 Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Sat, 28 Nov 2020 04:17:35 +0000 Subject: * Gemini Editing: use json subject line --- laravel/applyedit.php | 10 +++++++--- laravel/public/song.gmi.php | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/laravel/applyedit.php b/laravel/applyedit.php index 034cca1..993203c 100644 --- a/laravel/applyedit.php +++ b/laravel/applyedit.php @@ -13,13 +13,17 @@ for($i = 0; $i < 10; $i++) { // TODO: Process these in order? $header = imap_header($imap, $number - $i); if (strpos($header->to[0]->mailbox, "+songs")){ - $id = explode(" ", $header->subject)[2]; - $song = Song::findOrFail($id); + $json = json_decode($header->subject); + $song = Song::findOrFail($json->id); $body = quoted_printable_decode(imap_body($imap, $number - $i)); $song->text = $body; + $song->title = $json->title; + $song->author = $json->author; + $song->key = $json->key; + $song->verse = $json->verse; $song->save(); imap_delete($imap, $number - $i); - printf("updated song $id"); + printf("updated song {$song->id}"); exit(0); } } diff --git a/laravel/public/song.gmi.php b/laravel/public/song.gmi.php index 8e3c43b..e4a84d6 100755 --- a/laravel/public/song.gmi.php +++ b/laravel/public/song.gmi.php @@ -30,7 +30,13 @@ printf("30 " . Song::inRandomOrder()->first()->id . "\r\n");return; ``` -=> mailto:zachdecook+songs@gmail.com?subject=Edit%20Song%20id ?>&body=text) ?> Edit song +=> mailto:zachdecook+songs@gmail.com?subject= $song->id, 'title' => $song->title, + 'author' => $song->author, + 'key' => $song->key, 'verse' => $song->verse, + ])) + ?>&body=text) ?> Edit song limit(5)->pluck('title','id') as $id => $title): ?> => -- cgit 1.4.1