huwhois 3 vuotta sitten
vanhempi
commit
9903b64da5

+ 2 - 2
app/common/model/Article.php

@@ -83,7 +83,7 @@ class Article extends Base
         $limit = empty($params['limit']) ? 20 : (int)$params['limit'];
 
         $list = self::where($where)
-            ->field('id,cid,title,titlepic,username,hits,sorts,status,create_time')
+            ->field('id,cid,title,titlepic,username,summary,hits,sorts,status,create_time')
             ->with(['category'])
             ->order('id desc')->paginate($limit, false, ['query' => $params]);
 
@@ -105,7 +105,7 @@ class Article extends Base
         $order = !empty($order) ? array_merge($order, ['id' => 'desc']) : ['id' => 'desc'];
 
         return self::where($where)
-            ->field('id,cid,title,titlepic,username,hits,sorts,status,create_time')
+            ->field('id,cid,title,titlepic,username,summary,hits,sorts,status,create_time')
             ->order($order)->limit($limit)->select();
     }
 

+ 9 - 0
app/index/config/view.php

@@ -0,0 +1,9 @@
+<?php
+// +----------------------------------------------------------------------
+// | 模板设置
+// +----------------------------------------------------------------------
+
+return [
+    // 开启模板布局
+    'layout_on'    => true,
+];

+ 120 - 0
app/index/controller/Article.php

@@ -0,0 +1,120 @@
+<?php
+declare (strict_types = 1);
+/**
+ * +----------------------------------------------------------------------
+ * 文章控制制器
+ * @author huwhis@163.com
+ * @version   0.0.6
+ * +----------------------------------------------------------------------
+ */
+namespace app\index\controller;
+
+// 引入框架内置类
+use think\facade\View;
+
+use app\common\model\Category as CategoryModel;
+use app\common\model\Article as ArticleModel;
+use app\common\model\ArticleTags as ArticleTagsModel;
+use think\exception\HttpException;
+
+/**
+ * 文章管理  
+
+ */
+class Article extends Base
+{
+    protected $modelName = "Article";
+
+    public function index()
+    {   
+        $params = $this->app->request->param();
+
+        $list = ArticleModel::queryPage($params);
+        
+        $baseUrl = $this->request->baseUrl();
+
+        View::assign([
+            'baseUrl'  => $baseUrl,
+            'list' => $list->all(),
+            'total' => $list->total(),
+            'limit' => $list->listRows(),
+            'page' => $list->currentPage(),
+            'lastPage' => $list->lastPage(),
+            'pagelist' => $list->render()
+        ]);
+
+        return View::fetch();
+    }
+
+    /**
+     * 阅读文章
+     */
+    public function read($id=null)
+    {
+        $data = ArticleModel::getOne($id);
+
+        if (!$data) {
+            throw new HttpException(404, '页面不存在');
+        }
+
+        $data->hits += 1;
+
+        $data->save();
+
+        $prev_next = ArticleModel::getNextPrev($id, $data->cid);
+
+        View::assign('cid', $data->cid);
+        View::assign('data', $data);
+        View::assign('prev_next', $prev_next);
+
+        return View::fetch();
+    }
+
+    /**
+     * 文章点赞
+     */
+    public function dolike()
+    {
+        $id = input('post.id');
+
+        $res = ArticleModel::where('id', $id)->inc('likes')->update();
+
+        if ($res===false) {
+            return ['code' => 2];
+        } else {
+            return ['code' => 0, 'msg'=>'未知错误'];
+        }
+    }
+
+    /**
+     * 标签列表
+     */
+    public function tags($name=null)
+    {
+        if (!$name) {
+            throw new HttpException(404, '标签不可为空');
+        }
+
+        $list = ArticleTagsModel::tagsList($name);
+
+        View::assign([
+            'list' => $list,
+            'tag'  => $name
+        ]);
+
+        return View::fetch();
+    }
+
+    /**
+     * 时光轴
+     */
+    public function time()
+    {
+        $list =ArticleModel::field('id,cid,title,titlepic,username,summary,hits,sorts,status,create_time')->with(['category'])->order('update_time desc')->paginate();
+
+        View::assign('list', $list);
+
+        return View::fetch();
+    }
+    
+}

+ 77 - 0
app/index/controller/Base.php

