Module:UserLinks: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
fix bug where the username error wasn't showing up properly, add more comments
(add the rest of the link types, remove wiki-encoded username as I ended up not using it at all)
(fix bug where the username error wasn't showing up properly, add more comments)
Line 160:
 
local function generateUserDataStrings(args)
-- Username helper strings --.
-------------------------------------------------
u.username = args.user or args.User
-- Username helper strings --
-------------------------------------------------
-- Get the username value. If it is absent or blank, return an html error and a tracking category.
if args.user == '' or (not args.user and (not args.User or args.User == '')) then
return '<span class="error">Error: No username detected by [[Module:UserLinks]].</span>[[Category:UserLinks transclusions without usernames]]'
else
u.username = args.user or args.User
end
u.usernameHtml = mw.uri.encode(u.username) -- Html-encoded username. Spaces are encoded as pluses.
-- Project helper strings --.
u.project = args.Project -- Get the project value.
-------------------------------------------------
-- Project helper strings --
-------------------------------------------------
u.project = args.Project -- Get the project value.
u.projectColon = (u.project and (':' .. args.Project .. ':')) or '' -- Project value plus colons, for escaping interwiki links.
u.project = u.project or '' -- Control for nil values of args.Project.
Line 180 ⟶ 170:
 
local function getLinks(args)
-- GetIf the username value. If it is absent or blank, return an html error and a tracking category.
generateUserDataStrings(args)
if args.user == '' or (not args.user and (not args.User or args.User == '')) then
return '<span class="error">Error: No username detected by [[Module:UserLinks]].</span>[[Category:UserLinks transclusions without usernames]]'
elseend
-- Generate the user data strings.
generateUserDataStrings(args)
-- Build the template output.
local result = makeToolbar(args) -- Get the toolbar contents.
if result then
if args.sup then
Line 189 ⟶ 185:
result = '&nbsp;' .. result
else
result = '' -- If there are no links specified, don't return the toolbar at all.
end
result = '<span>' .. makeUserLink() .. result .. '</span>'
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu