添加文章完整查看

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]); View::renderTemplate("/blog/basic.html",['docs'=>$docs,'index'=>true]);
} }
function articleAction(){ function articleAction(){
View::renderTemplate("/blog/basic.html",['title'=>'test','index'=>false]); if(sizeof($this->querys) != 0){
//print_r($this->query_string); 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(){ function jsAction(){
print_r($_SERVER); //print_r($_SERVER);
} }
} }

View File

@ -62,4 +62,11 @@ class Doc extends Model
return $recv; 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%} {%else%}
<div style="width: 670px; height: 100%; border-bottom: #0b58a2 solid 1px ;margin: 5px 5px 5px 5px;"> <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;"> <p style="display: block;font-size: 16px;text-align: center;">
测试 {{ title }}
</p> </p>
<div style="width: 670px;height: 800px; display: block;font-size: 10px;text-align: left;"> <div style="width: 670px;height: 800px; display: block;font-size: 10px;text-align: left;">
发送到发的说法 {{ content | raw}}
</div> </div>
</div> </div>
{% endif %} {% endif %}

View File

@ -35,7 +35,7 @@ ul.navMenu{
} }
.subMenu>li>a { .subMenu>li>a {
text-align: center; text-align: left;
display: block; display: block;
line-height: 36px; line-height: 36px;
font-size: 10px; font-size: 10px;
@ -45,7 +45,6 @@ ul.navMenu{
ul.subMenu { ul.subMenu {
margin-top: 8px; margin-top: 8px;
margin-left: 10px;
padding-bottom: 5px; padding-bottom: 5px;
width: 130px; width: 130px;

View File

@ -74,20 +74,8 @@ $(document).ready(
// 注册回调s // 注册回调s
// console.log("#type_id_0 li a #" + rand); // console.log("#type_id_0 li a #" + rand);
$("#" + rand).on("click",(function () { $("#" + 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).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); preg_match("/^.{0,}\?(.{0,})$/i", $_SERVER['REQUEST_URI'], $matches);
if(sizeof($matches) > 0){ if(sizeof($matches) > 0){
$pieces = explode("=", $matches['1']); $pieces = explode("=", $matches['1']);
print_r(sizeof($pieces));
for ($i = 0;$i < sizeof($pieces) /2 ;$i++){ for ($i = 0;$i < sizeof($pieces) /2 ;$i++){
print $i;
$this->querys[$pieces[2*$i]] = $pieces[2*$i + 1]; $this->querys[$pieces[2*$i]] = $pieces[2*$i + 1];
} }
} }

View File

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