@@ -0,0 +1,77 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @file   Index.php
+ * @date   2019-02-27 14:49:36
+ * @author huwhis<huuwhois>
+ * @version   0.0.6
+ */
+
+namespace app\index\controller;
+
+use think\facade\View;
+use think\App;
+
+use app\common\model\Article;
+use app\common\model\Category;
+
+abstract class Base
+{
+    /**
+     * Request实例
+     * @var \think\Request
+     */
+    protected $request;
+
+    /**
+     * 应用实例
+     * @var \think\App
+     */
+    protected $app;
+
+    /**
+     * 构造方法
+     * @access public
+     * @param App $app 应用对象
+     */
+    public function __construct(App $app)
+    {
+        $this->app     = $app;
+        $this->request = $this->app->request;
+
+        // 控制器初始化
+        $this->initialize();
+    }
+
+    // 初始化
+    protected function initialize()
+    {
+        // 菜单
+        $categories = Category::where('is_nav', 1)->order(['sort desc'])->select();
+
+        View::assign('categories', $categories);
+
+        if ($this->request->has('_aside')==false) {
+            $this->aside();
+        }
+    }
+
+    /**
+     * 侧边栏
+     */
+    protected function aside()
+    {
+        $cate_lists = Category::where('template', 'article')->select();
+
+        $hits_lists = Article::getListByCid(0, 9, ['hits' => 'desc']);
+
+        $top_lists = Article::getTop(7);
+
+        View::assign([
+            'cate_lists' => $cate_lists,
+            'hits_lists'  => $hits_lists,
+            'top_lists'  => $top_lists
+        ]);
+    }
+}

+ 85 - 6
app/index/controller/Index.php

@@ -1,17 +1,96 @@
 <?php
-namespace app\controller;
+declare(strict_types=1);
+/**
+ * @file   Index.php
+ * @date   2019-02-27 14:49:36
+ * @author huwhis<huuwhois>
+ * @version   0.0.6
+ */
+namespace app\index\controller;
 
-use app\BaseController;
+use think\facade\View;
+use think\Request;
 
-class Index extends BaseController
+use app\index\controller\Base;
+use app\common\model\Article;
+use app\common\model\GuestBook;
+
+class Index extends Base
 {
     public function index()
     {
-        return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">14载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
+        // PHP $cid = 1;
+        $php_data = Article::getListByCid(1, 7);
+
+        // 其他学习笔记 $cid != 1;
+        $other_data = Article::getListByCid(-1, 7);
+        
+        // Top文章
+        $top_data = Article::getTop(3);
+
+        // 所有文章
+        $all_data = Article::getListByCid(0, 9);
+        
+        View::assign([
+            'php_data' => $php_data,
+            'other_data' => $other_data,
+            'top_data' => $top_data,
+            'all_data' => $all_data,
+        ]);
+
+        return View::fetch();
     }
 
-    public function hello($name = 'ThinkPHP6')
+
+    /**
+     * 关于&留言
+     */
+    public function about()
+    {
+        return View::fetch();
+    }
+
+    public function guestBook()
+    {
+        $data = GuestBook::getGuestBooks();
+        View::assign('data', $data);
+
+        return View::fetch();
+    }
+    
+    public function saveGuestBook(Request $request = null)
     {
-        return 'hello,' . $name;
+        $param = $request->param();
+
+        if (empty($param['author']) or empty($param['email'])) {
+            View::assign('data', ['msg'=>"请填写必填字段(姓名,电子邮件)", 'code'=>1]);
+            return View::fetch('error');
+        }
+
+        if (empty($param['comment'])) {
+            View::assign('data', ['msg'=>"请留下内容", 'code'=>1]);
+
+            return View::fetch('error');
+        }
+
+        array_pop($param);
+
+        try {
+            $bgu = new GuestBook();
+            $res = $bgu->save([
+                'comment' => $param['comment'],
+                'author' => $param['author'],
+                'email' => $param['email'],
+                'url' => $param['url'],
+                'time' => time(),
+            ]);
+        } catch (\Exception $e) {
+            $msg = $e->getMessage();
+
+            View::assign('data', ['msg'=>$msg, 'code'=>1]);
+            return View::fetch('error');
+        }
+
+        $this->redirect(url('blog/index/guestbook'), 302);
     }
 }

+ 43 - 0
app/index/route/app.php

@@ -0,0 +1,43 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+use think\facade\Route;
+use app\common\model\Category;
+use think\facade\Template;
+
+Route::pattern([
+    'name' => '\w+',
+    'id' => '\d+',
+    'cid' => '\d+',
+    'page' => '\d+',
+    'year' => '\d+',
+    'month' => '\d+',
+    'day' => '\d+',
+]); 
+
+Route::get('think', function () {
+    return 'hello,ThinkPHP6!';
+});
+
+Route::view('/404', '404');
+Route::get('/all', 'index/article/index');
+Route::get('/:year/:month/:day/:id', 'index/article/read');
+Route::post('/dolike', 'index/article/dolike');
+Route::get('/tags/:name', 'index/article/tags');
+Route::get('/time', 'index/article/time')->append(['_aside' => true]);
+Route::get('/about', 'index/index/about')->append(['_aside' => true]);
+
+$list = Category::getList();
+
+foreach ($list as $key => $value) {
+    if ($value->template == 'article') {
+        Route::get('/'.$value->url, 'index/article/index')->append(['cid' => $value->id]);
+    }
+}

