visuddhinanda@gmail.com 3 лет назад
Родитель
Сommit
52298ac42b

+ 16 - 0
app/Console/Commands/UpgradeProgressChapter.php

@@ -89,6 +89,21 @@ class UpgradeProgressChapter extends Command
                                 ->whereBetween('para',[$chapter->paragraph,$chapter->paragraph+$chapter->chapter_len-1])
                                 ->where('channel_id',$final->channel_id)
                                 ->max('updated_at');
+                    $transTexts = Sentence::where('book_id',$book->book_id)
+                                ->whereBetween('paragraph',[$chapter->paragraph+1,$chapter->paragraph+$chapter->chapter_len-1])
+                                ->where('channel_uid',$final->channel_id)
+                                ->select('content')
+                                ->orderBy('paragraph')
+                                ->orderBy('word_start')
+                                ->get();
+                    $summaryText = "";
+                    foreach ($transTexts as $text) {
+                        # code...
+                        $summaryText .= str_replace("\n","",$text->content);
+                        if(mb_strlen($summaryText,"UTF-8")>255){
+                            break;
+                        }
+                    }
                     #查询标题
                     $title = Sentence::where('book_id',$book->book_id)
                           ->where('paragraph',$chapter->paragraph)
@@ -137,6 +152,7 @@ class UpgradeProgressChapter extends Command
                     $chapterData->public = $final->cp_len/$chapter_strlen;
                     $chapterData->progress = $final->cp_len/$chapter_strlen;
                     $chapterData->title = mb_substr($title,0,255,"UTF-8");
+                    $chapterData->summary = mb_substr($summaryText,0,255,"UTF-8");
                     $chapterData->created_at = $finalAt;
                     $chapterData->updated_at = $updateAt;
                     $chapterData->save();

+ 11 - 2
app/Http/Controllers/ProgressChapterController.php

@@ -8,6 +8,7 @@ use App\Models\Channel;
 use App\Models\Tag;
 use App\Models\TagMap;
 use App\Models\PaliText;
+use App\Models\View;
 use Illuminate\Http\Request;
 
 class ProgressChapterController extends Controller
@@ -135,6 +136,9 @@ class ProgressChapterController extends Controller
             case 'channel-type':
                 break;
             case 'channel':
