Преглед изворни кода

:sparkles: term 增加翻译按钮。在阅读器中翻译。

visuddhinanda@gmail.com пре 3 година
родитељ
комит
e478fe414d

+ 4 - 0
app/Http/Controllers/DhammaTermController.php

@@ -20,6 +20,9 @@ class DhammaTermController extends Controller
 		$indexCol = ['id','guid','word','word_en','meaning','other_meaning','note','language','channal','updated_at'];
 		$indexCol = ['id','guid','word','word_en','meaning','other_meaning','note','language','channal','updated_at'];
 
 
 		switch ($request->get('view')) {
 		switch ($request->get('view')) {
+            case 'show':
+                return $this->ok(DhammaTerm::find($request->get('id')));
+                break;
 			case 'user':
 			case 'user':
 				# code...
 				# code...
                 $userUid = $_COOKIE['user_uid'];
                 $userUid = $_COOKIE['user_uid'];
@@ -165,6 +168,7 @@ class DhammaTermController extends Controller
     public function show(DhammaTerm $dhammaTerm)
     public function show(DhammaTerm $dhammaTerm)
     {
     {
         //
         //
+        return $dhammaTerm;
     }
     }
 
 
     /**
     /**

+ 7 - 0
app/Models/DhammaTerm.php

@@ -8,4 +8,11 @@ use Illuminate\Database\Eloquent\Model;
 class DhammaTerm extends Model
 class DhammaTerm extends Model
 {
 {
     use HasFactory;
     use HasFactory;
+
+    protected $primaryKey = 'guid';
+    public  $incrementing = false;
+    //protected $keyType = "string";
+    protected $casts = [
+        'guid' => 'string'
+    ];
 }
 }

+ 4 - 0
public/app/article/index.php

@@ -9,6 +9,7 @@ require_once "../pcdl/html_head.php";
 	</script>
 	</script>
 
 
 	<script  src="./article.js"></script>
 	<script  src="./article.js"></script>
+	<script  src="./term.js"></script>
 
 
 	<script src="../widget/like.js"></script>
 	<script src="../widget/like.js"></script>
 	<link type="text/css" rel="stylesheet" href="../widget/like.css"/>
 	<link type="text/css" rel="stylesheet" href="../widget/like.css"/>
@@ -473,6 +474,9 @@ function set_toc_visible(isVisible){
 		case "sim":
 		case "sim":
 			palicanon_load();
 			palicanon_load();
 			break;
 			break;
+        case 'term':
+            term_load();
+            break;
 		default:
 		default:
 			break;
 			break;
 	}
 	}

+ 43 - 0
public/app/article/term.js

@@ -0,0 +1,43 @@
+function term_load(){
+    let params = new URLSearchParams(document.location.search.substring(1));
+    if(params.get("view") != 'term'){
+        return;
+    }
+    $.getJSON("/api/v2/terms?view=show&id="+params.get("id"))
+    .done(function(data){
+        let result = data.data;
+						_article_date = result;
+						$("#article_title").html(result.word);
+						//$("#article_path_title").html(result.meaning);
+						$("#page_title").text(result.title);
+						$("#article_subtitle").html(result.meaning + "; " + result.other_meaning);
+                        /*
+						let article_author = result.username.nickname + "@" + result.username.username;
+						if(result.lang !== "false"){
+							article_author += result.lang;
+						}else{
+							result.lang = "en";
+						}
+						
+						$("#article_author").html( article_author );
+*/
+						//将绝对链接转换为 用户连接的主机链接
+						//result.content = result.content.replace(/www-[A-z]*.wikipali.org/g,location.host);
+
+						$("#contents").html(note_init(result.note,"",result.owner,result.language));
+						//处理<code>标签作为气泡注释
+						popup_init();
+						guide_init();
+						note_refresh_new(function(){
+                            $.get('templiates/glossary.tpl',function(data){
+                                let TermData = term_get_used();
+                                let rendered = Mustache.render(data,TermData);
+                                $("#glossary").html(rendered);                                
+                            });
+                        });
+
+    })
+    .fail(function(){
+
+    });
+}

+ 3 - 0
public/app/channal/function.php

@@ -10,6 +10,9 @@ class Channal extends Table
     }
     }
 
 
     public function getChannal($id){
     public function getChannal($id){
+        if(empty($id)){
+            return false;
+        }
         $query = "SELECT * FROM ".$this->table." WHERE uid =? ";
         $query = "SELECT * FROM ".$this->table." WHERE uid =? ";
         $stmt = $this->dbh->prepare($query);
         $stmt = $this->dbh->prepare($query);
         $stmt->execute(array($id));
         $stmt->execute(array($id));

+ 4 - 3
public/app/wiki/wiki.js

@@ -105,9 +105,10 @@ function term_render_word_to_div(strWord,eDiv) {
 									"</button>";
 									"</button>";
 							}
 							}
 
 
-							html += "<button class='icon_btn'><a href='#'>" + gLocal.gui.like + "</a></button>";
-							html +=
-								"<button class='icon_btn'><a href='#'>" + gLocal.gui.favorite + "</a></button></span>";
+							html += "<button class='icon_btn'><a href='../article/index.php?view=term&id="+iterator.guid+"&display=sent&mode=edit' target='_blank'>" + gLocal.gui.translate + "</a></button>";
+							//TODO 增加点赞按钮
+                            //html += "<button class='icon_btn'><a href='#'>" + gLocal.gui.like + "</a></button>";
+                            html += "</span>";
 							html += "</div>";
 							html += "</div>";
 
 
 							html += "</div>";
 							html += "</div>";

+ 4 - 0
public/app/wiki/wiki.php

@@ -284,6 +284,10 @@ else{
 		.wiki_search_list li:hover {
 		.wiki_search_list li:hover {
 			background-color: beige;
 			background-color: beige;
 		}
 		}
+
+    .note_shell{
+        display:none;
+    }
 	</style>
 	</style>
 
 
 <style media="screen and (max-width:800px)">
 <style media="screen and (max-width:800px)">