From 55e35673046615da18f2b5f7ffdc9f6216c50358 Mon Sep 17 00:00:00 2001 From: jokin <327928971@qq.com> Date: Sat, 21 Dec 2019 22:56:42 +0800 Subject: [PATCH] add static html file generator --- .own_conf.example | 6 +++--- README.md | 4 ++-- nav.php | 24 ++++++++++++++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.own_conf.example b/.own_conf.example index 79ebeb2..58058eb 100644 --- a/.own_conf.example +++ b/.own_conf.example @@ -5,7 +5,7 @@ # 名称(标题) -NAV_NAME="MY Navigation" +NAV_NAME="OWN Navigation" # 子标题 NAV_SUBTITLE="我的导航" @@ -17,8 +17,8 @@ NAV_KEYWORDS="轻量级导航,动态导航,导航,自动导航,在线导航,导 NAV_DESCRIPTION="一个轻量级自动根据目录动态生成导航的PHP程序" # 欢迎词 -NAV_WELCOME_TITLE="MY Navigation" -NAV_WELCOME_CONTENT="MY Navigation,一个轻量级自动根据目录动态生成导航的PHP程序" +NAV_WELCOME_TITLE="OWN Navigation" +NAV_WELCOME_CONTENT="OWN Navigation,一个轻量级自动根据目录动态生成导航的PHP程序" # 尝试读取独立配置(默认YES) NAV_TRY_READ_CONF=YES diff --git a/README.md b/README.md index dd79761..4e17f5d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MY Navigation +# OWN Navigation [![](https://data.jsdelivr.com/v1/package/gh/jokin1999/my-navigation/badge)](https://www.jsdelivr.com/package/gh/jokin1999/my-navigation) @@ -65,9 +65,9 @@ cp ./.own_navi.example ./[your_subfolder]/.own_navi php nav.php [COMMAND] dc 下载配置文件 dces 下载子目录的配置文件 + static 在根目录生成静态的 index.html 文件 ``` - ## 鸣谢 界面借鉴:[MikuTools](https://github.com/Ice-Hazymoon/MikuTools) diff --git a/nav.php b/nav.php index de07029..139c6b1 100644 --- a/nav.php +++ b/nav.php @@ -39,7 +39,8 @@ // 命令行模式 if (IS_CLI) { $method = $argv[1] ?? null; - if ($method == null || $method == 'help') { + define('METHOD', $method); + if (METHOD == null || METHOD == 'help') { echo 'php '.basename(__FILE__).' [COMMAND]'.PHP_EOL; echo ' dc download default configuration file for navigation'.PHP_EOL; echo ' dces download default configuration file for each subfolder of navigation'.PHP_EOL; @@ -48,7 +49,7 @@ } // download config - if ($method == 'dc') { + if (METHOD == 'dc') { // 检查文件是否可写 if (!is_writable('./')) { exit('目录'. __DIR__ .'无法写入文件'); @@ -64,7 +65,7 @@ } // download config of each subfolder - if ($method == 'dces') { + if (METHOD == 'dces') { // 检查文件是否可写 if (!is_writable('./')) { exit('目录'. __DIR__ .'无法写入文件'); @@ -78,6 +79,8 @@ exit('获取默认配置文件失败,请稍候再试...'); } } +}else{ + define('METHOD', NULL); } // 获取合法目录 @@ -206,7 +209,13 @@ function ec(string $key) { echo c($key); } ?> - + + @@ -314,3 +323,10 @@ class="nya-btn badge" +