+ 57 - 0
view/index/404.html

@@ -0,0 +1,57 @@
+{__NOLAYOUT__}
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
+
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <meta name="viewport" content="width=device-width">
+  <meta name='robots' content='noindex,follow' />
+  <title>huwhois的博客</title>
+  <link rel="stylesheet" type="text/css" href="/static/lib/Hui-iconfont/1.0.8/iconfont.css" />
+  <style>
+    .page-404 {
+      color: #afb5bf;
+      padding-top: 60px;
+      padding-bottom: 90px;
+      text-align: center;
+    }
+
+    .page-404 .error-title {
+      font-size: 80px
+    }
+
+    .page-404 .error-title .iconfont {
+      font-size: 80px
+    }
+
+    .page-404 .error-description {
+      font-size: 24px
+    }
+
+    .page-404 .error-info {
+      font-size: 14px
+    }
+    
+    a {
+      text-decoration: none;
+      color: #5A98E0;
+    }
+
+    .ml-20 {
+      margin-left: 20px;
+    }
+  </style>
+</head>
+
+<body id="error-page">
+  <div class="page-404 text-c" style="margin-top:80px;">
+    <p class="error-title"><i class="Hui-iconfont va-m" style="font-size:80px">&#xe656;</i><span class="va-m">
+        404</span></p>
+    <p class="error-description">不好意思,您访问的页面不存在~</p>
+    <p class="error-info">
+      您可以:<a href="javascript:;" onclick="history.go(-1)" class="c-primary">&lt; 返回上一页</a>
+      <span class="ml-20">|</span><a href="/" class="c-primary ml-20">去首页 &gt;</a></p>
+  </div>
+</body>
+
+</html>

+ 49 - 0
view/index/article/index.html

@@ -0,0 +1,49 @@
+<div class="box">
+  <!-- <div class="place">
+
+      <a href="/jstt/bj/" target="_blank" id="pagecurrent">心得笔记</a>
+
+      <a href="/jstt/css3/" target="_blank">CSS3|Html5</a>
+
+      <a href="/jstt/web/" target="_blank">网站建设</a>
+
+      <a href="/news/jsex/" target="_blank">JS经典实例</a>
+
+      <a href="/jstt/t/" target="_blank">推荐工具</a>
+  </div> -->
+  <div class="blank"></div>
+  <div class="blogs">
+    {foreach $list as $val}
+    <div class="bloglist">
+      <h2><a href="/read/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <div class="bloginfo">
+        <ul>
+          <li class="author"><a href="/{$val.category_url}"> {$val.category_name} </a></li>
+          <li class="timer">{$val.create_time}</li>
+          <li class="view">{$val.hits} 已阅读</li>
+          <li class="like">{$val.likes}</li>
+        </ul>
+      </div>
+      <p>{$val.summary}</p>
+    </div>
+    {/foreach}
+    {lt name="list|count" value="$limit"}
+    <p style="text-align: center;">全都给你了, 没有更多啦(╥╯^╰╥).</p>
+    {/lt}
+    <div class="pagelist">
+      <a title="Total record">共&nbsp;<b>{$lastPage}</b>页</a>&nbsp;&nbsp;&nbsp;
+      {neq name="page" value="1"}
+      <a href="{$baseUrl}">首页</a>
+      <a href="{$baseUrl}?page={$page - 1}">上一页</a>&nbsp;
+      {/neq}
+      <b>{$page}</b>&nbsp;
+      {neq name="page" value="$lastPage"}
+      <a href="{$baseUrl}?page={$page + 1}">下一页</a>&nbsp;
+      <a href="{$baseUrl}?page={$lastPage}">尾页</a>
+      {/neq}
+      <input type="number" min="1" max="{$lastPage}">
+      <a href="javascript:goto()">转到</a>
+    </div>
+  </div>
+  {include file="aside"}
+</div>

+ 93 - 0
view/index/article/read.html

