Explorar el Código

Merge pull request #501 from visuddhinanda/master

文集首页增加目录
visuddhinanda hace 4 años
padre
commit
5d8f694b58
Se han modificado 11 ficheros con 126 adiciones y 61 borrados
  1. 1 1
      .gitignore
  2. 21 3
      app/article/article.js
  3. 21 7
      app/article/index.php
  4. 6 7
      app/collect/index.js
  5. 21 0
      app/config.sample.php
  6. 0 38
      app/day-5.json
  7. 32 0
      app/db/database.php
  8. 16 0
      app/db/test.php
  9. 2 0
      app/path.php
  10. 4 4
      app/ucenter/invite.php
  11. 2 1
      composer.json

+ 1 - 1
.gitignore

@@ -14,7 +14,7 @@
 /yarn.lock
 /composer.lock
 /app/phpinfo.php
-
+/app/config.php
 # dependencies
 /vendor/
 /node_modules/

+ 21 - 3
app/article/article.js

@@ -1,3 +1,5 @@
+//import {Like,LikeRefresh} from '../widget/like.js';
+var _view = "";
 var _articel_id = "";
 var _channal = "";
 var _lang = "";
@@ -65,10 +67,17 @@ function collect_load(id) {
 							$("#article_subtitle").html(result.subtitle);
 						}
 						$("#article_author").html(result.username.nickname + "@" + result.username.username);
-						$("#contents").html(marked(result.summary));
+						$("#like_div").html("<like restype='collection' resid='"+id+"'></like>");
+						$("#summary").html(result.summary);
+						$("#contents").html("<div id='content_text'></div><h3>目录</h3><div id='content_toc'></div>");
 
 						let article_list = JSON.parse(result.article_list);
 						render_article_list(article_list);
