This documentation is transcluded from Module:Issue council/doc. Changes can be proposed in the talk page.
This module is unused.
This module is neither invoked by a template nor required/loaded by another module. If this is in error, make sure to add
{{Documentation}}
/{{No documentation}}
to the calling template's or parent's module documentation.Function list |
---|
L 15 — getArgs L 27 — makeWikitextError L 40 — stringContains L 49 — getProject L 63 — p.main L 72 — p._main |
Module:Issue council produces issue council links based on issue ID alone. It implements the {{issue council}} template.
--------------------------------------------------------------------------------
-- Module:Issue council --
-- --
-- This module produces issue council links based on issue ID alone. --
-- It implements the {{issue council}} template. --
--------------------------------------------------------------------------------
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local mArguments -- lazily initialise [[Module:Arguments]]
local mError -- lazily initialise [[Module:Error]]
local p = {}
local function getArgs(frame)
-- Fetches the arguments from the parent frame. Whitespace is trimmed and
-- blanks are removed.
mArguments = require('Module:Arguments')
return mArguments.getArgs(frame, {parentOnly = true})
end
--- Helper function to throw error
--
-- @param msg string - Error message
--
-- @return string - Formatted error message in wikitext
local function makeWikitextError(msg)
mError = require('Module:Error')
return mError.error{message =
'Error: ' .. msg .. '.'
}
end
--- Helper function checking if a substring is in a string
--
-- @param needle string - Value to search for
-- @param haystack string - String to search in
--
-- @return bool - True if found
local function stringContains( needle, haystack )
return string.find( string.lower( haystack ), needle, 1, true )
end
--- Determine the issue council project
--
-- @param id string - Issue Council ID
--
-- @return string - project or nil if unknown
local function getProject( id )
local project
if stringContains( 'starc-', id ) then
project = 'STAR-CITIZEN'
elseif stringContains( 'ic-', id ) then
project = 'ISSUE-COUNCIL'
else
project = nil
end
return project
end
function p.main(frame)
local args = getArgs(frame)
local issueId = args[1]
if not issueId then
return makeWikitextError('no issue ID specified')
end
return p._main(issueId)
end
function p._main(issueId)
checkType('_main', 1, issueId, 'string')
local project = getProject(issueId)
local url
if project == nil then
return makeWikitextError('issue ID is invalid (no project match)')
end
url = string.format(
'https://issue-council.robertsspaceindustries.com/projects/%s/issues/%s',
project,
issueId
)
return string.format(
'[%s %s]',
url,
issueId
)
end
return p