Backend for songs.zachdecook.com
Diffstat (limited to 'laravel/public/searchVerse.gmi')
| -rwxr-xr-x | laravel/public/searchVerse.gmi | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/laravel/public/searchVerse.gmi b/laravel/public/searchVerse.gmi new file mode 100755 index 0000000..d779988 --- /dev/null +++ b/laravel/public/searchVerse.gmi @@ -0,0 +1,29 @@ +#!/usr/bin/php8 +<?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\Song; + +$q = getenv('QUERY_STRING'); +if (!$q) { + printf("10 Enter a verse to search.\r\n"); + exit(0); +} + +$results = Song::whereVerse($q)->get(['id', 'verse', 'title']); + +if (!count($results)) { + printf("51 No songs found for '$q'."); + exit(0); +} + +printf("20 text/gemini\r\n"); +?> +<?php foreach($results as $song): ?> +=> /song.gmi.php/<?=$song->id?> <?= $song->verse ?>: <?= $song->title ?> + +<?php endforeach; ?> |