Module:Sandbox/Dragoniez: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 20: | Line 20: | ||
pagetitle = username |
pagetitle = username |
||
elseif username:find('^[Uu][Ss][Ee][Rr]:') ~= nil then |
elseif username:find('^[Uu][Ss][Ee][Rr]:') ~= nil then |
||
pagetitle = username:gsub('^[Uu][Ss][Ee][Rr]:', '利用者:') |
--pagetitle = username:gsub('^[Uu][Ss][Ee][Rr]:', '利用者:') |
||
pagetitle = username:gsub('^[Uu][Ss][Ee][Rr]:', 'User:') |
|||
else |
else |
||
pagetitle = '利用者:' .. username |
--pagetitle = '利用者:' .. username |
||
pagetitle = 'User:' .. username |
|||
⚫ | |||
local clss |
|||
⚫ | |||
clss = 'ul-page-exists' |
|||
⚫ | |||
clss = 'ul-page-missing' |
|||
end |
end |
||
Line 28: | Line 37: | ||
local displayText |
local displayText |
||
if prefix == 'none' then |
if prefix == 'none' then |
||
displayText = pagetitle:gsub('^利用者:', '') |
--displayText = pagetitle:gsub('^利用者:', '') |
||
displayText = pagetitle:gsub('^User:', '') |
|||
else |
else |
||
displayText = pagetitle |
displayText = pagetitle |
||
⚫ | |||
⚫ | |||
displayText = '<span class="ul-page-exists">' .. displayText ..'</span>' |
|||
⚫ | |||
displayText = '<span class="ul-page-missing">' .. displayText ..'</span>' |
|||
end |
end |
||
Line 43: | Line 47: | ||
--local templatestyles = frame:extensionTag{name = 'templatestyles', args = {src = 'Template:UserLink/styles.css'}} |
--local templatestyles = frame:extensionTag{name = 'templatestyles', args = {src = 'Template:UserLink/styles.css'}} |
||
local templatestyles = frame:extensionTag{name = 'templatestyles', args = {src = 'User:Dragoniez/Template:UserLink/styles.css'}} |
local templatestyles = frame:extensionTag{name = 'templatestyles', args = {src = 'User:Dragoniez/Template:UserLink/styles.css'}} |
||
local link = templatestyles .. '<span class="plainlinks">' .. extlink .. '</span>' |
local link = templatestyles .. '<span class="plainlinks ' .. clss ..'">' .. extlink .. '</span>' |
||
return link |
return link |
Latest revision as of 04:24, 29 July 2022
Documentation for this module may be created at Module:Sandbox/Dragoniez/doc
local p = {}
--[=[
local isIpOrRange = require('Module:IPAddress')._isIpOrRange
local function isIp(str)
return isIpOrRange(str) ~= ''
end
]=]
function p.createUserLink(frame)
local username = frame.args['username']
--[=[
if isIp(username) then
return '<span style="color: red; font-weight: bold;">エラー: IPユーザーは指定できません<span>'
end
]=]
local pagetitle
if username:find('^利用者:') ~= nil then
pagetitle = username
elseif username:find('^[Uu][Ss][Ee][Rr]:') ~= nil then
--pagetitle = username:gsub('^[Uu][Ss][Ee][Rr]:', '利用者:')
pagetitle = username:gsub('^[Uu][Ss][Ee][Rr]:', 'User:')
else
--pagetitle = '利用者:' .. username
pagetitle = 'User:' .. username
end
local clss
if mw.title.new(pagetitle).exists then
clss = 'ul-page-exists'
else
clss = 'ul-page-missing'
end
local prefix = frame.args['prefix']
local displayText
if prefix == 'none' then
--displayText = pagetitle:gsub('^利用者:', '')
displayText = pagetitle:gsub('^User:', '')
else
displayText = pagetitle
end
local url = '//ja.wikipedia.org/wiki/' .. pagetitle
local extlink = '[' .. url .. ' ' .. displayText .. ']'
--local templatestyles = frame:extensionTag{name = 'templatestyles', args = {src = 'Template:UserLink/styles.css'}}
local templatestyles = frame:extensionTag{name = 'templatestyles', args = {src = 'User:Dragoniez/Template:UserLink/styles.css'}}
local link = templatestyles .. '<span class="plainlinks ' .. clss ..'">' .. extlink .. '</span>'
return link
end
function p.Main(frame)
return p.createUserLink(frame)
end
return p