Modul:tagged but not listed/old
A modult a Modul:tagged but not listed/old/doc lapon tudod dokumentálni
local export = {}
local language = mw.getContentLanguage()
local function get_wikitext(title)
local titleobj = mw.title.new(title)
return titleobj:getContent()
end
-- XXX: [[mw:Extension:DynamicPageListEngine]] might make it easier, but WMF did not install it here; shame.
local function category_members(catname)
local html = mw.text.unstrip(mw.getCurrentFrame():callParserFunction("#tag", "dynamicpagelist", "category=" .. catname))
local iter, mstate, mlast = mw.ustring.gmatch(html, '<a href="/wiki/([^"]-)"')
return function (state, last)
mlast = iter(mstate, mlast)
if not mlast then
return nil
end
return mw.uri.decode(mw.text.decode(mlast), 'WIKI')
end
end
local function collect_listed_titles(bin, wikitext)
for _, header_text in wikitext:gmatch("\n(===?)%s*(.-)%s*%1%f[\n]") do
header_text = header_text:gsub("<s>.-</s>", "")
for link in header_text:gmatch("%[%[:?([^|%]]+)") do
link = mw.text.decode(mw.uri.decode(link, 'WIKI')) -- yes, in that order
link = link:match("^(.-)#") or link
bin[link] = true
end
end
return bin
end
local function make_list(titles, cat_name)
local output = {}
for member in category_members(cat_name) do
if not titles[member] then
output[#output + 1] = "* [[:" .. member .. "]]\n"
end
end
return table.concat(output)
end
function export.list_rfv(frame)
local titles = collect_listed_titles({}, get_wikitext("Wiktionary:Requests for verification"))
return make_list(titles, "Requests for verification")
end
function export.list_rfd(frame)
local titles = collect_listed_titles({}, get_wikitext("Wiktionary:Requests for deletion"))
return make_list(titles, "Requests for deletion")
end
function export.list_rfdo(frame)
local titles = collect_listed_titles({}, get_wikitext("Wiktionary:Requests for deletion/Others"))
return make_list(titles, "Requests for deletion/Others")
end
function export.list_rfc(frame)
local titles = collect_listed_titles({}, get_wikitext("Wiktionary:Requests for cleanup"))
return make_list(titles, "Requests for cleanup")
end
function export.list_rfm(frame)
local titles = collect_listed_titles({}, get_wikitext("Wiktionary:Requests for moves, mergers and splits"))
return make_list(titles, "Requests for moves, mergers and splits")
end
function export.list_rft(frame)
local titles = {}
local m0 = language:formatDate("Y/F", "first day of this month")
local m1 = language:formatDate("Y/F", "first day of this month - 1 month")
local m2 = language:formatDate("Y/F", "first day of this month - 2 months")
collect_listed_titles(titles, get_wikitext("Wiktionary:Tea room/" .. m2) or "")
collect_listed_titles(titles, get_wikitext("Wiktionary:Tea room/" .. m1) or "")
collect_listed_titles(titles, get_wikitext("Wiktionary:Tea room/" .. m0) or "")
return make_list(titles, "Tea room")
end
function export.list_votes(frame)
local html = mw.text.unstrip(frame:callParserFunction("#tag", "dynamicpagelist",
"category=Votes that have not been closed\nnotcategory=Votes that have not been opened\nnamespace=4"))
local now = language:formatDate("c")
local output = {}
for match in mw.ustring.gmatch(html, '<a href="/wiki/([^"]-)"') do
local title = mw.uri.decode(mw.text.decode(match), 'WIKI')
local wikitext = get_wikitext(title)
local grab_dates = false
local stamp
for line in mw.text.gsplit(wikitext, "\n") do
if line:match("^%*%s*Vote ends%s*:%s*") then
stamp = line:match("^%*%s*Vote ends%s*:%s*([0-9][A-Za-z0-9:, (){}]+)")
if stamp then
break
end
grab_dates = true
elseif grab_dates and line:match("^%*%*") then
stamp = line:match("^%*%*%s*Vote extended to%s*([0-9][A-Za-z0-9:, (){}]+)")
if stamp then
break
end
elseif grab_dates then
break
end
end
local iso_stamp = language:formatDate("c", stamp)
if not iso_stamp:match("^<") then -- parsing OK
-- the ISO date format has the nice property that ASCIIbetical ordering == chronological ordering.
if iso_stamp < now then
table.insert(output, "* [[" .. title .. "]]\n")
end
else
mw.log("Invalid timestamp: ", title)
end
end
return table.concat(output)
end
return export