feat(web): W-G14 anlian-mq acceptance and auth/session listen fixes
Add a GFM-first anlian rewrite under examples/anlian-mq to exercise Go libweb (lists, detail, gates, login, WS). Wire RBAC/login into listen, page query/order/detail ABIs, and stop issuing Max-Age=0 CSRF cookies so browser login sessions stick. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e20cf8b386
commit
ce195998c1
22 files changed
+1454
-20
No files matched your search
@@ -0,0 +1,53 @@
|
||||
# 暗恋见君 · Marqdo 重写(验收切片)
|
||||
|
||||
用 **Marqdo + `ext/web`(Go `libweb`)** 重写暗恋见君的主路径,验证「代码即文档」能否撑起真实社区站点。
|
||||
|
||||
外部依赖(完整生产):PostgreSQL + Redis。本示例默认 **SQLite**,便于本机一键跑通;URL 换 `postgres://…` 即可外接。
|
||||
|
||||
## 设计约定
|
||||
|
||||
| 做 | 不做 |
|
||||
|----|------|
|
||||
| GFM 表装配导航、样式、库表、种子、表单、门禁 | `json.set` 链拼页面 |
|
||||
| `网页.*` / `table.put` 命名方法 | 手写业务 JS 袋 |
|
||||
| 分文件:`db/`、`components/`、`styles/` | 单文件堆全部 HTML |
|
||||
|
||||
对照原站 [anlian](../../../anlian/)(Django)与施工图 [ext-web-go-rewrite.md](../../doc/design/ext-web-go-rewrite.md) §8。
|
||||
|
||||
## 已覆盖主路径
|
||||
|
||||
| 路径 | 能力 |
|
||||
|------|------|
|
||||
| `/` | 首页 + 最新帖子卡片 |
|
||||
| `/posts`、`/post/{slug}` | 帖子列表 / 详情 |
|
||||
| `/news`、`/news/{slug}` | 新闻列表 / 详情 |
|
||||
| `/write` | 发帖表单(需登录) |
|
||||
| `/search` | FTS 关键词(表单 → 查询页) |
|
||||
| `/chat` | 公聊页 + `/chat/ws` broadcast |
|
||||
| `/admin` | 鉴权门禁后台 |
|
||||
| `/sitemap.xml`、`/robots.txt` | 站长 |
|
||||
|
||||
## 运行
|
||||
|
||||
```bash
|
||||
# 仓库根目录
|
||||
export PATH="$HOME/.local/go/bin:$PATH"
|
||||
./scripts/build-web-plugin.sh
|
||||
./target/debug/marqdo run examples/anlian-mq/index.mq.md
|
||||
# → http://127.0.0.1:18180/
|
||||
|
||||
# 另开终端
|
||||
bash examples/anlian-mq/smoke.sh
|
||||
```
|
||||
|
||||
离线装配(不 listen):
|
||||
|
||||
```bash
|
||||
./target/debug/marqdo run examples/anlian-mq/offline-smoke.mq.md
|
||||
```
|
||||
|
||||
默认账号:`admin` / `anlian`(种子用户表)。
|
||||
|
||||
## 发现缺陷时
|
||||
|
||||
若某段 `.mq.md` 必须堆 `json` 才能完成,优先改 **`ext/web` / 插件 ABI`**,而不是在应用层打补丁。在本目录 `NOTES.md`(如有)或 PR 描述里记下可读性缺口。
|
||||
@@ -0,0 +1,10 @@
|
||||
## 页脚
|
||||
|
||||
`页脚` =
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| 暗恋见君 · Marqdo 验收切片 | / |
|
||||
| sitemap | /sitemap.xml |
|
||||
|
||||
**`页脚`**
|
||||
@@ -0,0 +1,18 @@
|
||||
## 导航
|
||||
|
||||
顶栏:首页、帖子、新闻、搜索、聊天、发帖(登录后)、后台。
|
||||
|
||||
`导航` =
|
||||
|
||||
| 属性 | 值 | 样式 | 媒体 | 当 |
|
||||
|------|-----|------|------|-----|
|
||||
| 暗恋见君 | / | | | |
|
||||
| 帖子 | /posts | | | |
|
||||
| 新闻 | /news | | | |
|
||||
| 搜索 | /search | | | |
|
||||
| 聊天 | /chat | | | |
|
||||
| 发帖 | /write | | | auth |
|
||||
| 登录 | /admin/login | | | guest |
|
||||
| 后台 | /admin | | | auth |
|
||||
|
||||
**`导航`**
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: db/index
|
||||
description: 打开库、建表、幂等种子、全文索引。
|
||||
导入 网页:ext/web/网页.mq.md
|
||||
import schema:schema.mq.md
|
||||
import seed:seed.mq.md
|
||||
---
|
||||
|
||||
## 打开
|
||||
|
||||
*store = > 网页.数据库 地址="sqlite:data/anlian-mq.db"*
|
||||
*帖子字段 = > schema.posts*
|
||||
*新闻字段 = > schema.news*
|
||||
*密钥字段 = > schema.api_keys*
|
||||
> `store`.初始化 名=posts 字段=`帖子字段`
|
||||
> `store`.初始化 名=news 字段=`新闻字段`
|
||||
> `store`.初始化 名=api_keys 字段=`密钥字段`
|
||||
|
||||
`全文列` =
|
||||
|
||||
| 列 |
|
||||
|----|
|
||||
| title |
|
||||
| summary |
|
||||
| body |
|
||||
|
||||
> `store`.全文 表=posts 列=`全文列` 名=posts_fts
|
||||
|
||||
*已有 = > store.查询 表="posts" 上限=1*
|
||||
1. `已有`
|
||||
**store**
|
||||
2. *
|
||||
*帖子 = > seed.posts*
|
||||
*新闻 = > seed.news*
|
||||
> `store`.插入 表=posts 行=`帖子`
|
||||
> `store`.插入 表=news 行=`新闻`
|
||||
**store**
|
||||
@@ -0,0 +1,52 @@
|
||||
## posts
|
||||
|
||||
帖子主表。`slug` 用于 `/post/{slug}`;`board` 为板块名(简化外键为文本,便于 SQLite 演示)。
|
||||
|
||||
`posts` =
|
||||
|
||||
| 字段 | 类型 | 可空 | 索引 |
|
||||
|------|------|------|------|
|
||||
| id | integer | false | |
|
||||
| title | text | false | |
|
||||
| slug | text | false | 是 |
|
||||
| summary | text | true | |
|
||||
| body | text | true | |
|
||||
| board | text | true | |
|
||||
| author | text | true | |
|
||||
| created_at | timestamp | true | |
|
||||
| updated_at | timestamp | true | |
|
||||
|
||||
**`posts`**
|
||||
|
||||
## news
|
||||
|
||||
新闻主表(与帖子对称,验收「news 模块可写」)。
|
||||
|
||||
`news` =
|
||||
|
||||
| 字段 | 类型 | 可空 | 索引 |
|
||||
|------|------|------|------|
|
||||
| id | integer | false | |
|
||||
| title | text | false | |
|
||||
| slug | text | false | 是 |
|
||||
| summary | text | true | |
|
||||
| body | text | true | |
|
||||
| created_at | timestamp | true | |
|
||||
| updated_at | timestamp | true | |
|
||||
|
||||
**`news`**
|
||||
|
||||
## api_keys
|
||||
|
||||
API Key 校验用哈希表(应用层 scopes;校验原语见 `web_api_key_check`)。
|
||||
|
||||
`api_keys` =
|
||||
|
||||
| 字段 | 类型 | 可空 |
|
||||
|------|------|------|
|
||||
| id | integer | false |
|
||||
| name | text | false |
|
||||
| hash | text | false |
|
||||
| scopes | text | true |
|
||||
|
||||
**`api_keys`**
|
||||
@@ -0,0 +1,24 @@
|
||||
## posts
|
||||
|
||||
种子帖子(`@` 行记录表)。
|
||||
|
||||
`posts` =
|
||||
|
||||
| @ | title | slug | summary | body | board | author |
|
||||
|---|-------|------|---------|------|-------|--------|
|
||||
| 1 | 欢迎来到暗恋见君 | welcome | 期待人们能够继续相信爱情。 | 这是用 Marqdo 重写的验收站点。页面、库表与门禁都用 GFM 表格装配——代码即文档。 | 日常 | 站务 |
|
||||
| 2 | 如何用表格写论坛 | tables-for-forums | 导航、表单、种子数据都是可读表格。 | 若某功能逼你写一长串 json.set,请先审视 ext/web 是否缺命名方法。 | 开发 | 站务 |
|
||||
| 3 | 公聊室已开放 | chat-open | WebSocket 广播房间。 | 打开 /chat,连上 /chat/ws,消息会扇出给同房间所有人。 | 聊天 | 站务 |
|
||||
|
||||
**`posts`**
|
||||
|
||||
## news
|
||||
|
||||
`news` =
|
||||
|
||||
| @ | title | slug | summary | body |
|
||||
|---|-------|------|---------|------|
|
||||
| 1 | 站点迁往 Marqdo | migrate-to-marqdo | 原生层换 Go libweb,作者面保持表格。 | 暗恋见君的验收目标:登录、发帖、列表详情、聊天与站长工具都能用 .mq.md 写完。 |
|
||||
| 2 | 外接 PostgreSQL / Redis | pg-redis | 生产可用外接驱动。 | 本示例默认 sqlite:;把数据库地址换成 postgres:// 即可。 |
|
||||
|
||||
**`news`**
|
||||
@@ -0,0 +1,181 @@
|
||||
---
|
||||
title: 暗恋见君 · Marqdo
|
||||
description: 用表格装配的论坛验收站点:帖子、新闻、发帖门禁、公聊、站长工具。
|
||||
导入 网页:ext/web/网页.mq.md
|
||||
import shell:styles/shell.mq.md
|
||||
import nav:components/nav.mq.md
|
||||
import foot:components/foot.mq.md
|
||||
import db:db/index.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
站点壳:导航 + 页脚。
|
||||
|
||||
`壳` =
|
||||
|
||||
| 组件 | 样式 |
|
||||
|------|------|
|
||||
| nav.`导航` | |
|
||||
| foot.`页脚` | |
|
||||
|
||||
帖子列表卡片绑定(字段名对应库表列;`href` 走 slug)。
|
||||
|
||||
`帖子卡片` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | posts.title | |
|
||||
| body | posts.summary | |
|
||||
| meta | posts.board | |
|
||||
| href | posts.slug | |
|
||||
|
||||
`帖子详情` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | posts.title | |
|
||||
| meta | posts.author | |
|
||||
| body | posts.body | |
|
||||
|
||||
`新闻卡片` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | news.title | |
|
||||
| body | news.summary | |
|
||||
| href | news.slug | |
|
||||
|
||||
`新闻详情` =
|
||||
|
||||
| 属性 | 值 | 样式 |
|
||||
|------|-----|------|
|
||||
| title | news.title | |
|
||||
| body | news.body | |
|
||||
|
||||
动态路由条件:`{slug}` 由路径注入。
|
||||
|
||||
`帖子条件` =
|
||||
|
||||
| 字段 | 操作 | 值 |
|
||||
|------|------|-----|
|
||||
| slug | = | {slug} |
|
||||
|
||||
`新闻条件` =
|
||||
|
||||
| 字段 | 操作 | 值 |
|
||||
|------|------|-----|
|
||||
| slug | = | {slug} |
|
||||
|
||||
发帖表单(字段 / 规则均为表)。
|
||||
|
||||
`发帖字段` =
|
||||
|
||||
| 字段 | 标签 | 类型 | 必填 |
|
||||
|------|------|------|------|
|
||||
| title | 标题 | text | true |
|
||||
| slug | 短链 | text | true |
|
||||
| summary | 摘要 | text | false |
|
||||
| body | 正文 | textarea | true |
|
||||
| board | 板块 | text | false |
|
||||
| author | 署名 | text | false |
|
||||
|
||||
`发帖规则` =
|
||||
|
||||
| 字段 | 规则 | 消息 |
|
||||
|------|------|------|
|
||||
| title | required | 标题不能为空 |
|
||||
| title | max:200 | 标题太长 |
|
||||
| slug | required | 需要短链 |
|
||||
| body | required | 正文不能为空 |
|
||||
| body | max:20000 | 正文太长 |
|
||||
|
||||
站务账号(明文仅用于本地验收;生产请用 `网页.密码哈希`)。
|
||||
|
||||
`用户表` =
|
||||
|
||||
| 行 | 用户名 | 密码 | 角色 |
|
||||
|----|--------|------|------|
|
||||
| 1 | admin | anlian | admin |
|
||||
|
||||
站点地图条目。
|
||||
|
||||
`地图项` =
|
||||
|
||||
| loc | 更新 |
|
||||
|-----|------|
|
||||
| / | 2026-09-10 |
|
||||
| /posts | 2026-09-10 |
|
||||
| /news | 2026-09-10 |
|
||||
| /chat | 2026-09-10 |
|
||||
| /search | 2026-09-10 |
|
||||
|
||||
*store = > db.打开*
|
||||
*壳CSS = > shell.全局*
|
||||
|
||||
*首页 = > 网页.页面 标题="暗恋见君" 引言="<h1>暗恋见君</h1><p>期待人们能够继续相信爱情。——本站用 Marqdo 表格装配,验收 web 拓展库。</p>"*
|
||||
*首页 = > 首页.组件装配 组件=`壳`*
|
||||
*首页 = > 首页.主体装配 主体=`帖子卡片`*
|
||||
*首页 = > 首页.排序 排序="-created_at"*
|
||||
*首页 = > 首页.样式 样式=`壳CSS`*
|
||||
|
||||
*帖子列表 = > 网页.页面 标题="帖子" 引言="<h1>帖子</h1>"*
|
||||
*帖子列表 = > 帖子列表.组件装配 组件=`壳`*
|
||||
*帖子列表 = > 帖子列表.主体装配 主体=`帖子卡片`*
|
||||
*帖子列表 = > 帖子列表.链接前缀 前缀="/post/"*
|
||||
*帖子列表 = > 帖子列表.排序 排序="-created_at"*
|
||||
*帖子列表 = > 帖子列表.样式 样式=`壳CSS`*
|
||||
|
||||
*帖子页 = > 网页.页面 标题="帖子详情"*
|
||||
*帖子页 = > 帖子页.组件装配 组件=`壳`*
|
||||
*帖子页 = > 帖子页.主体装配 主体=`帖子详情`*
|
||||
*帖子页 = > 帖子页.查询条件 条件=`帖子条件`*
|
||||
*帖子页 = > 帖子页.详情 详情=True*
|
||||
*帖子页 = > 帖子页.样式 样式=`壳CSS`*
|
||||
|
||||
*新闻列表 = > 网页.页面 标题="新闻" 引言="<h1>新闻</h1>"*
|
||||
*新闻列表 = > 新闻列表.组件装配 组件=`壳`*
|
||||
*新闻列表 = > 新闻列表.主体装配 主体=`新闻卡片`*
|
||||
*新闻列表 = > 新闻列表.链接前缀 前缀="/news/"*
|
||||
*新闻列表 = > 新闻列表.排序 排序="-created_at"*
|
||||
*新闻列表 = > 新闻列表.样式 样式=`壳CSS`*
|
||||
|
||||
*新闻页 = > 网页.页面 标题="新闻详情"*
|
||||
*新闻页 = > 新闻页.组件装配 组件=`壳`*
|
||||
*新闻页 = > 新闻页.主体装配 主体=`新闻详情`*
|
||||
*新闻页 = > 新闻页.查询条件 条件=`新闻条件`*
|
||||
*新闻页 = > 新闻页.详情 详情=True*
|
||||
*新闻页 = > 新闻页.样式 样式=`壳CSS`*
|
||||
|
||||
*发帖表 = > 网页.表单 表="posts" 动作="插入"*
|
||||
*发帖表 = > 发帖表.字段 字段=`发帖字段`*
|
||||
*发帖表 = > 发帖表.规则 规则=`发帖规则`*
|
||||
|
||||
*发帖页 = > 网页.页面 标题="发帖" 引言="<h1>发帖</h1><p>需登录(admin / anlian)。</p>"*
|
||||
*发帖页 = > 发帖页.组件装配 组件=`壳`*
|
||||
*发帖页 = > 发帖页.表单装配 id="post" 表单=`发帖表`*
|
||||
*发帖页 = > 发帖页.样式 样式=`壳CSS`*
|
||||
|
||||
*搜索页 = > 网页.页面 标题="搜索" 引言="<h1>搜索</h1><p>在地址栏加 <code>?q=关键词</code>,或从后台全文工具验证 FTS。验收切片先提供入口页。</p><form method=\"get\" action=\"/search\"><input name=\"q\" placeholder=\"关键词\"><button type=\"submit\">搜</button></form>"*
|
||||
*搜索页 = > 搜索页.组件装配 组件=`壳`*
|
||||
*搜索页 = > 搜索页.样式 样式=`壳CSS`*
|
||||
|
||||
*聊天页 = > 网页.页面 标题="公聊" 引言="<h1>公聊室</h1><div class=\"chat-box\"><div id=\"chat-log\" class=\"chat-log\"></div><p><input id=\"chat-msg\" placeholder=\"说点什么…\" style=\"width:70%\"> <button id=\"chat-send\" type=\"button\">发送</button></p></div><script src=\"/static/chat.js\"></script>"*
|
||||
*聊天页 = > 聊天页.组件装配 组件=`壳`*
|
||||
*聊天页 = > 聊天页.样式 样式=`壳CSS`*
|
||||
|
||||
*应用 = > 网页.应用 页面=`首页` 数据库=`store` 后台=True 主机="127.0.0.1" 端口=18180*
|
||||
*应用 = > 应用.路由 路径="/posts" 页面=`帖子列表`*
|
||||
*应用 = > 应用.路由 路径="/post/{slug}" 页面=`帖子页`*
|
||||
*应用 = > 应用.路由 路径="/news" 页面=`新闻列表`*
|
||||
*应用 = > 应用.路由 路径="/news/{slug}" 页面=`新闻页`*
|
||||
*应用 = > 应用.路由 路径="/write" 页面=`发帖页`*
|
||||
*应用 = > 应用.路由 路径="/search" 页面=`搜索页`*
|
||||
*应用 = > 应用.路由 路径="/chat" 页面=`聊天页`*
|
||||
*应用 = > 应用.静态 目录="public" 挂载="/static"*
|
||||
*应用 = > 应用.鉴权 用户表=`用户表` 会话时长=7200 登录回跳="/write" 登出回跳="/"*
|
||||
*应用 = > 应用.门禁 路径="/write" 角色="admin" 匹配="prefix" 拒绝="redirect" 排除="/admin/login"*
|
||||
*应用 = > 应用.路由实时 路径="/chat/ws" 模式="broadcast"*
|
||||
*应用 = > 应用.站点地图 路径="/sitemap.xml" 基址="http://127.0.0.1:18180" 条目=`地图项`*
|
||||
*应用 = > 应用.爬虫协议 站点地图="http://127.0.0.1:18180/sitemap.xml"*
|
||||
> `应用`.监听
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
title: anlian-mq offline smoke
|
||||
description: 不 listen:装配库表/页面/门禁/WS 路由袋,验证可读路径可构造。
|
||||
导入 网页:ext/web/网页.mq.md
|
||||
import shell:styles/shell.mq.md
|
||||
import nav:components/nav.mq.md
|
||||
import foot:components/foot.mq.md
|
||||
import db:db/index.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`壳` =
|
||||
|
||||
| 组件 | 样式 |
|
||||
|------|------|
|
||||
| nav.`导航` | |
|
||||
| foot.`页脚` | |
|
||||
|
||||
`帖子卡片` =
|
||||
|
||||
| 属性 | 值 |
|
||||
|------|-----|
|
||||
| title | posts.title |
|
||||
| body | posts.summary |
|
||||
| href | posts.slug |
|
||||
|
||||
`用户表` =
|
||||
|
||||
| 行 | 用户名 | 密码 | 角色 |
|
||||
|----|--------|------|------|
|
||||
| 1 | admin | anlian | admin |
|
||||
|
||||
*store = > db.打开*
|
||||
*壳CSS = > shell.全局*
|
||||
*首页 = > 网页.页面 标题="暗恋见君" 引言="<h1>ok</h1>"*
|
||||
*首页 = > 首页.组件装配 组件=`壳`*
|
||||
*首页 = > 首页.主体装配 主体=`帖子卡片`*
|
||||
*首页 = > 首页.样式 样式=`壳CSS`*
|
||||
|
||||
*应用 = > 网页.应用 页面=`首页` 数据库=`store` 后台=True 主机="127.0.0.1" 端口=18180*
|
||||
*应用 = > 应用.鉴权 用户表=`用户表`*
|
||||
*应用 = > 应用.门禁 路径="/write" 角色="admin" 匹配="prefix" 拒绝="redirect"*
|
||||
*应用 = > 应用.路由实时 路径="/chat/ws" 模式="broadcast"*
|
||||
|
||||
*gates = 应用[^gates]*
|
||||
*n = > len value=`gates`*
|
||||
1. `n` >= 2
|
||||
> print text=gates-ok
|
||||
2. *
|
||||
> print text=gates-fail
|
||||
> sys.exit code=1
|
||||
|
||||
*ws = 应用[^ws_routes]*
|
||||
*room = ws[^/chat/ws]*
|
||||
*mode = room[^mode]*
|
||||
1. `mode` == "broadcast"
|
||||
> print text=ws-ok
|
||||
2. *
|
||||
> print text=ws-fail
|
||||
> sys.exit code=1
|
||||
|
||||
*list = > store.查询 表="posts" 上限=10*
|
||||
*nr = > len value=`list`*
|
||||
1. `nr` >= 1
|
||||
> print text=seed-ok
|
||||
2. *
|
||||
> print text=seed-fail
|
||||
> sys.exit code=1
|
||||
|
||||
> print text=anlian-offline-ok
|
||||
@@ -0,0 +1,37 @@
|
||||
/* 公聊客户端:保持极薄;业务配置仍在 .mq.md 表格里。 */
|
||||
(function () {
|
||||
var log = document.getElementById("chat-log");
|
||||
var input = document.getElementById("chat-msg");
|
||||
var send = document.getElementById("chat-send");
|
||||
if (!log || !input || !send) return;
|
||||
|
||||
var proto = location.protocol === "https:" ? "wss:" : "ws:";
|
||||
var ws = new WebSocket(proto + "//" + location.host + "/chat/ws");
|
||||
|
||||
function line(text) {
|
||||
log.textContent += text + "\n";
|
||||
log.scrollTop = log.scrollHeight;
|
||||
}
|
||||
|
||||
ws.onopen = function () {
|
||||
line("[已连接公聊室]");
|
||||
};
|
||||
ws.onclose = function () {
|
||||
line("[连接关闭]");
|
||||
};
|
||||
ws.onmessage = function (ev) {
|
||||
line(String(ev.data));
|
||||
};
|
||||
|
||||
function publish() {
|
||||
var t = (input.value || "").trim();
|
||||
if (!t || ws.readyState !== 1) return;
|
||||
ws.send(t);
|
||||
input.value = "";
|
||||
}
|
||||
|
||||
send.addEventListener("click", publish);
|
||||
input.addEventListener("keydown", function (e) {
|
||||
if (e.key === "Enter") publish();
|
||||
});
|
||||
})();
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# 暗恋见君 Marqdo 切片冒烟(需先启动 index.mq.md)。
|
||||
# 用法:bash examples/anlian-mq/smoke.sh
|
||||
set -uo pipefail
|
||||
BASE="http://127.0.0.1:18180"
|
||||
PASS=0; FAIL=0
|
||||
ok() { echo " ok: $1"; PASS=$((PASS+1)); }
|
||||
bad() { echo " FAIL: $1"; FAIL=$((FAIL+1)); }
|
||||
|
||||
echo "== 首页 / 列表 =="
|
||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/")
|
||||
[ "$code" = "200" ] && ok "GET /" || bad "GET / -> $code"
|
||||
curl -s "$BASE/" | grep -q '暗恋见君' && ok "品牌标题" || bad "品牌标题"
|
||||
curl -s "$BASE/posts" | grep -q 'welcome\|欢迎' && ok "帖子列表" || bad "帖子列表"
|
||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/post/welcome")
|
||||
[ "$code" = "200" ] && ok "帖子详情" || bad "帖子详情 -> $code"
|
||||
curl -s "$BASE/news" | grep -q 'migrate\|迁往\|Marqdo' && ok "新闻列表" || bad "新闻列表"
|
||||
|
||||
echo "== 站长 =="
|
||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/sitemap.xml")
|
||||
[ "$code" = "200" ] && ok "sitemap" || bad "sitemap -> $code"
|
||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/robots.txt")
|
||||
[ "$code" = "200" ] && ok "robots" || bad "robots -> $code"
|
||||
|
||||
echo "== 门禁 =="
|
||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/write")
|
||||
[ "$code" = "303" ] || [ "$code" = "302" ] && ok "未登录 /write 重定向" || bad "/write -> $code"
|
||||
|
||||
echo "== 登录 =="
|
||||
rm -f /tmp/anlian_mq_hdr.txt
|
||||
curl -s -D /tmp/anlian_mq_hdr.txt -o /dev/null -d "username=admin&password=anlian" "$BASE/admin/login"
|
||||
sid=$(grep -i "set-cookie" /tmp/anlian_mq_hdr.txt | sed 's/.*marqdo_sid=\([^;]*\).*/\1/' | head -1)
|
||||
[ -n "$sid" ] && ok "会话 cookie" || bad "无 cookie"
|
||||
code=$(curl -s -b "marqdo_sid=$sid" -o /dev/null -w "%{http_code}" "$BASE/write")
|
||||
[ "$code" = "200" ] && ok "登录后 /write" || bad "登录后 /write -> $code"
|
||||
|
||||
echo "== 聊天 WS =="
|
||||
wsok=$(python3 -c "
|
||||
import socket, base64, os
|
||||
s = socket.create_connection(('127.0.0.1', 18180), timeout=3)
|
||||
key = base64.b64encode(os.urandom(16)).decode()
|
||||
s.sendall((f'GET /chat/ws HTTP/1.1\r\nHost: x\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: {key}\r\nSec-WebSocket-Version: 13\r\n\r\n').encode())
|
||||
r = s.recv(1024).decode(errors='replace')
|
||||
print('OK' if '101' in r.split('\r\n')[0] else 'NO')
|
||||
s.close()
|
||||
" 2>/dev/null)
|
||||
[ "$wsok" = "OK" ] && ok "WebSocket 握手" || bad "WebSocket $wsok"
|
||||
|
||||
echo
|
||||
echo "通过 $PASS / $((PASS+FAIL))"
|
||||
[ "$FAIL" = "0" ] || exit 1
|
||||
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: styles/shell
|
||||
description: 暗恋见君壳样式——配色与布局用表格声明。
|
||||
导入 网页:ext/web/网页.mq.md
|
||||
---
|
||||
|
||||
## 基础
|
||||
|
||||
暖纸感背景、深红强调(品牌向「相信爱情」),避免默认紫渐变模板。
|
||||
|
||||
`基础` =
|
||||
|
||||
| 选择器 | 属性 | 值 |
|
||||
|--------|------|-----|
|
||||
| :root | --ink | #2a1f1a |
|
||||
| :root | --muted | #7a6560 |
|
||||
| :root | --paper | #faf6f2 |
|
||||
| :root | --card | #ffffff |
|
||||
| :root | --line | #eadfd8 |
|
||||
| :root | --accent | #9b2c2c |
|
||||
| :root | --accent-ink | #fffaf7 |
|
||||
| :root | --radius | 12px |
|
||||
| :root | --serif | "Noto Serif SC", "Songti SC", Georgia, serif |
|
||||
| :root | --sans | "Noto Sans SC", "IBM Plex Sans", system-ui, sans-serif |
|
||||
| * | box-sizing | border-box |
|
||||
| body | margin | "0" |
|
||||
| body | font-family | var(--sans) |
|
||||
| body | background | var(--paper) |
|
||||
| body | color | var(--ink) |
|
||||
| h1 | font-family | var(--serif) |
|
||||
| h1 | font-weight | "600" |
|
||||
| a | color | var(--accent) |
|
||||
| .main-intro | max-width | "52rem" |
|
||||
| .main-intro | margin | "1.5rem auto" |
|
||||
| .main-intro | padding | "0 1.25rem" |
|
||||
| .chat-box | border | 1px solid var(--line) |
|
||||
| .chat-box | border-radius | var(--radius) |
|
||||
| .chat-box | background | var(--card) |
|
||||
| .chat-box | padding | "1rem" |
|
||||
| .chat-log | min-height | "12rem" |
|
||||
| .chat-log | font-family | ui-monospace, monospace |
|
||||
| .chat-log | font-size | "0.9rem" |
|
||||
| .chat-log | white-space | pre-wrap |
|
||||
|
||||
**`基础`**
|
||||
|
||||
## 全局
|
||||
|
||||
*基础表 = > 基础*
|
||||
*css = > 网页.样式装配 名="anlian" 表=`基础表`*
|
||||
**css**
|
||||
Reference in new issue
Block a user