Browse Source

:sparkles: 新的模版 quote

visuddhinanda 3 years ago
parent
commit
97adec0b36
1 changed files with 28 additions and 0 deletions
  1. 28 0
      app/Http/Api/MdRender.php

+ 28 - 0
app/Http/Api/MdRender.php

@@ -4,6 +4,7 @@ namespace App\Http\Api;
 use Illuminate\Support\Str;
 use mustache\mustache;
 use App\Models\DhammaTerm;
+use App\Models\PaliText;
 use App\Http\Controllers\CorpusController;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
@@ -85,6 +86,33 @@ class MdRender{
                     $html = $Sent->getSentTpl($param[1],[$channelId]);
                     return $html;
                     break;
+                case 'quote':
+                    $paraId = trim($param[1]);
+                    $props = Cache::remember("/quote/{$channelId}/{$paraId}",
+                          60,
+                          function() use($paraId,$channelId){
+                            $para = \explode('-',$paraId);
+                            $output = [
+                                "paraId" => $paraId,
+                                "channel" => $channelId,
+                                "innerString" => $paraId,
+                                ];
+                            if(count($para)<2){
+                                return $output;
+                            }
+                            $PaliText = PaliText::where("book",$para[0])
+                                                ->where("paragraph",$para[1])
+                                                ->select(['toc','path'])
+                                                ->first();
+
+                            if($PaliText){
+                                $output["pali"] = $PaliText->toc;
+                                $output["paliPath"] = \json_decode($PaliText->path);
+                                $innerString = $PaliText->toc;
+                            }
+                            return $output;
+                          });
+                    break;
                 default:
                     break;
             }