@@ -0,0 +1,93 @@
+<link href="/static/plugins/highlight/styles/monokai-sublime.min.css" rel="stylesheet"> 
+
+<div class="box">
+  <div class="blank"></div>
+  <div class="infosbox">
+    <div class="newsview">
+      <h3 class="news_title">{$data.title}</h3>
+      <div class="bloginfo">
+        <ul>
+          <li class="author"><a href="/{$data.category_url}"> {$data.category_name} </a></li>
+          <li class="timer">{$data.create_time}</li>
+          <li class="view">{$data.hits} 已阅读</li>
+          <li class="like">{$data.likes}</li>
+        </ul>
+      </div>
+      <div class="tags">
+        {php}$tags = explode(',',$data->keywords);{/php}
+        {foreach $tags as $value}
+        <a href="/tags/{$value}"  rel="tag" data-wpel-link="internal">{$value}</a> &nbsp;
+        {/foreach}
+      </div>
+      <div class="news_about"><strong>简介</strong>{$data.summary}</div>
+      <div class="news_con" id="preview">
+        {$data.content|raw}
+      </div>
+      <p id="content_md" style="display: none;"></p>
+      <p class="diggit"><a href="JavaScript:getLike({$data.id});"> 很赞哦! </a>(<b id="diggnum"> {$data.likes} </b>)</p>
+    </div>
+    <div class="nextinfo">
+      {empty name="prev_next.prev"}
+      <p>上一篇:<a >没有了</a></p>
+      {else}
+      <p>上一篇:<a href="/read/{$prev_next['prev']['id']}" title="{$prev_next.prev.title}">{$prev_next.prev.title}</a></p>
+      {/empty}
+      {empty name="prev_next.next"}
+      <p>下一篇:<a href="/{$data.category_url}">返回列表</a></p>
+      {else}
+      <p>下一篇:<a
+          href="/read/{$prev_next['next']['id']}"
+          title="{$prev_next.next.title}">{$prev_next.next.title}</a></p>
+      {/empty}
+    </div>
+    <!-- <div class="otherlink">
+      <h2>相关文章</h2>
+      <ul>
+        <li><a href="#" title="##">###</a></li>
+      </ul>
+    </div> -->
+    <!-- <div class="news_pl">
+      <h2>文章评论</h2>
+      <ul>
+        <div class="gbko"> </div>
+      </ul>
+    </div> -->
+  </div>
+  {include file="aside"}
+</div>
+
+<script src="/static/plugins/highlight/highlight.min.js"></script>
+<!-- <script src="/static/plugins/md/js/marked.js"></script> -->
+<script type="text/javascript">
+  // hljs.initHighlightingOnLoad();
+  hljs.highlightAll();
+
+  // marked.setOptions({
+  //   renderer: new marked.Renderer(),
+  //   gfm: true,
+  //   tables: true,
+  //   breaks: false,
+  //   pedantic: false,
+  //   sanitize: false,
+  //   smartLists: true,
+  //   smartypants: false,
+  //   highlight: function (code) {
+  //     return hljs.highlightAuto(code).value;
+  //   }
+  // });
+
+  // $("#preview").html(marked($("#content_md").html()));
+ 
+  function getLike(id) {
+    var num = parseInt($('#diggnum').text());
+    $.post('/dolike', {
+      'id': id
+    }, function (res) {
+      if (res.code==0) {
+        $('#diggnum').text(num+1);
+      } else {
+        console.log(res.msg);
+      }
+    }, 'json');
+  }
+</script>

+ 23 - 0
view/index/article/tags.html

@@ -0,0 +1,23 @@
+<div class="box">
+  <div class="place">
+    <h2>Tags for {$tag}</h2>
+  </div>
+  <div class="blank"></div>
+  <div class="blogs">
+    {foreach $list as $val}
+    <div class="bloglist">
+      <h2><a href="/read/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <div class="bloginfo">
+        <ul>
+          <li class="author"><a href="/{$val.category_url}"> {$val.category_name} </a></li>
+          <li class="timer">{$val.create_time}</li>
+          <li class="view">{$val.hits} 已阅读</li>
+          <li class="like">{$val.likes}</li>
+        </ul>
+      </div>
+      <p>{$val.summary}</p>
+    </div>
+    {/foreach}
+  </div>
+  {include file="aside"}
+</div>

+ 16 - 0
view/index/article/time.html

