about summary refs log tree commit diff
path: root/laravel/app
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-02-12 00:15:24 +0000
committerZach DeCook <zachdecook@librem.one>2021-02-12 00:15:24 +0000
commit085b53b12866de6c095553bf2809641994e2d4cb (patch)
tree086074197f3ef7ea00b886a1f287accec428f838 /laravel/app
parentfa5a84e2b82d9295466b9587eb791bdf00de9e08 (diff)
downloadprosongsa-085b53b12866de6c095553bf2809641994e2d4cb.tar.gz
gemini: show chords based on transposition
Diffstat (limited to 'laravel/app')
-rw-r--r--laravel/app/Song.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/laravel/app/Song.php b/laravel/app/Song.php
index 102a0ca..46472c4 100644
--- a/laravel/app/Song.php
+++ b/laravel/app/Song.php
@@ -36,9 +36,10 @@ class Song extends Model
         // TODO: Validate that this is plain.
         return trim($this->key, "m");
     }
-    public function getChordsAttribute()
+    public function getChordsAttribute($txt = null)
     {
-        $txt = str_replace(['(',')',"\n"]," ",$this->text);
+        $txt = $txt ?? $this->text;
+        $txt = str_replace(['(',')',"\n", "\r"]," ",$txt);
         $words = array_flip(explode(' ', $txt));
         $allChords = json_decode(file_get_contents("public/js/chordsdata/chords.json"), TRUE);
         $chords = array_intersect_key($allChords, $words);