Add marqdo-blog example with GFM-table style assembly

Introduce web_style ABI (样式装配) so themes are GFM style tables
(|选择器|属性|值|, optional |媒体| column for @media) assembled by
functions instead of hand-written CSS strings — 文档即代码. The new
examples/marqdo-blog shows a full blog: card grid, dynamic /post/{slug},
tag archive, WebSocket live widget, and session-gated admin CRUD, plus a
smoke test (15 checks) and README.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-26 13:03:55 +08:00
1 parent 7645dd4c1f
commit da9fc75b1e
20 files changed
+1518 -93

No files matched your search

+36
View File
@@ -272,6 +272,20 @@ pub fn select(
table: &str,
limit: i64,
where_v: Option<&Value>,
) -> Result<Value, String> {
select_order(url, table, limit, where_v, None)
}
/// Like `select`, with an optional `ORDER BY`.
///
/// `order` is a column name, optionally prefixed with `-` for descending
/// (`"created_at"`, `"-created_at"`). Comma-separated lists are allowed.
pub fn select_order(
url: &str,
table: &str,
limit: i64,
where_v: Option<&Value>,
order: Option<&str>,
) -> Result<Value, String> {
let table = ident(table)?;
let (clauses, mut vals) = parse_where(where_v)?;
@@ -281,6 +295,28 @@ pub fn select(
sql.push_str(" WHERE ");
sql.push_str(&clauses.join(" AND "));
}
if let Some(order) = order {
let order = order.trim();
if !order.is_empty() {
let parts: Vec<&str> = order
.split(',')
.map(|p| p.trim())
.filter(|p| !p.is_empty())
.collect();
let mut exprs = Vec::new();
for part in parts {
let (col, dir) = match part.strip_prefix('-') {
Some(col) => (col, " DESC"),
None => (part, ""),
};
exprs.push(format!("\"{}\"{}", ident(col)?, dir));
}
if !exprs.is_empty() {
sql.push_str(" ORDER BY ");
sql.push_str(&exprs.join(", "));
}
}
}
sql.push_str(&format!(" LIMIT ?{}", vals.len() + 1));
vals.push(rusqlite::types::Value::Integer(limit));
let mut stmt = conn.prepare(&sql).map_err(|e| e.to_string())?;