@@ -0,0 +1,16 @@
+<article>
+  <div class="timebox">
+    <ul>
+      {foreach $list as $val}
+      <li><span>{$val.create_time|date="Y-m-d"}</span><i><a href="/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></i></li>
+      {/foreach}
+    </ul>
+  </div>
+  <div class="pagelist">
+    
+    <a title="Total record">共&nbsp;<b>{//$data.pages}</b>页</a>&nbsp;&nbsp;&nbsp;
+     
+      <a href="{//:url('/time/'.($page + 1))}">下一页</a>&nbsp;
+      <a href="{//:url('/time/'.$data.pages)}">尾页</a>
+  </div>
+</article>

+ 33 - 0
view/index/aside.html

@@ -0,0 +1,33 @@
+<aside>
+  <div class="ztbox">
+    <ul>
+      {foreach $cate_lists as $value}
+      <li><a href="/{$value.url}">{$value.name}</a></li>
+      {/foreach}
+    </ul>
+  </div>
+  <div class="paihang">
+    <h2>点击排行</h2>
+    <ul>
+      {foreach $hits_lists as $value}
+      <li><a href="/read/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+      {/foreach}
+    </ul>
+  </div>
+  <div class="paihang">
+      <h2>博文推荐</h2>
+      <ul>
+        {foreach $top_lists as $value}
+        <li><a href="/read/{$value.id}" title="{$value.title}" title="{$value.title}">{$value.title}</a></li>
+        {/foreach}
+      </ul>
+    </div>
+  <!-- <div class="paihang">
+    <h2>友情链接</h2>
+    <ul>
+      <li><a href="{//$Think.config.url_2048_root}">2048之陈小发</a></li>
+      <li><a href="{//$Think.config.url_blog_root}">huwhois个人博客</a></li>
+      <li><a href="{//$Think.config.url_1219_root}">1219fun</a></li>
+    </ul>
+  </div> -->
+</aside>

+ 25 - 0
view/index/index/about.html

@@ -0,0 +1,25 @@
+<div class="box">
+  <div class="newsview">
+    <h2>About my blog</h2>
+    <div class="news_infos">
+      <p>本博客属个人所有, 不涉及商业目的.遵守中华人民共和国法律法规、中华民族基本道德和基本网络道德规范, 尊重有节制的言论自由和意识形态自由, 反对激进、破坏、低俗、广告、投机等不负责任的言行.
+        <br>
+        所有转载的文撰写页面章、图片仅用于说明性目的, 被要求或认为适当时, 将标注署名与来源. 避免转载有明确"不予转载"声明的作品. 若不愿某一作品被转用, 请及时通知本人.
+        对于无版权或自由版权作品, 本博客有权进行修改和传播, 一旦涉及实质性修改, 本博客将对修改后的作品享有相当的版权.二次转载者请再次确认原作者所给予的权力范围.
+        <br>
+        <!-- 本博客所有原创作品, 包括文字、资料、图片、网页格式, 转载时请标注作者与来源. 非经允许, 不得用于赢利目的.<br> -->
+      </p>
+      <br>
+      <h2>About This Site</h2>
+      &nbsp;
+      <p>域 名:huwhois.cn 创建于2022年3月10日&nbsp;</p>
+      <br>
+      <!-- <p>备案号:暂无</p> -->
+      <br>
+      <p>
+        <br>后端框架: ThinkPHP6.0 官网:http://www.thinkphp.cn/
+        <br>前端模板: 来源杨青青个人博客. https://www.yangqq.com/download/div/881.html.
+      </p>
+    </div>
+  </div>
+</div>

+ 84 - 0
view/index/index/article.html

@@ -0,0 +1,84 @@
+<link href="/static/highlight/styles/monokai-sublime.css" rel="stylesheet"> 
+
+<div class="box">
+  <div class="blank"></div>
+  <div class="infosbox">
+    <div class="newsview">
+      <h3 class="news_title">{$data.title}</h3>
+      <div class="bloginfo">
+        <ul>
+          <li class="author"><a href="{:url('/lists/'.$cid.'/1')}"> {$cid|model('admin/blog_category')->getCateName} </a></li>
+          <li class=" timer">{$data.pubtime|date="Y-m-d", ###}</li>
+          <li class="view">{$data.clicks} 已阅读</li>
+          <!-- <li class="like">8888888</li> -->
+        </ul>
+      </div>
+      <!-- <div class="tags"><a href="/" target="_blank">个人博客</a> &nbsp; <a href="/" target="_blank">小世界</a></div> -->
+      <div class="news_about"><strong>简介</strong>{$data.summary}</div>
+      <div class="news_con" id="preview">
+
+      </div>
+      <p id="content_md" style="display: none;">{$data.content_md}</p>
+      <p class="diggit"><a href="JavaScript:getLike({$data.id});"> 很赞哦! </a>(<b id="diggnum"> {$data.like} </b>)</p>
+    </div>
+    <div class="nextinfo">
+      {empty name="prev_next.prev"}
+      <p>上一篇:<a href="#">没有了</a></p>
+      {else}
+      <p>上一篇:<a href="/{$prev_next.prev.pubtime|date='Y/m/d', ###}/{$prev_next['prev']['id']}" title="{$prev_next.prev.title}">{$prev_next.prev.title}</a></p>
+      {/empty}
+      {empty name="prev_next.next"}
+      <p>下一篇:<a href="{:url('/time')}">返回列表</a></p>
+      {else}
+      <p>下一篇:<a
+          href="/{$prev_next.next.pubtime|date='Y/m/d', ###}/{$prev_next['next']['id']}"
+          title="{$prev_next.next.title}">{$prev_next.next.title}</a></p>
+      {/empty}
+    </div>
+    <!-- <div class="otherlink">
+      <h2>相关文章</h2>
+      <ul>
+        <li><a href="#" title="##">###</a></li>
+      </ul>
+    </div> -->
+    <div class="news_pl">
+      <h2>文章评论</h2>
+      <ul>
+        <div class="gbko"> </div>
+      </ul>
+    </div>
+  </div>
+  {include file="aside"}
+</div>
+
+<script src="/static/highlight/highlight.pack.js"></script>
+<script src="/static/md/js/marked.js"></script>
+<script type="text/javascript">
+  hljs.initHighlightingOnLoad();
+
+  marked.setOptions({
+    renderer: new marked.Renderer(),
+    gfm: true,
+    tables: true,
+    breaks: false,
+    pedantic: false,
+    sanitize: false,
+    smartLists: true,
+    smartypants: false,
+    highlight: function (code) {
+      return hljs.highlightAuto(code).value;
+    }
+  });
+
+  $("#preview").html(marked($("#content_md").html()));
+  function getLike(id) {
+    var num = parseInt($('#diggnum').text());
+    $.post('/getlike', {
+      'id': id
+    }, function (data) {
+      if (data.code=2) {
+        $('#diggnum').text(num+1);
+      }
+    }, 'json');
+  }
+</script>

+ 138 - 0
view/index/index/error.html

@@ -0,0 +1,138 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
+
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <meta name="viewport" content="width=device-width">
+  <meta name='robots' content='noindex,follow' />
+  <title>Comment Submission Failure</title>
+  <style type="text/css">
+    html {
+      background: #f1f1f1;
+    }
+
+    body {
+      background: #fff;
+      color: #444;
+      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
+      margin: 2em auto;
+      padding: 1em 2em;
+      max-width: 700px;
+      -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
+      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
+    }
+
+    h1 {
+      border-bottom: 1px solid #dadada;
+      clear: both;
+      color: #666;
+      font-size: 24px;
+      margin: 30px 0 0 0;
+      padding: 0;
+      padding-bottom: 7px;
+    }
+
+    #error-page {
+      margin-top: 50px;
+    }
+
+    #error-page p {
+      font-size: 14px;
+      line-height: 1.5;
+      margin: 25px 0 20px;
+    }
+
+    #error-page code {
+      font-family: Consolas, Monaco, monospace;
+    }
+
+    ul li {
+      margin-bottom: 10px;
+      font-size: 14px;
+    }
+
+    a {
+      color: #0073aa;
+    }
+
+    a:hover,
+    a:active {
+      color: #00a0d2;
+    }
+
+    a:focus {
+      color: #124964;
+      -webkit-box-shadow:
+        0 0 0 1px #5b9dd9,
+        0 0 2px 1px rgba(30, 140, 190, .8);
+      box-shadow:
+        0 0 0 1px #5b9dd9,
+        0 0 2px 1px rgba(30, 140, 190, .8);
+      outline: none;
+    }
+
+    .button {
+      background: #f7f7f7;
+      border: 1px solid #ccc;
+      color: #555;
+      display: inline-block;
+      text-decoration: none;
+      font-size: 13px;
+      line-height: 26px;
+      height: 28px;
+      margin: 0;
+      padding: 0 10px 1px;
+      cursor: pointer;
+      -webkit-border-radius: 3px;
+      -webkit-appearance: none;
+      border-radius: 3px;
+      white-space: nowrap;
+      -webkit-box-sizing: border-box;
+      -moz-box-sizing: border-box;
+      box-sizing: border-box;
+
+      -webkit-box-shadow: 0 1px 0 #ccc;
+      box-shadow: 0 1px 0 #ccc;
+      vertical-align: top;
+    }
+
+    .button.button-large {
+      height: 30px;
+      line-height: 28px;
+      padding: 0 12px 2px;
+    }
+
+    .button:hover,
+    .button:focus {
+      background: #fafafa;
+      border-color: #999;
+      color: #23282d;
+    }
+
+    .button:focus {
+      border-color: #5b9dd9;
+      -webkit-box-shadow: 0 0 3px rgba(0, 115, 170, .8);
+      box-shadow: 0 0 3px rgba(0, 115, 170, .8);
+      outline: none;
+    }
+
+    .button:active {
+      background: #eee;
+      border-color: #999;
+      -webkit-box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
+      box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, 0.5);
+      -webkit-transform: translateY(1px);
+      -ms-transform: translateY(1px);
+      transform: translateY(1px);
+    }
+  </style>
+</head>
+
+<body id="error-page">
+  <p>
+    <p><strong>ERROR</strong>: {$data.msg}.</p>
+  </p>
+  <p><a href='javascript:history.back()'>&laquo; Back</a></p>
+</body>
+
+</html>

