Module:PageNotice: Difference between revisions
Created page with "local p = {} function p.checkCategory(frame) local categories = { ["Needs Polish"] = "Notice Needs Polish", ["Stub"] = "Notice Stub", ["Stub for LLM content"] = "Notice Stub for LLM content", ["Raw LLM output"] = "Notice LLM raw" } for category, notice in pairs(categories) do if mw.title.getCurrentTitle():inCategory(category) then return frame:expandTemplate{ title = notice } end end retur..." |
No edit summary |
||
Line 9: | Line 9: | ||
} | } | ||
local title = mw.title.getCurrentTitle() | |||
for category, notice in pairs(categories) do | for category, notice in pairs(categories) do | ||
local categoryTitle = mw.title.new("Category:" .. category) | |||
local pagesInCategory = mw.site.stats.pagesInCategory(categoryTitle) | |||
if pagesInCategory and pagesInCategory[title.fullText] then | |||
return frame:expandTemplate{ title = notice } | return frame:expandTemplate{ title = notice } | ||
end | end |
Revision as of 10:00, 31 May 2024
Documentation for this module may be created at Module:PageNotice/doc
local p = {}
function p.checkCategory(frame)
local categories = {
["Needs Polish"] = "Notice Needs Polish",
["Stub"] = "Notice Stub",
["Stub for LLM content"] = "Notice Stub for LLM content",
["Raw LLM output"] = "Notice LLM raw"
}
local title = mw.title.getCurrentTitle()
for category, notice in pairs(categories) do
local categoryTitle = mw.title.new("Category:" .. category)
local pagesInCategory = mw.site.stats.pagesInCategory(categoryTitle)
if pagesInCategory and pagesInCategory[title.fullText] then
return frame:expandTemplate{ title = notice }
end
end
return "" -- Return an empty string if no category matches
end
return p