Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
添加README文档文件的解析模式:html、md
Browse files Browse the repository at this point in the history
  • Loading branch information
bajins committed Oct 28, 2019
1 parent 3e79249 commit 440b345
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,35 @@


## 自定义修改

- 比如README的上下边距

- 添加对表格样式多样化的支持

- 添加对锚点定位支持,使用方式:在链接后面加上`#标签的id`

> 示例链接:https://file.woytu.com/?dir=DeveloperTool#Xshell
- 化繁为简:去除顶部链接,如果需要顶部链接版本,请看分支[top-links](https://github.com/woytu/DirectoryLister/tree/top-links)

- [添加gitter聊天室](https://github.com/woytu/DirectoryLister/commit/154df157974ac6f883e3484761ad951e0da90ae6)

- [添加留言](https://github.com/woytu/DirectoryLister/commit/67de302d611e4cf011d8fdee8b7e649e662a1d76)

- [修改网站标题为统一在配置文件中设置](https://github.com/woytu/DirectoryLister/commit/0fab9eae60df0926a06a5859f4d528b859b8be4c)

- 修改[`README.md`支持Markdown语法](https://github.com/woytu/DirectoryLister/blob/68c64d9a95201d1460607f3f85855dcd303fecf5/resources/DirectoryLister.php#L460-L517),如果不需要Markdown语法版本,请看分支[README-HTML](https://github.com/woytu/DirectoryLister/tree/README-HTML)

- 添加面包屑导航栏

- 添加配置`readme_mode`(README文档文件的解析模式:html、md)



![新旧式样手机效果对比](/sample-graph.png)



## 演示示例

woytu Soft:https://www.woytu.com
Expand All @@ -29,7 +46,9 @@ woytu Soft:https://www.woytu.com


## 文件结构
假设你的虚拟主机是 `/home/wwwroot/xxx.xx`

- 假设你的虚拟主机是 `/home/wwwroot/xxx.xx`

```
├─ resources/
│ ├ themes/
Expand All @@ -55,6 +74,7 @@ woytu Soft:https://www.woytu.com
└ ......
```

## 注意事项:

### 不显示文件和目录
Expand All @@ -67,6 +87,7 @@ sed -i 's/,scandir//g' /usr/local/php/etc/php.ini
/etc/init.d/php-fpm restart
# 重启 PHP生效
```

### 程序放在网站子目录不显示`README.md`的解决方法

> 因为程序有个判断 `README.md` 路径的代码,而如果是正常使用域名或IP(即使加上),都是可以自适应的。
Expand Down
24 changes: 24 additions & 0 deletions resources/DirectoryLister.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,30 @@ public function getReadmeHtml()
}


/**
* 根据config文件中的readme_mode的值解析README文档文件
*
* @return string config html内容
* @access public
*/
public function getReadme()
{
$readme_mode = $this->getConfig("readme_mode");
// 如果配置为空,默认使用Markdown方式
if ($readme_mode == "") {
return $this->getMarkdownHtml();
}
// 字符串转大写
$readme_mode = strtoupper($readme_mode);
// 如果为Markdown
if ($readme_mode == "MD") {
return $this->getMarkdownHtml();
}
return $this->getReadmeHtml();
}



/**
* 将消息添加到系统消息数组
*
Expand Down
7 changes: 5 additions & 2 deletions resources/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
'hide_dot_files' => true,
'list_folders_first' => true,
'list_sort_order' => 'natcasesort',
// 主题名称
'theme_name' => 'bootstrap',
'external_links_new_window' => true,
// README文档文件的解析模式:html、md
'readme_mode' => "md",

// 隐藏文件
'hidden_files' => array(
Expand Down Expand Up @@ -48,8 +51,8 @@
// 允许以zip文件格式下载目录
'zip_dirs' => false,

// Stream zip file content directly to the client,
// without any temporary file
// 直接将zip文件内容流式传输到客户端,
// 没有任何临时文件
'zip_stream' => true,

'zip_compression_level' => 0,
Expand Down
6 changes: 3 additions & 3 deletions resources/themes/bootstrap/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
$web_title = $lister->getConfig('web_title');
// 当前路径
$listed_path = $lister->getListedPath();
$md_text = $lister->getMarkdownText();
$md_html = $lister->getMarkdownHtml();
// 当前目录中的README文档文件内容
$readme_html = $lister->getReadme();
// 面包屑导航
$breadcrumbs = $lister->listBreadcrumbs();
?>
Expand Down Expand Up @@ -160,7 +160,7 @@
<div class="readme" id="readme">
';
echo $readme_top;
echo $md_html;
echo $readme_html;
echo "</div>", "</div>";
}
?>
Expand Down

0 comments on commit 440b345

Please sign in to comment.