+ 157 - 0
view/index/index/guestbook.html

@@ -0,0 +1,157 @@
+<style>
+  .comment-respond {
+  background: white;
+  box-shadow: 0 0 2px 0 rgba(58, 58, 58, 0.2);
+  padding: 1.5em 4.6875375%;
+}
+
+.guestbook {
+  width: 100%; 
+  float: left;
+  padding-bottom: 3em;
+}
+
+.guestbook h2 span {
+  font-size: 12px;
+}
+
+@media only screen and (max-width: 767px) {
+  .comment-respond {
+    background: white;
+    box-shadow: 0 0 2px 0 rgba(58, 58, 58, 0.2);
+    padding: 1.5em 7.50006%;
+  }
+}
+
+h3 {
+  font-size: 1.125em;
+  /* 18px / 16px */
+  line-height: 1.333;
+  /* 24px */
+}
+.comment-respond p{
+  margin: 1.125em 0;
+}
+
+.comment-respond p.comment-notes {
+  margin: 1.5em 0;
+}
+
+.comment-respond label {
+  display: block;
+  margin-bottom: 6px;
+  font-weight: 700;
+  font-size: 0.875em;
+  line-height: 1.715;
+}
+
+input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="file"]):not([type="image"]), textarea {
+  width: 100%;
+  font-family: "Roboto", "Open Sans", sans-serif;
+  font-weight: 400;
+  padding: 10px 12px;
+  max-width: 27.75em;
+  min-height: 26px;
+  background: #F7F7F7;
+  color: #333333;
+  border: solid 1px #D4D4D4;
+  border-radius: 0;
+  -webkit-appearance: none;
+  -webkit-transition: background 0.2s;
+  transition: background 0.2s;
+}
+
+textarea {
+  max-width: 41.625em;
+  overflow: auto;
+}
+.comment-respond p.form-submit {
+  margin-top: 2.25em;
+}
+
+input[type="submit"]{
+  font-size: 0.75em;
+  line-height: 1.5;
+}
+
+input[type="submit"] {
+  font-family: "Roboto", "Open Sans", sans-serif;
+  font-weight: 400;
+  padding: 10px 12px;
+  color: #333333;
+  border: solid 1px #333333;
+  background: none;
+  border-radius: 0;
+  -webkit-appearance: none;
+  -webkit-transition: all 0.2s;
+  transition: all 0.2s;
+}
+
+.pager{
+  margin-left: 10%;
+  width: 60%;
+  background: red;
+}
+
+ul.pager li:first-child {
+  float: left;
+}
+ul.pager li:last-child{
+  float: left;
+  margin-left: 30%;
+}
+</style>
+
+<div class="box">
+  <div class="newsview">
+    <h2>留言</h2>
+    <div class="news_infos">
+      <p>有什么想告诉我说的, 就在这吧ヾ(✿゚▽゚)ノ</p>
+    </div>
+  </div>
+  <!-- #respond -->
+  <div id="respond" class="comment-respond">
+    <h3 id="reply-title" class="comment-reply-title">Leave a Reply</h3>
+    <form action="{:url('blog/index/saveguestbook')}" method="post" id="commentform" class="comment-form" novalidate="">
+      <p class="comment-notes"><span id="email-notes">我会妥善保存你的邮箱哒(`・ω・´).</span> 必填项已标记<span class="required">*</span></p>
+      <p class="comment-form-comment">
+        <label for="comment">Comment</label>
+        <textarea required="" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
+      </p>
+      <p class="comment-form-author">
+        <label for="author">Name*</label>
+        <input id="author" name="author" type="text" placeholder="Jane Doe" value="" size="26">
+      </p>
+      <p class="comment-form-email">
+        <label for="email">Email*</label>
+        <input id="email" name="email" type="email" placeholder="name@email.com" value="" size="26">
+      </p>
+      <p class="comment-form-url">
+        <label for="url">Website</label>
+        <input id="url" name="url" type="url" placeholder="http://google.com" value="" size="26">
+      </p>
+      <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Post Comment">
+        <!-- <input type="hidden" name="comment_post_ID" value="23" id="comment_post_ID">
+        <input type="hidden" name="comment_parent" id="comment_parent" value="0"> -->
+      </p>
+    </form>
+  </div><!-- #respond end-->
+  <div class="blank"></div>
+  <div class="guestbook">
+    {foreach $data as $val}
+    <div class="bloglist">
+      <div>
+        <h2>{$val.author} <span>{$val.time|date="Y/m/d", ###}</span></h2>
+      </div>
+      <p>{$val.comment}</p>
+    </div>
+    {/foreach}
+    {php}$counts = count($data);{/php}
+    {lt name="counts" value="15"}
+    <p style="text-align: center;">全都给你了, 没有更多啦(╥╯^╰╥).</p>
+    {/lt}
+    <div class="pagelist">
+      {$data->render()}
+    </div>
+  </div>
+</div>

+ 48 - 0
view/index/index/index.html

@@ -0,0 +1,48 @@
+<div class="box">
+  <!-- PHP -->
+  <div class="newsbox f_l ">
+    <div class="newstitle"><span><a href="/php">+</a></span><b>PHP</b></div>
+    <ul class="newsli">
+      {foreach $php_data as $val}
+      <li><a href="/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
+      {/foreach}
+    </ul>
+  </div>
+  <!-- notes_data -->
+  <div class="newsbox f_r ">
+    <div class="newstitle"><span><a href="/all">+</a></span><b>其他</b></div>
+    <ul class="newsli">
+      {foreach $other_data as $val}
+      <li><a href="/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
+
+      {/foreach}
+    </ul>
+  </div>
+  <div class="blank"></div>
+  <!-- top -->
+  {foreach $top_data as  $key=> $val}
+  <div class="sbox  {switch name='key'}{case value='1'}f_l ml{/case}{case value='2'}f_r{/case}{default /}f_l{/switch}"> <span>{$val.category_name}</span>
+    <h2><a href="/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+    <p>{$val.summary}</p>
+  </div>
+  {/foreach}
+  <div class="blank"></div>
+  <!-- all -->
+  <div class="blogs">
+    {foreach $all_data as $val}
+    <div class="bloglist">
+      <h2><a href="/read/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <div class="bloginfo">
+        <ul>
+          <li class="author"><a href="/{$val.category_url}"> {$val.category_name} </a></li>
+          <li class="timer">{$val.create_time}</li>
+          <li class="view">{$val.hits} 已阅读</li>
+          <li class="like">{$val.likes}</li>
+        </ul>
+      </div>
+      <p>{$val.summary}</p>
+    </div>
+    {/foreach}
+  </div>
+  {include file="aside"}
+</div>

+ 45 - 0
view/index/index/lists.html

@@ -0,0 +1,45 @@
+<div class="box">
+  <!-- <div class="place" id="pageContents">
+
+      <a href="/jstt/bj/" target="_blank" id="pagecurrent">心得笔记</a>
+
+      <a href="/jstt/css3/" target="_blank">CSS3|Html5</a>
+
+      <a href="/jstt/web/" target="_blank">网站建设</a>
+
+      <a href="/news/jsex/" target="_blank">JS经典实例</a>
+
+      <a href="/jstt/t/" target="_blank">推荐工具</a>
+  </div> -->
+  <div class="blank"></div>
+  <div class="blogs">
+    {foreach $data.lists as $val}
+    <div class="bloglist">
+      <h2><a href="/read/{$val.id}"
+          title="{$val.title}">{$val.title}</a></h2>
+      <p>{$val.summary}</p>
+    </div>
+    {/foreach}
+    {lt name="data.count" value="$data.num_of_per"}
+    <p style="text-align: center;">全都给你了, 没有更多啦(╥╯^╰╥).</p>
+    {/lt}
+    <div class="pagelist">
+      <a title="Total record">共&nbsp;<b>{$data.pages}</b>页</a>&nbsp;&nbsp;&nbsp;
+      {neq name="page" value="1"}
+      <a href="{:url('/lists/'.$cid.'/1')}">首页</a>
+      <a href="{:url('/lists/'.$cid.'/'.($page - 1))}">上一页</a>&nbsp;
+      {/neq}
+      {php}$start = ceil($page/5)*5-4;{/php}
+      {for start="$start" end="$start+5" comparison="lt" step="1" name="npage"}
+      {eq name="page" value="$npage"}
+      <b>{$npage}</b>&nbsp;
+      {else}
+      <a href="{:url('/lists/'.$cid.'/'.$npage, 'page=')}">{$npage}</a>&nbsp;
+      {/eq}
+      {/for}
+      <a href="{:url('/lists/'.$cid.'/'.($page + 1))}">下一页</a>&nbsp;
+      <a href="{:url('/lists/'.$cid.'/'.$data.pages)}">尾页</a>
+    </div>
+  </div>
+  {include file="aside"}
+</div>

+ 37 - 0
view/index/layout.html

@@ -0,0 +1,37 @@
+<!doctype html>
+<html>
+
+<head>
+  <meta charset="utf-8">
+  <title>{$title??'首页'}</title>
+  <meta name="keywords" content="个人博客,huwhois个人博客,huwhois,PHP,php" />
+  <meta name="description" content="huwhois个人博客" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <link href="/static/index/css/index.css" rel="stylesheet">
+  <script type="text/javascript" src="/static/plugins/lib/jquery/1.9.1/jquery.min.js"></script>
+</head>
+
+<body>
+  <header>
+    <div class="logo"><a href="{:url('/index')}">huwhois个人博客</a></div>
+    <nav>
+      <ul id="starlist">
+        <li><a href="{:url('/index')}">网站首页</a></li>
+        {foreach $categories as $val}
+        <li><a href="/{$val.url}">{$val.name}</a></li>
+        {/foreach}
+      </ul>
+    </nav>
+  </header>
+
+  {__CONTENT__}
+
+  <div class="blank"></div>
+
+  <footer>
+    <p>Power by <a href="mailto:{//$Think.config.email}" target="_blank">{//$Think.config.email}</a> </p>
+    <!-- <p>备案号:<a href="/"></a></p> -->
+  </footer>
+</body>
+
+</html>