添加文章完整查看

deploy
caiyuzheng 2019-08-29 16:12:59 +08:00
parent 2f2dba60bc
commit 8bb9af10e1
7 changed files with 26 additions and 23 deletions

View File

@ -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 '<pre>';
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 '</pre>';
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);
}
}

View File

@ -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;
}
}

View File

@ -135,10 +135,10 @@
{%else%}
<div style="width: 670px; height: 100%; border-bottom: #0b58a2 solid 1px ;margin: 5px 5px 5px 5px;">
<p style="display: block;font-size: 16px;text-align: center;">
测试
{{ title }}
</p>
<div style="width: 670px;height: 800px; display: block;font-size: 10px;text-align: left;">
发送到发的说法
{{ content | raw}}
</div>
</div>
{% endif %}

View File

@ -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;

View File

@ -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());
}));
})

View File

@ -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];
}
}

View File

@ -35,7 +35,6 @@ try{
print "";
return;
}else{
$router->dispatch($_SERVER['REQUEST_URI']);
}
}catch (Exception $exception){