Skip to content

Commit

Permalink
更新v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Mar 5, 2017
1 parent ba17917 commit d7a742b
Show file tree
Hide file tree
Showing 82 changed files with 7,632 additions and 400 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/Src/Cache
/Src/Logs
/Src/Static/Upload
/Src/sitemap.xml
114 changes: 107 additions & 7 deletions Db/db_yurunblog.sql

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ YurunBlog 基于 YurunPHP 框架开发,目前这还属于Demo阶段,暂时

这个开源项目我会持续开发更新,也欢迎有兴趣的朋友一起来完善 YurunBlog 。

YurunBlog不追求什么功能强大,也不追求什么轻便简洁。反正功能强大的东西早晚要被嫌弃臃肿,轻便简洁的会嫌弃他功能少,久而久之轻便简洁也慢慢变臃肿。没有任何意义,实用就行。

演示地址(宇润的博客):http://blog.yurunsoft.com/

##配置说明
Expand Down
16 changes: 16 additions & 0 deletions Src/Common/Lib/Component/YCComment/YCComment.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
class YCComment extends YCBase
{
/**
* 渲染类型
* @var unknown
*/
protected $renderMode = self::RENDER_MODE_NONE;
/**
* 自定义渲染内容
*/
protected function __render()
{
$this->view->display(APP_TEMPLATE . Config::get('@.THEME') . '/Home/Comment/comment.html');
}
}
52 changes: 52 additions & 0 deletions Src/Common/Lib/Component/YCCommentList/YCCommentList.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
class YCCommentList extends YCBase
{
/**
* 属性默认值们
* @var unknown
*/
protected $attrsDefault = array(
'content_id' => 0,
'comments' => false,
'page' => 1,
'is_child' => false,
'total_records' => 0
);
/**
* 渲染类型
* @var unknown
*/
protected $renderMode = self::RENDER_MODE_NONE;
/**
* comments模版文件路径
*/
private $commentsTemplatePath;
/**
* 自定义渲染内容
*/
protected function __render()
{
if(Config::get('Custom.CONTENT_SHOW_STATIC_COMMENTS'))
{
if(false === $this->comments)
{
$commentModel = new CommentModel;
$this->comments = $commentModel->where(array('Status'=>COMMENT_STATUS_NORMAL))->orderByNew()->getAssocList($this->content_id,(int)Config::get('@.COMMENTS_SHOW'),$this->page,$totalRecords);
$this->total_records = $totalRecords;
}
$this->renderItem();
}
}
private function renderItem()
{
$this->commentsTemplatePath = APP_TEMPLATE . Config::get('@.THEME') . '/Home/Comment/comments.html';
$this->view->comments = $this->comments;
$this->view->display($this->commentsTemplatePath);
}
public function renderSubItem($comments)
{
$view = new View(null,$this);
$view->comments = $comments;
$view->display($this->commentsTemplatePath);
}
}
35 changes: 35 additions & 0 deletions Src/Common/Lib/UrlHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,30 @@ public function Home_Index_index($data)
}
public function Article_view($data)
{
static $articleModel;
if(!isset($data['param']['Alias']) && isset($data['param']['ID']))
{
if(null === $articleModel)
{
$articleModel = new CategoryModel;
}
$data['param'] = $articleModel->getByPk($data['param']['ID']);
}
$data['result'] = Dispatch::url('Home/Article/view',array('Alias'=>$data['param']['Alias']));
}
public function Page_view($data)
{
static $pageModel;
if(!isset($data['param']['Alias']) && isset($data['param']['ID']))
{
if(null === $pageModel)
{
$pageModel = new CategoryModel;
}
$data['param'] = $pageModel->getByPk($data['param']['ID']);
}
$data['result'] = Dispatch::url('Home/Page/view',array('Alias'=>$data['param']['Alias']));
}
public function Article_list($data)
{
static $categoryModel;
Expand All @@ -47,4 +69,17 @@ public function Article_list($data)
}
$data['result'] = Dispatch::url('Home/Article/list',$param);
}
public function Tag_view($data)
{
static $tagModel;
if(!isset($data['param']['Code']) && isset($data['param']['ID']))
{
if(null === $tagModel)
{
$tagModel = new TagModel;
}
$data['param'] = $tagModel->getByPk($data['param']['ID']);
}
$data['result'] = Dispatch::url('Home/Tag/view',array('Alias'=>$data['param']['Code']));
}
}
6 changes: 3 additions & 3 deletions Src/Common/Lib/UserSession.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ private function checkCookie($isJumpToLogin = false)
return false;
}
// 根据UID获取用户信息
$userInfo = $this->getBy($this->rememberCookieUIDFieldNameFieldName, $uid);
$this->userInfo = $this->getBy($this->rememberCookieUIDFieldNameFieldName, $uid);
// 判断用户信息是否存在
if(!isset($userInfo[$this->pk]))
if(!isset($this->userInfo[$this->pk]))
{
return false;
}
return $hash === $this->parseCookieHash($userInfo[$this->rememberCookieUIDFieldNameFieldName],$time);
return $hash === $this->parseCookieHash($this->userInfo[$this->rememberCookieUIDFieldNameFieldName],$time);
}
/**
* 处理密码加盐
Expand Down
74 changes: 74 additions & 0 deletions Src/Common/Lib/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,21 @@ enumFiles(APP_TEMPLATE . Config::get('@.THEME') . '/Home/Article/view'
);
return $result;
}
/**
* 页面模版
*/
function &getPageTemplates()
{
$result = array();
enumFiles(APP_TEMPLATE . Config::get('@.THEME') . '/Home/Page/view'
,function($file) use(&$result){
$arr = explode('.',basename($file));
array_pop($arr);
$result[] = implode('.',$arr);
}
);
return $result;
}
/**
* 获取YurunBlog自定义规则的文本结果
* @param string $rule
Expand Down Expand Up @@ -264,4 +279,63 @@ function($matches)use($params){
}
},
$rule);
}
/**
* 获取评论哈希值
* @param id $contentID
* @return string
*/
function getCommentHash($contentID)
{
$key = Session::get('@.COMMENT_KEY');
if(false === $key)
{
$key = uniqid('',true);
Session::set('@.COMMENT_KEY',$key);
}
return sha1(md5($contentID) . $key . md5(Config::get('@.BLOG_KEY',mt_rand())));
}
// 兼容PHP < 5.5
if(!function_exists('array_column'))
{
function array_column($array,$column_name)
{
return array_map(function($element) use($column_name){return $element[$column_name];}, $array);
}
}
/**
* 处理html换行,把\r\n替换为<br/>
* @param mixed $str
* @return mixed
*/
function parseHtmlLine($str)
{
return str_replace("\r\n",'<br/>',$str);
}
/**
* 处理标签的Code,替换关键符号
* @param string $code
* @return string
*/
function parseTagCode($code)
{
return str_replace(
array(
'=',
'%',
'&',
'?',
'/',
'#'
),
array(
'Equal',
'Percent',
'And',
'QuestionMark',
'Slash',
'Sharp'
),
$code
);
}
4 changes: 2 additions & 2 deletions Src/Common/Lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* YurunBlog版本信息
*/
define('YB_VERSION','0.0.1');
define('YB_VERSION','0.0.2');
/**
* YurunBlog字母版本号
* @Dev 开发版
Expand Down Expand Up @@ -31,7 +31,7 @@
/**
* 生成URL
*/
Event::register('YP_URL_CREATE', function(&$data){
Event::register('YP_URL_CREATE', function($data){
UrlHelper::parse($data);
});
/**
Expand Down
4 changes: 0 additions & 4 deletions Src/Common/Model/ArticleModel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ class ArticleModel extends ContentModel
{
public $exDataType = EX_DATA_TYPE_ARTICLE;
public $type = CONTENT_TYPE_ARTICLE;
public function __selectOneAfter(&$data)
{
$data['Url'] = Dispatch::url('Article/view',$data);
}
}
Loading

0 comments on commit d7a742b

Please sign in to comment.