Skip to content
This repository has been archived by the owner on May 6, 2018. It is now read-only.

Commit

Permalink
修改了文章自定义链接的方法:
Browse files Browse the repository at this point in the history
早期是文件名即为文章链接,修改后用户可以使用`slug`参数在文章中自定义链接名,如果文章中不存在`slug`参数则使用文件名,如果文件名是中文的话会自动转换成拼音使用。
  • Loading branch information
lizheming committed Jun 5, 2014
1 parent 43b3873 commit ca3913f
Show file tree
Hide file tree
Showing 3 changed files with 578 additions and 23 deletions.
6 changes: 1 addition & 5 deletions .gitignore
@@ -1,9 +1,5 @@
/*.html
/*.xml
/generate
/PMBlog.wiki
/category/*
/page/*
/tag/*
/admin/usr/contents/*.md
!/admin/usr/contents/hello-world.md
/admin/usr/themes/octopress
Expand Down
6 changes: 4 additions & 2 deletions admin/index.php
Expand Up @@ -192,6 +192,7 @@ protected function get_contents() {
$log['type'] = $post->type();
$log['docpath'] = $post->doc();
$log['filename'] = $post->doc_title();
$log['slug'] = $post->url();
$log['extension'] = $post->doc_extension();
$log['title'] = $post->title();
$log['content'] = $post->text();
Expand All @@ -204,6 +205,7 @@ protected function get_contents() {
$log['read_more'] = isset($abstract[1]) ? true : false;
$log['opening'] = $abstract[0];

if(json_encode($item)=='null') $item = mb_convert_encoding($item, 'UTF-8', array('GBK', 'BIG-5'));
$dirname = dirname($item).'/';
$dirname = str_replace($this->site['config']['doc'], '', $dirname);
$dirname = explode('/', $dirname);
Expand All @@ -230,10 +232,10 @@ protected function get_contents() {
if($log['type'] == 'post' && preg_match('/{category}/', $router)) {
$log['filepath'] = array();
foreach($log['categories'] as $category) {
$log['filepath'][] = str_replace('{category}', $category, $router) . "/{$log['filename']}.html";
$log['filepath'][] = str_replace('{category}', $category, $router) . "/{$log['slug']}";
}
} else {
$log['filepath'] = array("$router/{$log['filename']}.html");
$log['filepath'] = array("$router/{$log['slug']}");
}

$log['url'] = $this->site['url'].$log['filepath'][0];
Expand Down

0 comments on commit ca3913f

Please sign in to comment.