模块:Dictionary/Complete.lua:修订间差异
来自「荏苒之境」
无编辑摘要 |
小 Sicusa移动页面模块:Dictionary-Complete.lua至模块:Dictionary/Complete.lua,不留重定向 |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
local dict_views = require("Module:Dictionary | local dict_views = require("Module:Dictionary/Views.lua") | ||
local dict_utils = require("Module:Dictionary | local dict_utils = require("Module:Dictionary/Utils.lua") | ||
local cargo = mw.ext.cargo | local cargo = mw.ext.cargo | ||
第12行: | 第12行: | ||
local language = frame.args.language | local language = frame.args.language | ||
local dictPage = frame.args.dictionaryPage | local dictPage = frame.args.dictionaryPage | ||
local query = cargo.query(DICT_TABLE, "Spelling,Definition,Extra", { | local query = cargo.query(DICT_TABLE, "Spelling,Definition,Extra,Priority", { | ||
where = | where = "Language=\""..language.."\"", | ||
limit = 100000 | limit = 100000 | ||
}) | }) | ||
第27行: | 第25行: | ||
if query[i].Priority == DICT_HEADER_PRIORITY then | if query[i].Priority == DICT_HEADER_PRIORITY then | ||
header = dict_utils.expand_row(query[i]) | header = dict_utils.expand_row(query[i]) | ||
break | |||
end | end | ||
end | end | ||
if header == nil then | if header == nil then | ||
error(" | error("标题行未找到") | ||
end | end | ||
2025年8月5日 (二) 00:57的最新版本
此模块的文档可以在模块:Dictionary/Complete.lua/doc创建
local dict_views = require("Module:Dictionary/Views.lua")
local dict_utils = require("Module:Dictionary/Utils.lua")
local cargo = mw.ext.cargo
local DICT_TABLE = dict_views.TABLE
local DICT_HEADER_PRIORITY = tostring(dict_utils.HEADER_PRIORITY)
local complete = {}
complete.show = function(frame)
local language = frame.args.language
local dictPage = frame.args.dictionaryPage
local query = cargo.query(DICT_TABLE, "Spelling,Definition,Extra,Priority", {
where = "Language=\""..language.."\"",
limit = 100000
})
if #query == 0 then
return "无词条。"
end
local header
for i = 1, #query do
if query[i].Priority == DICT_HEADER_PRIORITY then
header = dict_utils.expand_row(query[i])
break
end
end
if header == nil then
error("标题行未找到")
end
local extra_count = #header - 2
local rows = {}
local template_head = "{{词典条目|语言标识码="..language.."|拼写="
for i = 1, #query do
local raw = query[i]
if raw.Priority ~= DICT_HEADER_PRIORITY then
local row = dict_utils.expand_row(raw, extra_count)
local spelling = row[1]
local entry_page = dictPage.."/"..spelling
row[1] = "[["..entry_page.."|"..spelling.."]]"
rows[#rows+1] = row
mw.site.createPage(
entry_page, template_head..spelling.."}}")
end
end
return dict_views.vocabulary(header, rows)
end
return complete