匿名
未登录
中文(中国大陆)
登录
深色模式
「荏苒之境」
搜索
查看“︁模块:Discussions”︁的源代码
来自「荏苒之境」
命名空间
模块
讨论
更多
更多
页面操作
阅读
查看源代码
历史
清除缓存
←
模块:Discussions
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local discussions = {} local API_PAGEINFO = "http://localhost/api.php?action=discussiontoolspageinfo&format=json&prop=threaditemshtml&excludesignatures=1&formatversion=2&page=" local function get_topics(title) local d, e = mw.ext.externaldata.getExternalData { url = API_PAGEINFO..title, format = "json" } if e then error("发起请求失败") end return d[1]["__json"]["discussiontoolspageinfo"]["threaditemshtml"] end discussions.get_topics = get_topics local function get_topic_timestamp(name) local time_str = string.sub(name, string.find(name, "-[^-]*$") + 1) return tonumber(time_str) end discussions.show = function(frame) local title = frame.args.title local limit = tonumber(frame.args.limit) or 5 local topics = get_topics(title) for i = 1, #topics do local topic = topics[i] topic.timestamp = get_topic_timestamp(topic.name) end table.sort(topics, function(t1, t2) return t1.timestamp < t2.timestamp end) local t = {"<ul>"} for i = #topics, math.max(1, #topics - limit) do t[#t+1] = "<li>" t[#t+1] = topics[i].html t[#t+1] = "</li>" end t[#t+1] = "</ul>" return table.concat(t) end return discussions
该页面使用的模板:
模块:Discussions/doc
(
查看源代码
)
返回
模块:Discussions
。
导航
导航
最近更改
随机页面
特殊页面
模板列表
wiki工具
wiki工具
Cargo数据
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志