Editing
Module:Pagelist
From Thetacola Wiki
Jump to navigation
Jump to search
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!
Advanced
Special characters
Help
Heading
Level 2
Level 3
Level 4
Level 5
Format
Insert
Latin
Latin extended
IPA
Symbols
Greek
Greek extended
Cyrillic
Arabic
Arabic extended
Hebrew
Bangla
Tamil
Telugu
Sinhala
Devanagari
Gujarati
Thai
Lao
Khmer
Canadian Aboriginal
Runes
ร
รก
ร
ร
ร
รข
ร
รค
ร
รฃ
ว
ว
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ร
รฅ
ฤ
ฤ
ฤ
ฤ
ร
รง
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ร
รฉ
ร
รจ
ร
รช
ร
รซ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤ
ฤข
ฤฃ
ฤ
ฤ
ฤ
ฤก
ฤค
ฤฅ
ฤฆ
ฤง
ร
รญ
ร
รฌ
ร
รฎ
ร
รฏ
ฤจ
ฤฉ
ว
ว
ฤช
ฤซ
ฤฌ
ฤญ
ฤฐ
ฤฑ
ฤฎ
ฤฏ
ฤด
ฤต
ฤถ
ฤท
ฤน
ฤบ
ฤป
ฤผ
ฤฝ
ฤพ
ล
ล
ล
ล
ร
รฑ
ล
ล
ล
ล
ร
รณ
ร
รฒ
ร
รด
ร
รถ
ร
รต
ว
ว
ล
ล
ล
ล
วช
วซ
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ล
ลก
ศ
ศ
ศ
ศ
ลค
ลฅ
ร
รบ
ร
รน
ร
รป
ร
รผ
ลจ
ลฉ
ลฎ
ลฏ
ว
ว
ลช
ลซ
ว
ว
ว
ว
ลฌ
ลญ
ลฒ
ลณ
ลฐ
ลฑ
ลด
ลต
ร
รฝ
ลถ
ลท
ลธ
รฟ
ศฒ
ศณ
ลน
ลบ
ลฝ
ลพ
ลป
ลผ
ร
รฆ
วข
วฃ
ร
รธ
ล
ล
ร
ร
รฐ
ร
รพ
ฦ
ษ
Formatting
Links
Headings
Lists
Files
Discussion
Description
What you type
What you get
Italic
''Italic text''
Italic text
Bold
'''Bold text'''
Bold text
Bold & italic
'''''Bold & italic text'''''
Bold & italic text
local p = {} local separators = { dot = true, pipe = true, comma = true, ['tpt-languages'] = true } local function getSeparator(sep) if type(sep) ~= 'string' then return nil end if separators[sep] then return mw.message.new(sep .. '-separator'):plain() else return sep end end local function generateLink(page, nspace, delim, endDelim) if not page then return nil end local pagename = mw.title.new(page) if not pagename then -- Default to the args we were passed if our page -- object was nil. pagename = page else pagename = pagename.text end delim = delim or '' endDelim = endDelim or delim nspace = nspace or '' if nspace == 'all' then nspace = '' pagename = page end local outStr = mw.ustring.gsub( string.format( '%s[[:%s:%s|%s]]%s', delim, nspace, pagename, page, endDelim ), ':+', ':' ) return outStr end function p._main(args) local t = {} local separator = getSeparator(args.separator) local conjunction = getSeparator(args.conjunction) for i, v in ipairs(args) do table.insert(t, generateLink( v, args.nspace, args.delim, args.edelim )) end return mw.text.listToText(t, separator, conjunction) end function p.main(frame) local origArgs = require('Module:Arguments').getArgs(frame, { trim = false, removeBlanks = false, wrappers = 'Template:Pagelist' }) -- Process integer args. Allow for explicit positional arguments that are -- specified out of order, e.g. {{br separated entries|3=entry3}}. -- After processing, the args can be accessed accurately from ipairs. local args = {} for k, v in pairs(origArgs) do if type(k) == 'number' and k >= 1 and math.floor(k) == k and string.match(v, '%S') then -- Remove blank or whitespace values. table.insert(args, k) end end table.sort(args) for i, v in ipairs(args) do args[i] = origArgs[v] -- Trim whitespace. if type(args[i]) == 'string' then args[i] = mw.text.trim(args[i]) end end -- Get old named args. We don't need to remove blank values -- as for the nspace and edelim parameters the behaviour is different -- depending on whether the parameters are blank or absent, and for -- the delim parameter the default should be the blank string anyway. args.delim = origArgs.delim args.edelim = origArgs.edelim args.nspace = origArgs.nspace -- Get new named args, "separator" and "conjunction", and strip blank values. if origArgs.separator and origArgs.separator ~= '' then args.separator = origArgs.separator end if origArgs.conjunction and origArgs.conjunction ~= '' then args.conjunction = origArgs.conjunction end return p._main(args) end return p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local
p
=
{
}
local
separators
=
{
dot
=
true
,
pipe
=
true
,
comma
=
true
,
[
'tpt-languages'
]
=
true
}
local
function
getSeparator
(
sep
)
if
type
(
sep
)
~=
'string'
then
return
nil
end
if
separators
[
sep
]
then
return
mw
.
message
.
new
(
sep
..
'-separator'
)
:
plain
(
)
else
return
sep
end
end
local
function
generateLink
(
page
,
nspace
,
delim
,
endDelim
)
if
not
page
then
ืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืืื
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0
0
0
1:0
Summary:
Please note that all contributions to Thetacola Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Debug console
* The module exports are available as the variable "p", including unsaved modifications. * Precede a line with "=" to evaluate it as an expression or use print(). Use mw.logObject() for tables. * Use mw.log() and mw.logObject() in module code to send messages to this console.
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Nowrap
(
edit
)
Template:Ombox
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Module:Arguments
(
edit
)
Module:Effective protection level
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Pagelist/doc
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Page actions
Module
Discussion
Read
Edit source
History
Page actions
Module
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information