Bladeren bron

Merge pull request #1832 from visuddhinanda/laravel

逐词解析模式原文有content
visuddhinanda 2 jaren geleden
bovenliggende
commit
b08a0bf002

+ 6 - 3
app/Console/Commands/UpgradeCompound.php

@@ -16,7 +16,7 @@ class UpgradeCompound extends Command
 {
 {
     /**
     /**
      * The name and signature of the console command.
      * The name and signature of the console command.
-     * php artisan upgrade:compound
+     * php artisan upgrade:compound --api=https://staging.wikipali.org/api
      * @var string
      * @var string
      */
      */
     protected $signature = 'upgrade:compound {word?} {--book=} {--debug} {--test} {--continue} {--api=} {--from=} {--to=}';
     protected $signature = 'upgrade:compound {word?} {--book=} {--debug} {--test} {--continue} {--api=} {--from=} {--to=}';
@@ -191,11 +191,14 @@ class UpgradeCompound extends Command
     }
     }
 
 
     private function upload($index,$words,$url=null){
     private function upload($index,$words,$url=null){
-        $this->info('uploading '.count($index));
+
         if(!$url){
         if(!$url){
             $url = config('app.url').'/api/v2/compound';
             $url = config('app.url').'/api/v2/compound';
+        }else{
+            $url = $url.'/v2/compound';
         }
         }
-
+        $this->info('url = '.$url);
+        $this->info('uploading size='.strlen(json_encode($words,JSON_UNESCAPED_UNICODE)));
         $response = Http::post($url,
         $response = Http::post($url,
                                 [
                                 [
                                     'index'=> $index,
                                     'index'=> $index,

+ 2 - 2
app/Http/Api/TemplateRender.php

@@ -565,7 +565,7 @@ class TemplateRender{
             'found' => true,
             'found' => true,
         ];
         ];
 
 
-        if(empty($bookName) || !$volume || empty($page)){
+        if(empty($bookName) || $volume===false || empty($page)){
             /**
             /**
              * 没有指定书名,根据book para 查询
              * 没有指定书名,根据book para 查询
              */
              */
@@ -597,7 +597,7 @@ class TemplateRender{
                             }
                             }
                         }
                         }
                     }
                     }
-                    if(!$volume){
+                    if($volume===false){
                         $volume = $pageInfo->volume;
                         $volume = $pageInfo->volume;
                     }
                     }
                     if(!$page){
                     if(!$page){

+ 23 - 17
app/Http/Controllers/CorpusController.php

@@ -668,27 +668,33 @@ class CorpusController extends Controller
                             // 阅读模式直接显示html原文
                             // 阅读模式直接显示html原文
                             // 传过来的数据一定有一个原文channel
                             // 传过来的数据一定有一个原文channel
                             //
                             //
-                            if($mode !== "read" && $row->content_type==='json'){
-                                $newSent['channel']['type'] = "wbw";
-                                if(isset($this->wbwChannels[0])){
-                                    $newSent['channel']['name'] = $indexChannel[$this->wbwChannels[0]]->name;
-                                    $newSent['channel']['id'] = $this->wbwChannels[0];
-                                    //存在一个translation channel
-                                    //尝试查找逐词解析数据。找到,替换现有数据
-                                    $wbwData = $this->getWbw($arrSentId[0],$arrSentId[1],$arrSentId[2],$arrSentId[3],
-                                                            $this->wbwChannels[0]);
-                                    if($wbwData){
-                                        $newSent['content'] = $wbwData;
-                                        $newSent['contentType'] = 'json';
-                                        $newSent['html'] = "";
-                                    }
-                                }
-                            }else{
+                            if($mode === "read"){
                                 $newSent['content'] = "";
                                 $newSent['content'] = "";
-                                //$newSent['html'] = $row->content;
                                 $newSent['html'] = MdRender::render($row->content,[$row->channel_uid],
                                 $newSent['html'] = MdRender::render($row->content,[$row->channel_uid],
                                                                             null,$mode,"translation",
                                                                             null,$mode,"translation",
                                                                             $row->content_type,$format);
                                                                             $row->content_type,$format);
+                            }else{
+                                if($row->content_type==='json'){
+                                    $newSent['channel']['type'] = "wbw";
+                                    if(isset($this->wbwChannels[0])){
+                                        $newSent['channel']['name'] = $indexChannel[$this->wbwChannels[0]]->name;
+                                        $newSent['channel']['id'] = $this->wbwChannels[0];
+                                        //存在一个translation channel
+                                        //尝试查找逐词解析数据。找到,替换现有数据
+                                        $wbwData = $this->getWbw($arrSentId[0],$arrSentId[1],$arrSentId[2],$arrSentId[3],
+                                                                $this->wbwChannels[0]);
+                                        if($wbwData){
+                                            $newSent['content'] = $wbwData;
+                                            $newSent['contentType'] = 'json';
+                                            $newSent['html'] = "";
+                                        }
+                                    }
+                                }else{
+                                    $newSent['content'] = $row->content;
+                                    $newSent['html'] = MdRender::render($row->content,[$row->channel_uid],
+                                                                                null,$mode,"translation",
+                                                                                $row->content_type,$format);
+                                }
                             }
                             }
 
 
                             break;
                             break;