Warning: is_readable(): open_basedir restriction in effect. File(/gitinfo/info.json) is not within the allowed path(s): (/www/wwwroot/ANDERSYSWIKI/:/tmp/:/dev/) in /www/wwwroot/ANDERSYSWIKI/includes/utils/GitInfo.php on line 149
模块:名言板 - Ander. System Wiki
打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:名言板

来自Ander. System Wiki
Ander留言 | 贡献2026年7月28日 (二) 22:53的版本 (创建页面,内容为“-- Module:名言板 local p = {} local data = mw.loadData("Module:名言板/data") -- 渲染单条名言卡片 local function renderQuote(item) return '<div class="as-quote-card">' .. '<div class="as-quote-mark">“</div>' .. '<div class="as-quote-text">' .. item.quote .. "</div>" .. '<div class="as-quote-author">—— " .. item.author .. "</div>" .. '<div class="as-quote-cat"><span class="as-tag">'…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:名言板/doc创建

-- Module:名言板
local p = {}
local data = mw.loadData("Module:名言板/data")

-- 渲染单条名言卡片
local function renderQuote(item)
    return '<div class="as-quote-card">'
        .. '<div class="as-quote-mark">“</div>'
        .. '<div class="as-quote-text">' .. item.quote .. "</div>"
        .. '<div class="as-quote-author">—— [[' .. item.page .. "|" .. item.author .. "]]</div>"
        .. '<div class="as-quote-cat"><span class="as-tag">' .. item.category .. "</span></div>"
        .. "</div>"
end

-- 收集所有分类(保持顺序,去重)
local function getCategories()
    local seen = {}
    local cats = {}
    for _, item in ipairs(data) do
        if item.category and not seen[item.category] then
            seen[item.category] = true
            table.insert(cats, item.category)
        end
    end
    return cats
end

-- 主入口
function p.render(frame)
    local categories = getCategories()

    -- 页面头部
    local html = '<div class="as-page-header">'
        .. '<div class="as-page-label">★ QUOTE BOARD</div>'
        .. '<div class="as-page-title">搞笑名言板</div>'
        .. '<div class="as-page-desc">收录 Ander.System 日常语录,仅供娱乐,切勿当真</div>'
        .. "</div>"

    -- 筛选栏
    local tabs = '<span class="as-filter-tab as-active">全部</span>'
    for _, cat in ipairs(categories) do
        tabs = tabs .. '<span class="as-filter-tab">[[#' .. cat .. "|" .. cat .. "]]</span>"
    end
    html = html .. '<div class="as-filter-bar">'
        .. '<div class="as-filter-label">分类筛选</div>'
        .. '<div class="as-filter-tabs">' .. tabs .. "</div>"
        .. "</div>"

    -- 全部名言网格
    html = html .. '<div class="as-section-label" id="全部名言">全部名言</div>'
    html = html .. '<div class="as-quote-grid">'
    for _, item in ipairs(data) do
        html = html .. renderQuote(item)
    end
    html = html .. "</div>"

    -- 按分类输出
    for _, cat in ipairs(categories) do
        html = html .. '<div class="as-section-label" id="' .. cat .. '">' .. cat .. "</div>"
        html = html .. '<div class="as-quote-grid">'
        for _, item in ipairs(data) do
            if item.category == cat then
                html = html .. renderQuote(item)
            end
        end
        html = html .. "</div>"
    end

    return html
end

return p