Content deleted Content added
Fix |
add a link to edit the css |
||
Line 3:
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')
local TNT = require('Module:TNT')
local p = {}
local function format(msg, ...)
return TNT.format('I18n/Uses TemplateStyles', msg, ...)
end
local function getConfig()
return mw.loadData('Module:Uses TemplateStyles/config')
end
local function urlEncode(str)
return mw.uri.encode(str, "WIKI")
end
Line 14 ⟶ 23:
type = 'notice',
small = true,
image = string.format('[[File:Farm-Fresh css add.svg|32px|alt=%s]]', format('
}
if #tStyles < 1 then
boxArgs.text = string.format('<strong class="error">%s</strong>', format('
else
local cfg = getConfig()
Line 24 ⟶ 33:
local link = string.format('[[:%s]]', ts)
local sandboxLink = nil
local editLink = string.format(
'[%s edit]',
"https://en.wikipedia.org/w/index.php?title=" .. urlEncode(ts) .. "&action=edit"
)
local tsTitle = mw.title.new(ts)
if tsTitle and cfg['sandbox_title'] then
Line 29 ⟶ 42:
'%s:%s/%s/%s', tsTitle.nsText, tsTitle.baseText, cfg['sandbox_title'], tsTitle.subpageText))
if tsSandboxTitle and tsSandboxTitle.exists then
sandboxLink = format('sandboxlink', link,
end
end
tStylesLinks[i] = sandboxLink or (link .. " (" .. editLink .. ")")
end
local tStylesList = mList.makeList('bulleted', tStylesLinks)
boxArgs.text =
'
end
return mMessageBox.main('mbox', boxArgs)
Line 48 ⟶ 61:
local cfg = getConfig()
local cats = {}
-- Error category
if #tStyles < 1 and cfg['error_category'] then
cats[#cats + 1] = cfg['error_category']
end
-- TemplateStyles category
titleObj = titleObj or mw.title.getCurrentTitle()
Line 96 ⟶ 108:
end
function p._main(args
local cfg = getConfig()
if #args == 0 then
local prefixed = mw.title.getCurrentTitle().prefixedText
prefixed = prefixed:gsub("/doc","")
args[1] = prefixed .. "/" .. cfg["default_subpage_name"]
end
local tStyles = mTableTools.compressSparseArray(args)
local box = renderBox(tStyles)
|