+            /*
+            总共有多少channel
+            */
                 $chapters = ProgressChapter::select('channel_id')
                                             ->selectRaw('count(*) as count')
                                             ->with(['channel' => function($query) {  //city对应上面province模型中定义的city方法名  闭包内是子查询
@@ -174,7 +178,7 @@ class ProgressChapterController extends Controller
                 $param[] = $minProgress;
                 $param[] = $offset;
                 $query = "
-                select tpc.book ,tpc.para,tpc.channel_id,tpc.title,pt.toc,pt.path,tpc.progress,tpc.created_at,tpc.updated_at 
+                select tpc.uid, tpc.book ,tpc.para,tpc.channel_id,tpc.title,pt.toc,pt.path,tpc.progress,tpc.summary,tpc.created_at,tpc.updated_at 
                     from (
                         select * from (
                             select anchor_id as cid from (
@@ -196,7 +200,12 @@ class ProgressChapterController extends Controller
                 $chapters = DB::select($query,$param);
                 foreach ($chapters as $key => $value) {
                     # code...
-                    $chapters[$key]->channel_info = Channel::where('uid',$value->channel_id)->select(['name','owner_uid'])->first();
+                    $chapters[$key]->channel = Channel::where('uid',$value->channel_id)->select(['name','owner_uid'])->first();
+                    $chapters[$key]->views = View::where("target_id",$value->uid)->count();
+                    $chapters[$key]->tags = TagMap::where("anchor_id",$value->uid)
+                                                ->leftJoin('tags','tag_maps.tag_id', '=', 'tags.id')
+                                                ->select(['tags.id','tags.name','tags.description'])
+                                                ->get();
                 }
                 $all_count = 10;
                 break;

+ 12 - 4
app/Http/Controllers/ViewController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Models\View;
+use App\Models\ProgressChapter;
 use Illuminate\Http\Request;
 use Illuminate\Support\Str;
 
@@ -17,6 +18,13 @@ class ViewController extends Controller
                 break;
             case 'chapter':
                 # code...
+                $channel = $request->get("channel");
+                $book = $request->get("book");
+                $para = $request->get("para");
+                $target_id = ProgressChapter::where("channel_id",$request->get("channel"))
+                                            ->where("book",$request->get("book"))
+                                            ->where("para",$request->get("para"))
+                                            ->value("uid");
                 break;
             case 'article-instance':
                 # code...
@@ -80,9 +88,9 @@ class ViewController extends Controller
             'target_id' => $target_id,
             'target_type' => $request->get("target_type"),
         ];
-        if(isset($GET['user_uid'])){
+        if(isset($_COOKIE['user_uid'])){
             //已经登陆
-            $user_id = $GET['user_uid'];
+            $user_id = $_COOKIE['user_uid'];
             $param['user_id'] = $user_id;
         }else{
             $param['user_ip'] = $clientIp;
@@ -90,8 +98,8 @@ class ViewController extends Controller
         $new = View::firstOrNew($param);
         $new->user_ip = $clientIp;
         $new->save();
-
-        return $this->ok($new);
+        $count = View::where("target_id",$new->target_id)->count();
+        return $this->ok($count);
     }
 
     /**

+ 22 - 0
public/app/article/article.js

@@ -362,6 +362,23 @@ function gotoArticle(articleId) {
 	location.assign(url);
 }
 
+function OneHitChapter(book,para,channel){
+    fetch('/api/v2/view',{
+        method: 'POST',
+        credentials: 'include',
+        headers: {
+            'Content-Type': 'application/json'
+        },
+        body: JSON.stringify({
+            target_type:'chapter',
+            book:book,
+            para:para,
+            channel:channel
+        })
+    })
+  .then(response => response.json())
+  .then(data => console.log(data));
+}
 
 function palicanon_load() {
 	let param;
@@ -376,6 +393,11 @@ function palicanon_load() {
 				start: _start,
 				end: _end,
 			}
+            if(_channal !==""){
+                for (const iterator of _channal.split(",")) {
+                    OneHitChapter(_book,_par,iterator);
+                }
+            }
 			break;
 		case "simsent":
 		case "sim":

+ 45 - 11
public/app/palicanon/index1.php

@@ -34,20 +34,14 @@ require_once '../public/function.php';
     margin-left: 0;
 }
 .head_bar{
-    display:flex;
-    max-width: 30vh;
+    display: flex;
+    flex-direction: column;
 }
 #left-bar{
     flex: 2;
     background-color: var(--box-bg-color2);
 }
-.more_info{
-    font-size:80%;
-    color: var(--main-color1);
-}
-.more_info>.item{
-    margin-right:1em;
-}
+
 .chapter_list ul li{
     display:flex;
 }
@@ -77,10 +71,22 @@ require_once '../public/function.php';
     max-height: unset;
     overflow-y: unset; 
 }
-.chapter_list .more_info {
-    display: block;
+
+.chapter_list .more_info{
+    display:flex;
+    font-size:80%;
+    color: var(--main-color1);
+    justify-content: space-between;
 }
 
+
+}
+.more_info>.palicanon_chapter_info>.item{
+    margin-right:1em;
+}
+.left_item>.item{
+    margin-right:1em;
+}
 .filter>.inner {
     max-height: 200px;
     overflow-y: auto;
@@ -123,6 +129,34 @@ select#tag_category_index option {
 button.active {
     background-color: gray;
 }
+
+.chapter_list ul li>.left{
+    width: 100px;
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+}
+.chapter_list ul li>.right{
+    width:100%;
+}
+.chapter_tag {
+    width: 475px;
+    padding: 5px 0;
+    overflow-y: visible;
+    overflow-x: auto;
+    display: flex;
+    flex-wrap: wrap;
+}
+.left_item {
+    margin: 4px 0;
+}
+.left_item>.item>.small_icon{
+    width:16px;
+    height:16px;
+}
+.left_item>.item>.text{
+    padding:5px;
+}
 </style>
 
 <?php

+ 181 - 67
public/app/palicanon/palicanon.js

@@ -141,8 +141,12 @@ function communityGetChapter(strTags="",lang="",offset=0){
                     trans_title:iterator.title,
                     channel_id:iterator.channel_id,
                     type:'article',
-                    channel_info:iterator.channel_info,
-                    path:JSON.parse(iterator.path)
+                    channel_info:iterator.channel,
+                    path:JSON.parse(iterator.path),
+                    views:iterator.views,
+                    tags:iterator.tags,
+                    summary:iterator.summary,
+                    created_at:iterator.created_at
                 });
             }
 			for (const iterator of arrChapterList) {
@@ -424,19 +428,20 @@ function palicanon_chapter_list_apply(div_index) {
 }
 
 function chapter_onclick(obj) {
-	let book = $(obj).attr("book");
-	let para = $(obj).attr("para");
-	let channel = $(obj).attr("channel");
-	let type = $(obj).attr("type");
-	let level =  parseInt($(obj).parent().attr("level"));
-    let title1 = $(obj).find(".title_1").first().text();
+    let objList = $(obj).parent().parent().parent();
+	let book = $(objList).attr("book");
+	let para = $(objList).attr("para");
+	let channel = $(objList).attr("channel");
+	let type = $(objList).attr("type");
+	let level =  parseInt($(objList).parent().attr("level"));
+    let title1 = $(objList).find(".title_1").first().text();
     if(type=='article'){
         window.open("../article/index.php?view=chapter&book="+book+"&par="+para+"&channel="+channel,);
     }else{
         gBreadCrumbs[level] = {title1:title1,book:book,para:para,level:level};
         RenderBreadCrumbs();
-        $(obj).siblings().removeClass("selected");
-        $(obj).addClass("selected");
+        $(objList).siblings().removeClass("selected");
+        $(objList).addClass("selected");
         $("#tag_list").slideUp();
         palicanon_load_chapter(book, para, level);
     }
@@ -446,6 +451,27 @@ function close_tag_list(){
     $("#tag_list").slideUp();
     $("#btn-filter").removeClass("active");
 
+}
+function renderProgress(progress=0,width=16,height=16){
+        //绘制进度圈
+    
+
+		let r = 12;
+		let perimeter = 2 * Math.PI * r;
+		let stroke1 = parseInt(perimeter * progress);
+		let stroke2 = perimeter - stroke1;
+        let html="";
+		html += '<svg class="progress_circle" width="16" height="16" viewbox="0,0,30,30">';
+		html += '<circle class="progress_bg" cx="15" cy="15" r="12" stroke-width="5"  fill="none"></circle>';
+		html +=
+			'<circle class="progress_color" cx="15" cy="15" r="12" stroke-width="5" fill="none"  stroke-dasharray="' +
+			stroke1 +
+			" " +
+			stroke2 +
+			'"></circle>';
+		html += "</svg>";
+    return html;
+    
 }
 function palicanon_render_chapter_row(chapter) {
 	let html = "";
@@ -457,26 +483,88 @@ function palicanon_render_chapter_row(chapter) {
     if(typeof chapter.type !== "undefined" && chapter.type==='article'){
         html += ' channel="' + chapter.channel_id + '" type="' + chapter.type + '"';
     }
-    html += ' onclick="chapter_onclick(this)">';
+    html += ' >';
     
-	html += '<div class="head_bar">';
+	html += '<div class="left">';
 
-    html += '<span class="" style="margin-right: 1em;padding: 4px 0;">';
-    html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
-    if(typeof chapter.type !== "undefined" && chapter.type==='article'){
-        html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journal-text'>";
+    html += "<div class='left_items'>";
+
+    html += "<div class='left_item'>";
+
+    html += "<span class='item'>";
+    html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
+    html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#eye'>";
+    html += "</svg>" ;
+    html += "<span class='text'>";
+    if(chapter.views){
+        html += chapter.views;
     }else{
-        if (chapter.level == 1) {
-            html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journal'>";
-        }else{
-            html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#folder2-open'>";
-        }
+        html += "0";
     }
+    html += "</span>";
+    html += "</span>";
 
+    html += "</div>"
+
+    html += "<div class='left_item'>";
+    html += "<span class='item'>";
+    html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
+    html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#heart'>";
+    html += "</svg>" ;
+    html += "<span class='text'>";
+    if(chapter.likes){
+        html += chapter.likes;
+    }else{
+        html += "0";
+    }
+    html += "</span>";
+    html += "</span>";
+    html += "</div>"
+
+    //完成度
+    html += "<div class='left_item'>";
+	html += "<span class='item'>";
+    html += renderProgress(chapter.progress.all_trans);
+    /*
+    html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
+	html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#translate'>";
 	html += "</svg>" ;
-	html += "</span>";   
+    */
+    html += "<span class='text'>";
+    if(chapter.progress){
+        html += parseInt(chapter.progress.all_trans*100+1)+"%";
+    }else{
+         html += "无";
+    }
+    html += "</span>";
+    html += "</span>";
+    html += "</div>"
 
-	html += '<div class="title">';
+    html += "<div class='left_item'></div>"
+    html += "</div>";//end of left_items
+
+    html += "<div class='chapter_icon'>";
+        html += '<span class="" style="margin-right: 1em;padding: 4px 0;">';
+        html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
+        if(typeof chapter.type !== "undefined" && chapter.type==='article'){
+            html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journal-text'>";
+        }else{
+            if (chapter.level == 1) {
+                html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journal'>";
+            }else{
+                html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#folder2-open'>";
+            }
+        }
+        html += "</svg>" ;
+        html += "</span>";
+    html += "</div>";
+	html += '</div>';//end of left
+
+	html += '<div class="right">';
+
+	html += '<div class="head_bar">';
+
+	html += '<div class="title" onclick="chapter_onclick(this)">';
 
     
     let sPaliTitle = chapter.title;
@@ -502,69 +590,76 @@ function palicanon_render_chapter_row(chapter) {
 		html += "	<div class='title_1'>" + chapter.trans_title + "</div>";
 	}
 
-	html += '	<div class="title_2" lang="pali">' + sPaliTitle + "</div>";
-	html += "</div>";
-	html += '<div class="resource">';
-    //绘制进度圈
-    /*
-	if (chapter.progress) {
-		let r = 12;
-		let perimeter = 2 * Math.PI * r;
-		let stroke1 = parseInt(perimeter * chapter.progress.all_trans);
-		let stroke2 = perimeter - stroke1;
-		html += '<svg class="progress_circle" width="30" height="30" viewbox="0,0,30,30">';
-		html += '<circle class="progress_bg" cx="15" cy="15" r="12" stroke-width="5"  fill="none"></circle>';
-		html +=
-			'<circle class="progress_color" cx="15" cy="15" r="12" stroke-width="5" fill="none"  stroke-dasharray="' +
-			stroke1 +
-			" " +
-			stroke2 +
-			'"></circle>';
-		html += "</svg>";
-	}
-    */
-	html += "</div>";
-	html += "</div>";//end of head bar
-
-
-    html += '<div class="more_info">';
-
-    html += "<span class='item'>";
+	html += '<div class="title_2" lang="pali">' + sPaliTitle + "</div>";
+	html += '<div class="title_2" lang="pali">';
+//书名
     if(chapter.path){
+        html += "<span class='item'>";        
         html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
         html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#journals'>";        
         html += "</svg>" ;
         html += chapter.path[0].title;
+        html += "</span>";        
     }
-    html += "</span>"
-    
-	html += "<span class='item'>";
-    html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
-	html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#translate'>";
-	html += "</svg>" ;
-    if(chapter.progress){
-        html += parseInt(chapter.progress.all_trans*100+1)+"%";
-    }else{
-         html += "无";
+    html +=  "</div>";
+	html += "</div>";
+	html += '<div class="resource">';
+    if(chapter.summary){
+        html += chapter.summary;
+    }
+
+	html += "</div>";
+
+    html += '<div class="more_info">';
+    //最下面一栏,左侧的标签列表
+    html += "<div class='chapter_tag'>";
+
+
+    if(chapter.tags){
+        html += renderChapterTags(chapter.tags);
     }
     
-    html += "</span>";
+    html += "</div>";
+    html += "<div class='palicanon_chapter_info'>"
+
 
 	html += "<span class='item'>";
-    html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
-	html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#person'>";
+    html += "<svg class='small_icon' style='width:16px;height:16px;fill: var(--box-bg-color1)'>";
+	html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#person-circle'>";
 	html += "</svg>" ;
+	html += "<span class='text'>";
+
     if(typeof chapter.type !== "undefined" && chapter.type==='article'){
         html += chapter.channel_info.name;
     }else{
-        html += "简体中文(3)";
+        html += "EN(3)";
     }
-    
     html += "</span>";
+    html += "</span>";
+
+    if(chapter.created_at){
+        let time = new Date(chapter.created_at);
+        html += "<span class='item'>";
+        html += "<svg class='small_icon' style='width:16px;height:16px;fill: var(--box-bg-color1)'>";
+        html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#clock'>";
+        html += "</svg>" ;
+        html += "<span class='text'>";
+        html += getPassDataTime(time);
+        html += "</span>";
+        html += "</span>";
+        html += "</div>";
+        html += "</div>";    
+    }
+
+
+
+	html += "</div>";//end of head bar
+
 
 
 
 	html += "</div>";
+
 	html += "</li>";
 	return html;
 }
@@ -632,11 +727,30 @@ function tag_click(tag) {
 }
 
 function tag_set(tag) {
-	list_tag = tag;
+    if(Array.isArray(tag)){
+        list_tag = tag;
+    }else{
+        list_tag = [tag];
+    }
+	
 	render_tag_list();
 	tag_changed();
 }
 
+function renderChapterTags(tags){
+    let html = "";
+    for (const iterator of tags) {
+		html += '<tag onclick="tag_set(\''+iterator.name+'\')">';
+        html += "<svg class='small_icon' style='fill: var(--box-bg-color1)'>";
+        html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#tag'>";
+        html += "</svg>" 
+        html += '<span class="textt" title="' + iterator.name + '">' + tag_get_local_word(iterator.name) + "</span>";
+		//html += '<span class="tag-delete" onclick ="tag_remove(\'' + iterator + "')\">✕</span>";
+        html += "</tag>";
+	}
+    return html;
+}
+
 function render_tag_list() {
 	//$("#tag_list").slideDown();
 

+ 20 - 11
public/app/palicanon/style.css

@@ -38,9 +38,11 @@ tag {
 	margin: 2px;
 	padding: 2px 12px;
 	border-radius: 5px;
-	border: 1px solid #fe897c;
+    cursor: pointer;
+}
+tag:hover{
+    background-color: var(--border-line-color);
 }
-
 .tag-delete {
 	margin-left: 6px;
 	color: #f93e3e;
@@ -154,9 +156,6 @@ tag {
 	display: none;
 }
 .chapter_list ul {
-	background-color: antiquewhite;
-	border-left: 1px solid brown;
-	border-right: 1px solid brown;
 	padding: 0;
 }
 .chapter_list ul li {
@@ -165,21 +164,31 @@ tag {
 	padding: 8px;
 	white-space: nowrap;
 	overflow-x: hidden;
+    border-bottom: 1px solid var(--border-line-color);
 }
 .chapter_list ul li:hover {
-	background-color: darkorange;
-	cursor: pointer;
+	/*background-color: darkorange;*/
+	/*cursor: pointer;*/
 }
 .chapter_list .resource {
-	display: flex;
-	margin-top: auto;
-	margin-bottom: auto;
+
+    margin-top: auto;
+    margin-bottom: auto;
+    white-space: pre-wrap;
+    display: -webkit-box;
+    -webkit-box-orient: vertical;
+    -webkit-line-clamp: 3;
+    overflow: hidden;
 }
 .chapter_list .title .title_1 {
-	color: var(--main-color);
+	color: var(--link-color);
 	font-weight: 700;
 	font-size: 110%;
 }
+.chapter_list .title .title_1:hover {
+	color: var(--link-hover-color);
+	cursor: pointer;
+}
 .chapter_list .title .title_2 {
 	font-size: 80%;
 	color: var(--main-color1);