Home
Random
Log in
Settings
About Chabadpedia
Chabadpedia
Search
Editing
Module:Noinclude tfd
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local redr = require("Module:Redirect") local function stringCount(string, pattern) local _dump, cnt = mw.ustring.gsub(string, pattern, "") return cnt end local function parse(frame, links) local missing = "" local hidden = "" local bogus = "" for _, object in ipairs(links) do if object then local title = "Template:" .. object; local rtarget; errorvalue, rtarget = pcall(redr.getTarget, title) if errorvalue then title = rtarget or title end local code local title = mw.title.new(title) if title == nil then bogus = bogus .. "\n* " .. title code = nil else code = title:getContent() end if code then local unsubstified = mw.ustring.match(code, "#invoke:Unsubst|"); local nmg = stringCount(code, "<noinclude>[^/]*{{Tfm") local ndel = stringCount(code, "<noinclude>[^/]*{{Template for discussion") local disabled = stringCount(code,"type=disabled") local safesubst = mw.ustring.match(code,"{{{|safesubst:}}}") or mw.ustring.match(code, "<includeonly>safesubst:</includeonly>"); safesubst = safesubst or mw.ustring.match(code,"[Ss][Aa][Ff][Ee][Ss][Uu][bB][sS][Tt]:%s*<noinclude%s*/>"); local oldstylesubst = mw.ustring.match(code, "{{{subst|}}}") or mw.ustring.match(code, "<includeonly>[Ss]ubst:</includeonly>"); local tagCnt = stringCount(code,"{{Tfm") + stringCount(code,"{{Template for merging") tagCnt = tagCnt + stringCount(code,"{{Template for discussion"); if tagCnt == 0 then if title.contentModel == "sanitized-css" then tagCnt = tagCnt + stringCount(code, "subst:[Tt]emplate for discussion|help=off") -- What twinkle does tagCnt = tagCnt + stringCount(code, "This template is being discussed in accordance with Wikipedia's") -- What the instructions say end if tagCnt == 0 then missing = missing .. "\n* {{tfd links|" .. object .. "}}"; end elseif (nmg + ndel + disabled >= tagCnt) and (unsubstified or not (safesubst or oldstylesubst)) then hidden = hidden .. "\n* {{tfd links|" .. object .. "}}"; end end end end local output = "" if #bogus > 0 then output = output .. "=== Bogus listings at TfD === \n" .. bogus .. "\n" end if #missing > 0 then output = output .. "=== Pages with no TfD tag === \n" .. missing .. "\n" end if #hidden > 0 then output = output .. "=== Pages with noincluded TfD tags === " .. hidden end return frame:preprocess(output); end local function parseDay(day, links) local daytext = mw.title.new(day):getContent(); daytext = mw.ustring.gsub(daytext,"Please do not modify it","{{tfd links|this is closed}}"); daytext = mw.ustring.gsub(daytext,"{{[tT]fd links|([^}|]+)[^}]-|module=Module:[^}]-}}", ""); daytext = mw.ustring.gsub(daytext,"{{[tT]fd links|([^}|]+)[^}]-|module=yes[^}]-}}", ""); local daymatcher = mw.ustring.gmatch(daytext, "{{[tT]fd links|([^}|]+)[^}]-}}") local closed = false while true do local link = daymatcher(); if not link then return links; end if link == "this is closed" then closed = not closed elseif link:sub(1, 7) == "S-line/" then -- "S-line/" nominations are almost always for unused templates that don't merit my attention. elseif not closed then links[#links+1] = link; end end end local p = {} function p.main(frame) local links = {}; local lang = mw.getContentLanguage() local logpage = "Wikipedia:Templates for discussion/Log/" for a = 0, 40 do parseDay(logpage .. lang.formatDate(lang, "Y F j", "-" .. tostring(a) .. "days"), links) end return parse(frame, links) end return p
Edit summary
(Briefly describe your changes)
Please note that all contributions to Chabadpedia are considered to be released under the GNU Free Documentation License 1.3 or later (see
Chabadpedia:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Noinclude tfd/doc
(
edit
)