about summary refs log tree commit diff
path: root/laravel/public
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2022-05-11 13:27:03 +0000
committerZach DeCook <zachdecook@librem.one>2022-05-11 13:27:03 +0000
commit6288883d88c420e242ffc07e81d9ca315eec4a5a (patch)
tree6c4cefe2e06f2036a95e72c27f1bd56539989f1e /laravel/public
parentb5b0dc2fd788ce2e27bebb14562f2225c0078871 (diff)
downloadprosongsa-6288883d88c420e242ffc07e81d9ca315eec4a5a.tar.gz
gemini: Add feature to search by bible verse
Diffstat (limited to 'laravel/public')
-rwxr-xr-xlaravel/public/searchVerse.gmi29
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; ?>