diff --git a/.gitignore b/.gitignore index d34c599..a7be932 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ # --------------------------------------------------------------------------- # 部署脚本(与具体服务器、账号、路径绑定) -# 统一放在 ~/code/_tooling/ 下,不属于应用源码,不入库 +# 不属于应用源码,按需放在仓库之外,不入库 # --------------------------------------------------------------------------- /deploy/ diff --git a/.htaccess b/.htaccess index 10f7542..1628f84 100644 --- a/.htaccess +++ b/.htaccess @@ -20,7 +20,7 @@ Options -Indexes # # 背景(2026-09-28 线上实测):服务器装了宝塔面板的「网站加速」,那是一层基于 # memcached 的整页缓存(脚本 /www/server/speed/httpd_speed.lua,站点配置 -# /www/server/speed/config.lua 里 n.yangyq.net 这节,expire=30 秒)。它的缓存键 +# /www/server/speed/config.lua 里该站点那一节,expire=30 秒)。它的缓存键 # 按 host:port + 完整 URI 计算,只缓存 GET 的 text/html。 # # 关键坑:它**读不到 FastCGI 后端返回的 Cache-Control**(实测存下来的副本里 diff --git a/LICENSE b/LICENSE index 3a6327d..5fc005d 100644 --- a/LICENSE +++ b/LICENSE @@ -58,7 +58,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. -Copyright 2026 laoyang +Copyright 2026 The SimpleNav Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index c03ea43..7a36bf1 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ - **合集区可「标签页折叠」或「全部平铺」**:底部「合集」区有两种展示方式,后台「设置 → 合集显示方式」一键切换。条目不多时选**全部平铺**(每个合集各占一块,一眼看全、不用点);合集多或条目杂时选**标签页折叠**(默认只展开当前那一个)。 - **前后台永远一致**:所有动态页面都发 `Cache-Control: no-store, no-cache`,静态资源走「长缓存 + 版本号」(文件名不变、URL 带 `?v=mtime-size`)。 -## 页面结构(复刻 n.yangyq.net 风格) +## 页面结构 1. 顶部:搜索引擎切换 + 搜索框(带联想下拉) 2. 中部:网格板块(如「常用」「工具」)——「展示方式」选「普通网格板块」的板块都在这里 @@ -46,22 +46,30 @@ SimpleNav/ ## 部署 -1. 上传全部文件到站点目录(如 `/www/wwwroot/n.yangyq.net/simplenav`)。 +1. 上传全部文件到站点目录(如 `/var/www/html`,或虚拟主机常见的 `/www/wwwroot/example.com`)。 2. 确保 web 用户对 `data/` 与 `uploads/icons/` 有写权限。 + (`data/` 不入库——它是运行时生成的 SQLite 数据库,首次部署请自行创建该目录。) 3. 服务器需开启 PHP 的 **GD 扩展**(图标规范化要用)与 `curl`。 4. 浏览器打开站点 → 首次访问进入「初始化管理员」,创建账号后即可在后台管理。 -5. 若服务器是 **Apache**(宝塔默认可能装 Apache 或 Nginx),`data/` 的访问拦截由仓库自带的 - `data/.htaccess` + 根目录 `.htaccess` 完成,无需改 vhost;若是 Nginx,请把 - `nginx-simplenav-deny-data.conf`(见本机 `_tooling/simplenav-deploy/`)里的规则加进 `server{}`。 +5. 阻止外部访问数据库目录: + - **Apache**:根目录 `.htaccess` 里已含 `RewriteRule ^data/ - [F,L]`,无需改 vhost; + - **Nginx**:在 `server{}` 里自行加一条规则: -服务器上创建最小权限部署账号:以 root 运行 `setup-simplenav-user.sh`(同样在 `_tooling/simplenav-deploy/`)。 + ```nginx + location ^~ /data/ { deny all; } + ``` -> 需要额外说明的是:**服务器上若装了宝塔「网站加速」之类的页面缓存插件,本站也不需要为它做任何特殊配置**。 -> 动态页发的 `Cache-Control: ... no-cache ...` 会被这类插件视为「不缓存」而直接跳过写入。 +若用独立的低权限账号(而非 root)上传,只需保证它对该站点目录有写权限即可—— +推荐用 POSIX ACL 授权,**不要把站点文件属主改成它**。 + +> 关于页面缓存插件的坑:宝塔面板的「网站加速」(Apache + memcached 整页缓存)**读不到** +> FastCGI 后端返回的 `Cache-Control`,会出现「后台改完、前台刷新还是旧的」。 +> 仓库自带的根目录 `.htaccess` 已在**请求侧**注入旁路标记(`Cookie: X_CACHE=1`)绕过它, +> 无需额外配置;若你用的是别的缓存层,请确认它是否尊重后端的 `Cache-Control`。 ## 搜索联想(建议词)说明 -联想接口必须由**服务端代理**(浏览器直接调用会跨域)。2026-09-28 在本站服务器实测各家的可用性: +联想接口必须由**服务端代理**(浏览器直接调用会跨域)。下面是 2026-09-28 在各家接口上实测的可用性(测试机位于中国大陆): | 引擎 | 联想接口 | 实测 | 结论 | |---|---|---|---| diff --git a/assets/css/style.css b/assets/css/style.css index 6db355a..72cd779 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -1,5 +1,5 @@ /* 简航 SimpleNav —— 前台样式 - 在 n.yangyq.net「浅灰底 + 白卡片」基础上做了现代化处理: + 在经典「浅灰底 + 白卡片」导航站风格基础上做了现代化处理: 圆角更大、阴影分层、悬停微动效、顶部品牌区与胶囊式搜索引擎切换。 */ :root { --primary: #2F6BF7; diff --git a/config.php b/config.php index 6f5c1f7..af0930b 100644 --- a/config.php +++ b/config.php @@ -22,7 +22,7 @@ define('ICON_STORE', 128); // 图标统一存成 128×128 * 是否「由 PHP 再发一颗」绕开服务器侧页面缓存的标记 cookie。 * * 背景(2026-09-28 线上实测):服务器装了宝塔面板的「网站加速」,它是一层基于 - * memcached 的整页缓存,本站在其 n.yangyq.net 配置里的过期时间是 30 秒。实测它 + * memcached 的整页缓存,本站实测其过期时间是 30 秒。实测它 * **读不到** FastCGI 后端返回的 `Cache-Control` 响应头,所以 `no-store` 之类对它 * 无效;它唯一认的信号是**请求** cookie `X_CACHE=1`。 * diff --git a/db.php b/db.php index 74c32e2..4e832b1 100644 --- a/db.php +++ b/db.php @@ -1,7 +1,7 @@