+						render_article_list_in_content(article_list);
+						$("#content_toc").fancytree("getRootNode").visit(function(node){
+							node.setExpanded(true);
+						  });
+						Like();
 					}
 				} catch (e) {
 					console.error(e);
@@ -94,7 +103,6 @@ function articel_load_article_list(articleId,collectionId) {
 					if (result) {
 						let article_list = JSON.parse(result.article_list);
 						render_article_list(article_list,collectionId,articleId);
-
 						let strTitle = "<a href='../article/?collection=" + result.id + "'>" + result.title + "</a> / ";
 						for (const iterator of tocActivePath) {
 							strTitle += "<a href='../article/?id="+iterator.key+"&collection=" + result.id + "'>" + iterator.title + "</a> / ";
@@ -122,7 +130,17 @@ function render_article_list(article_list,collectId="",articleId="") {
 		}
 	});
 }
-
+//在 正文中的目录
+function render_article_list_in_content(article_list,collectId="",articleId="") {
+	$("#content_toc").fancytree({
+		autoScroll: true,
+		source: tocGetTreeData(article_list,articleId),
+		activate: function(e, data) {
+			gotoArticle(data.node.key,collectId);
+			return false;
+		}
+	});
+}
 function set_channal(channalid) {
 	let url = "../article/index.php?id=" + _articel_id;
 	if (_collection_id != "") {

+ 21 - 7
app/article/index.php

@@ -6,8 +6,9 @@ require_once "../pcdl/html_head.php";
 <body style="margin: 0;padding: 0;" class="reader_body" >
 
 
-	<script src="./article.js"></script>
+	<script  src="./article.js"></script>
 
+	<script src="../widget/like.js"></script>
 	<script src="../widget/click_dropdown.js"></script>
 	<link type="text/css" rel="stylesheet" href="../widget/click_dropdown.css"/>
 
@@ -110,7 +111,7 @@ require_once "../pcdl/html_head.php";
 <script src="../article/my_collect.js" type="text/javascript"></script>
 
 <style>
-#toc_content ul.fancytree-container{
+ul.fancytree-container{
 	border:unset;
 }
 .fancytree-container .active {
@@ -129,6 +130,14 @@ span.fancytree-node{
 	max-height: 25vw;
     width: max-content;
 }
+like{
+    min-width: 40px;
+    border: 1px solid var(--border-line-color);
+    display: inline-block;
+    border-radius: 5px;
+    margin: 5px;
+    cursor: pointer;
+}
 </style>
 
 <?php
@@ -165,15 +174,20 @@ span.fancytree-node{
 </div>
 <div id="main_view" class="main_view">
 <div id="article_head" style="border-bottom: 1px solid gray;">
-	<div id="article_title" class="term_word_head_pali"><?php echo $_local->gui->title; ?></div>
-	<div id="article_subtitle"><?php echo $_local->gui->sub_title; ?></div>
-	<div id="article_author"><?php echo $_local->gui->author; ?></div>
+	<div id="article_title" class="term_word_head_pali"></div>
+	<div id="article_subtitle"></div>
+	<div id="article_author"></div>
+	<div id="like_div">
+		<like restype='article' resid='124'></like>
+		<watch restype='article' resid='124'></watch>
+	</div>
 </div>
+
 <div id="contents_view">
 	<div id="contents_div">
-	
+		<div id="summary"></div>
 		<div id="contents" class="<?php echo $contentClass;?>">
-		<?php echo $_local->gui->loading; ?>...
+			<?php echo $_local->gui->loading; ?>...
 		</div>
 		<div id="contents_foot">
 			<div id="contents_nav" style="display:flex;justify-content: space-between;">

+ 6 - 7
app/collect/index.js

@@ -18,7 +18,7 @@ function collect_load(begin = 0) {
                     html += "<div class='subtitle'>" + iterator.subtitle + "</div>";
                 }
                 if (iterator.summary && iterator.summary != "null") {
-                    html += "<div class='summary'>" + iterator.summary + "</div>";
+                    html += "<div class='summary'>" + marked(iterator.summary) + "</div>";
                 }
                 if (iterator.tag) {
                     html += "<div style='overflow-wrap: anywhere;'>" + iterator.tag + "</div>";
@@ -39,12 +39,11 @@ function collect_load(begin = 0) {
                 html += "<div>";
                 for (const article of article_list) {
                     html += "<div style='padding:6px 0; border-top: #707070 1px solid;'>";
-                    html +=
-                        "<a class='article_title' style='color:var(--main_color);font-weight:700;' href='../article/?id=" +
-                        article.article +
-                        "' target='_blank'>" +
-                        article.title +
-                        "</a>";
+                    html += "<a class='article_title'";
+					html +=" style='color:var(--main_color);font-weight:700;'";
+					html +=" href='../article/?id=" + article.article +"&collection="+iterator.id+"' target='_blank'>" ;
+					html += article.title ;
+					html += "</a>";
                     html += "</div>";
                     article_count++;
                     if (article_count > article_limit) {

+ 21 - 0
app/config.sample.php

@@ -0,0 +1,21 @@
+<?php 
+// Require Composer's autoloader.
+require_once '../../vendor/autoload.php';
+
+// Require Composer's autoloader.
+use PHPMailer\PHPMailer\PHPMailer;
+use PHPMailer\PHPMailer\SMTP;
+use PHPMailer\PHPMailer\Exception;
+
+define("Email", ["SMTPDebug"=>SMTP::DEBUG_SERVER,//Enable verbose debug output
+				 "Host"=>"smtp.gmail.com",//Set the SMTP server to send through
+				 "SMTPAuth"=>true,//Enable SMTP authentication
+				 "Username"=>'your@gmail.com',//SMTP username
+				 "Password"=>'your_password',//SMTP password
+				 "SMTPSecure"=>PHPMailer::ENCRYPTION_SMTPS,//Enable implicit TLS encryption
+				 "Port"=>465,//TCP port to connect to 465; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
+				 "From"=>"your@gmail.com",
+				 "Sender"=>"sender"
+				 ]);
+
+?>

+ 0 - 38
app/day-5.json

@@ -1,38 +0,0 @@
-[
-  {
-    "key": "1",
-    "name": "name1",
-    "age": 32,
-    "adress": "西湖南路"
-  },
-  {
-    "key": "2",
-    "name": "name2",
-    "age": 34,
-    "adress": "西湖公园"
-  },
-  {
-    "key": "3",
-    "name": "name1",
-    "age": 32,
-    "adress": "西湖南路"
-  },
-  {
-    "key": "4",
-    "name": "name2",
-    "age": 34,
-    "adress": "西湖公园"
-  },
-  {
-    "key": "5",
-    "name": "name1",
-    "age": 32,
-    "adress": "西湖南路"
-  },
-  {
-    "key": "6",
-    "name": "name2",
-    "age": 34,
-    "adress": "西湖公园"
-  }
-]

+ 32 - 0
app/db/database.php

@@ -0,0 +1,32 @@
+// config/database.php
+
+// database connection file
+
+<?php
+class Database
+{
+    // specify your own database credentials
+    private $host = '127.0.0.1';
+    private $db_name = 'eloquent';
+    private $username = 'root';
+    private $password = 'password';
+	
+    public $conn;
+	
+	// public function __construct() {
+    // }
+	
+    public function EloquentConnection()
+    {
+        return [
+            'driver' => 'mysql',
+            'host' => $this->host,
+            'database' => $this->db_name,
+            'username' => $this->username,
+            'password' => $this->password,
+            'charset' => 'utf8',
+            'collation' => 'utf8_unicode_ci',
+            'prefix' => '',
+        ];
+    }
+}

+ 16 - 0
app/db/test.php

@@ -0,0 +1,16 @@
+<?php
+require "../vendor/autoload.php";
+require "../config/database.php";
+use Illuminate\Database\Capsule\Manager as Capsule;
+
+$dbclass = new Database();
+$capsule = new Capsule();
+$capsule->addConnection($dbclass->EloquentConnection());
+
+// Make this Capsule instance available globally via static methods
+$capsule->setAsGlobal();
+// Setup the Eloquent ORM
+$capsule->bootEloquent();
+
+
+$users = Capsule::table('user')->where('id', '=', 1)->get();

+ 2 - 0
app/path.php

@@ -173,6 +173,8 @@ define("_FILE_DB_USER_CUSTOM_BOOK_", "sqlite:" . __DIR__ . "/../tmp/user/custom_
 # 逐词译和译文编辑消息
 define("_FILE_DB_MESSAGE_", "sqlite:" . __DIR__ . "/../tmp/user/message.db");
 
+define("_FILE_DB_LIKE_", "sqlite:" . __DIR__ . "/../tmp/user/like.db3");
+
 
 
 //很少使用

+ 4 - 4
app/ucenter/invite.php

@@ -40,14 +40,14 @@ if (PHP_SAPI == "cli") {
 				}
 			}
 			fclose($fp);
-			echo "body load";
+			echo "body loaded \n";
 		}
 		else{
-			echo "can not load body file. ";
+			echo "can not load body file. \n";
 		}
 
-		$strBody = str_replace("%SignUpLink%",$SignUpLink,$body);
-		$strBody = str_replace("%SignUpString%",$SignUpString,$body);
+		$strBody = str_replace("%SignUpLink%",$SignUpLink,$strBody);
+		$strBody = str_replace("%SignUpString%",$SignUpString,$strBody);
 
 		//TODO sendmail
 

+ 2 - 1
composer.json

@@ -4,6 +4,7 @@
 		"guzzlehttp/guzzle": "7.0",
 		"catfan/medoo": "^2.1",
 		"casbin/casbin": "^3.9",
-		"phpmailer/phpmailer": "^6.5"
+		"phpmailer/phpmailer": "^6.5",
+		"illuminate/database": "^8.59"
 	}
 }