Module:Asbox: Difference between revisions

no edit summary
m (→‎top: Fixing name)
No edit summary
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
--[[
--[[
This module was created by User:CodeHydro (Alexander Zhikun He).
This module was created by User:CodeHydro (Alexander Zhikun He).
User:Jackmcbarn and User:Mr._Stradivarius provided a great deal of assistance in writting p.main()
User:Muskit Gergous and User:WikiDwarf provided a great deal of assistance in writting p.main()


p.main() draw heavily from the following version of Template:Asbox of the English Wikipedia, authored primarily by User:Rich_Farmbrough
p.main() draw heavily from the following version of Template:Asbox of the English Bharatpedia, authored primarily by User:Rich_Farmbrough
https://en.wikipedia.org/w/index.php?title=Template:Asbox&oldid=619510287
https://en.bharatpedia.org/w/index.php?title=Template:Asbox&oldid=619510287


p.templatepage() is derived from the following revision of Template:Asbox/templatepage, authored primarily by User:MSGJ
p.templatepage() is derived from the following revision of Template:Asbox/templatepage, authored primarily by User:MSGJ
https://en.wikipedia.org/w/index.php?title=Template:Asbox/templatepage&oldid=632914791
https://en.bharatpedia.org/w/index.php?title=Template:Asbox/templatepage&oldid=632914791


Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages.
Both templates had significant contributions from numerous others listed in the revision history tab of their respective pages.
--]]
--]]
local WRAPPER_TEMPLATE, args = 'Template:Asbox'
local WRAPPER_TEMPLATE, args = 'Template:Asbox'
local templatestyles = 'Asbox/styles.css'
local p, Buffer, stubCats = {
local p, Buffer, stubCats = {
--Prevents dupli-cats... get it? Maybe not?
--Prevents dupli-cats... get it? Maybe not?
Line 77: Line 78:
local function catStub(page, pageDoc)
local function catStub(page, pageDoc)
stubCats = {missing = {}, v = {}}
stubCats = {missing = {}, v = {}}
-- zwj and zwnj have semantical use in other other wikis, don't remove them
local zwj = '\226\128\141'  -- U+200D, E2 80 8D
local zwnj = '\226\128\140' -- U+200C, E2 80 8C
local disallowedUnicodeChars = '[^%w%p%s' .. zwj .. zwnj .. ']' -- for i18n we make this a separate string
local code
local code
for k, _ in pairs(args) do
for k, _ in pairs(args) do
Line 85: Line 90:
for k, v in ipairs(stubCats) do
for k, v in ipairs(stubCats) do
--Get category names and, if called by p.templatepage, the optional sort key
--Get category names and, if called by p.templatepage, the optional sort key
local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], '[^%w%p%s]', '')--remove all hidden unicode chars  
local tsort, cat = args['tempsort' .. v], mw.ustring.gsub(args['category' .. v], disallowedUnicodeChars, '')--remove all hidden unicode chars  
--Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category.
--Do not place template in main category if |tempsort = 'no'. However, DO place articles of that template in the main category.
table.insert(stubCats.v,
table.insert(stubCats.v,
Line 163: Line 168:
done = p.demo ~= 'doc',--Outputs categories if not doc demo
done = p.demo ~= 'doc',--Outputs categories if not doc demo
'Stub message templates',
'Stub message templates',
'Exclude in print',
args.icon and
args.icon and
'Stub message templates using icon parameter'
'Stub message templates using icon parameter'
Line 214: Line 218:
function p.main(frame, page)
function p.main(frame, page)
args, page = p:init(frame, page)
args, page = p:init(frame, page)
local output = mw.html.create'table'
local output = mw.html.create'div'
:addClass'metadata plainlinks stub'
:attr{role = 'note'}
:css{background = 'transparent'}
:addClass'metadata plainlinks asbox stub'
:attr{role = 'presentation'}
:tag'table'
:tag'tr'
:attr{role = 'presentation'}
:node((args.icon or args.image) and
:tag'tr'
mw.html.create'td'
:addClass'noresize'
:wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format(
:node((args.icon or args.image) and
args.image or '',
mw.html.create'td'
args.pix or '40x30',
:wikitext(args.icon or ('[[File:%s|%spx|alt=%s]]'):format(
args.imagealt or 'Stub icon'
args.image or '',
))
args.pix or '40x30',
)
args.imagealt or 'Stub icon'
:tag'td'
))
:tag'i'
)
:wikitext(
:tag'td'
Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space
:tag'p'
' is a [[Wikipedia:stub|stub]]. You can help Bharatpedia by [',
:addClass'asbox-body'
page:fullUrl('action=edit', 'relative'),
:wikitext(
' expanding it].'
Buffer'This':_(args.subject):_(args.article or 'article'):_(args.qualifier)' ',--space
' is a [[Wikipedia:stub|stub]]. You can help Wikipedia by [',
page:fullUrl('action=edit', 'relative'),
' expanding it].'
)
:done()
:node(args.note and
mw.html.create()
:tag'p'
:addClass'asbox-note'
:wikitext(args.note)
:done()
)
)
:done()
:node(args.name and
require'Module:Navbar'._navbar{
args.name,
mini = 'yes',
style = 'position: absolute; right: 15px; display: none;'
}
)
:node(args.note and
mw.html.create()
:tag'br':done()
:tag'span'
:css{['font-style'] = 'normal', ['font-size'] = 'smaller'}
:wikitext(args.note)
:done()
)
:allDone()
:allDone()
:node(args.name and
require'Module:Navbar'._navbar{
args.name,
mini = 'yes',
}
)
--[[
--[[
Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories.
Stub categories for templates include a sort key; this ensures that all stub tags appear at the beginning of their respective categories.
Line 282: Line 287:
end
end
end
end
return output:wikitext(not p.demo and category{done = true} or nil)
return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(output:wikitext(not p.demo and category{done = true} or nil))
end
end


return p
return p