Module:Aware/sandbox
| This is the module sandbox page for Module:Aware (diff). |
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.detect(frame)
local title
local args = getArgs(frame)
if args.testTitle then
title = mw.title.new(args.testTitle)
else
title = mw.title.getCurrentTitle()
end
local content = title:getContent() or ''
local codes = string.match(content, "{{%s-[cC]ontentious [tT]opics/[aA]ware%s-|([^}]-)}}")
local shortcutCodes = string.match(content, "{{%s-[cC][tT]/[aA]ware%s-|([^}]-)}}")
local dsCodes = string.match(content, "{{%s-D[sS]/[aA]ware%s-|([^}]-)}}")
if (not codes) and (not dsCodes) and (not shortcutCodes) then return end
local text
if ( codes ) then
text = p._listToText(frame, mw.text.split(codes, "\n? *|"))
elseif ( dsCodes ) then
text = p._listToText(frame, mw.text.split(dsCodes, "\n? *|"))
else
text = p._listToText(frame, mw.text.split(shortcutCodes, "\n? *|"))
end
return frame:preprocess(
"<div style = 'font-weight: bold'>It is not necessary to notify this user about the following topics being contentious topics:"
..text..
"\n The user has indicated that they are already aware using the template <nowiki>{{Contentious topics/aware}}</nowiki> on their talk page.</div>"
)
end
function p.listToText(frame)
return p._listToText(frame, getArgs(frame))
end
function p._listToText(frame, t)
local new = {}
local t = require('Module:TableTools').compressSparseArray(t)
for i,v in ipairs(t) do
table.insert(new, frame:expandTemplate{
title = 'Contentious_topics/list',
args = {["scope"] = require('Module:Wikitext Parsing').PrepareText(v)}})
end
return '\n*'..table.concat(new, '\n*')
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.