diff --git a/App/Controllers/Blog.php b/App/Controllers/Blog.php index 994989e..b9586cb 100644 --- a/App/Controllers/Blog.php +++ b/App/Controllers/Blog.php @@ -26,10 +26,22 @@ class Blog extends Controller View::renderTemplate("/blog/basic.html",['docs'=>$docs,'index'=>true]); } function articleAction(){ - View::renderTemplate("/blog/basic.html",['title'=>'test','index'=>false]); - //print_r($this->query_string); + if(sizeof($this->querys) != 0){ + echo '
';
+            print_r($this->querys['title']);
+            $docModel = new Models\Doc();
+            $doc = $docModel->titleDoc($this->querys['title']);
+            $markdown = new Parsedown;
+            $content = $markdown->text($doc[0]['content']);
+            echo  '
'; + View::renderTemplate("/blog/basic.html",['title'=>$this->querys['title'], + 'index'=>false, + 'content'=>$content]); + }else{ + View::renderTemplate("/blog/basic.html",['title'=>'test','index'=>false]); + } } function jsAction(){ - print_r($_SERVER); + //print_r($_SERVER); } } \ No newline at end of file diff --git a/App/Models/Doc.php b/App/Models/Doc.php index b9271c0..fae3a91 100644 --- a/App/Models/Doc.php +++ b/App/Models/Doc.php @@ -62,4 +62,11 @@ class Doc extends Model return $recv; } } + public function titleDoc($title){ + $db = static::getDB(); + $stmt = $db->query('select * from doc where title = \''.$title.'\''); + $recv = $stmt->fetchAll(); + return $recv; + } } + diff --git a/App/Views/blog/basic.html b/App/Views/blog/basic.html index 61bb0da..6cfb34b 100644 --- a/App/Views/blog/basic.html +++ b/App/Views/blog/basic.html @@ -135,10 +135,10 @@ {%else%}

- 测试 + {{ title }}

- 发送到发的说法 + {{ content | raw}}
{% endif %} diff --git a/App/Views/blog/css/left.css b/App/Views/blog/css/left.css index e8b1439..3c12b66 100644 --- a/App/Views/blog/css/left.css +++ b/App/Views/blog/css/left.css @@ -35,7 +35,7 @@ ul.navMenu{ } .subMenu>li>a { - text-align: center; + text-align: left; display: block; line-height: 36px; font-size: 10px; @@ -45,7 +45,6 @@ ul.navMenu{ ul.subMenu { margin-top: 8px; - margin-left: 10px; padding-bottom: 5px; width: 130px; diff --git a/App/Views/blog/js/scripts.js b/App/Views/blog/js/scripts.js index 30bf021..fc4a708 100644 --- a/App/Views/blog/js/scripts.js +++ b/App/Views/blog/js/scripts.js @@ -74,20 +74,8 @@ $(document).ready( // 注册回调s // console.log("#type_id_0 li a #" + rand); $("#" + rand).on("click",(function () { - $.ajax({ - method: "GET", - url: "http://127.0.0.1/api/public/Blog/article?title=" + rand, - async: false, - dataType: "json", - beforeSend: function (xhr) { - - }, - success:function(data){ - console.log(data); - } - }); console.log($("#" + rand).html()); - console.log(rand); + $(location).attr('href', "http://127.0.0.1/api/public/Blog/article?title=" + $("#" + rand).html()); })); }) diff --git a/Core/Controller.php b/Core/Controller.php index c515351..cfe4255 100644 --- a/Core/Controller.php +++ b/Core/Controller.php @@ -39,9 +39,7 @@ abstract class Controller preg_match("/^.{0,}\?(.{0,})$/i", $_SERVER['REQUEST_URI'], $matches); if(sizeof($matches) > 0){ $pieces = explode("=", $matches['1']); - print_r(sizeof($pieces)); for ($i = 0;$i < sizeof($pieces) /2 ;$i++){ - print $i; $this->querys[$pieces[2*$i]] = $pieces[2*$i + 1]; } } diff --git a/public/index.php b/public/index.php index effdfbc..bf46763 100644 --- a/public/index.php +++ b/public/index.php @@ -35,7 +35,6 @@ try{ print ""; return; }else{ - $router->dispatch($_SERVER['REQUEST_URI']); } }catch (Exception $exception){