Module:InterPro content: Difference between revisions
Appearance
Content deleted Content added
beginText for easier future editing |
m colon, .hlist-separated |
||
Line 1: | Line 1: | ||
local getArgs = require('Module:Arguments').getArgs |
local getArgs = require('Module:Arguments').getArgs |
||
local beginText = 'This article incorporates text from the public domain [[Pfam]] and [[InterPro]]' |
local beginText = 'This article incorporates text from the public domain [[Pfam]] and [[InterPro]]: ' |
||
local p = {} |
local p = {} |
||
Line 11: | Line 11: | ||
local function renderList(args) |
local function renderList(args) |
||
local listRoot = mw.html.create('ul') |
local listRoot = mw.html.create('ul') |
||
:addClass('hlist') |
:addClass('hlist hlist-separated') |
||
:css('display', 'inline') |
:css('display', 'inline') |
||
:css('margin', 0) |
:css('margin', 0) |
||
Line 30: | Line 30: | ||
return '<div class="error">[[Module:InterPro content]]: required argument 1 is missing</div>' |
return '<div class="error">[[Module:InterPro content]]: required argument 1 is missing</div>' |
||
elseif not args[2] then |
elseif not args[2] then |
||
return '<div role="note" style="font-style: italic;">' .. beginText |
return '<div role="note" style="font-style: italic;">' .. beginText .. interproLink(args[1]) .. '</div>' |
||
else |
else |
||
return '<div role="note" style="font-style: italic;">' .. beginText |
return '<div role="note" style="font-style: italic;">' .. beginText .. renderList(args) .. '</div>' |
||
end |
end |
||
end |
end |
Revision as of 22:13, 30 August 2018
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
![]() | This module depends on the following other modules: |
This module implements {{InterPro content}}.
Usage
{{#invoke:InterPro content|function_name}}
local getArgs = require('Module:Arguments').getArgs
local beginText = 'This article incorporates text from the public domain [[Pfam]] and [[InterPro]]: '
local p = {}
local function interproLink(entry)
return '[https://www.ebi.ac.uk/interpro/entry/' .. entry .. ' ' .. entry .. ']'
end
local function renderList(args)
local listRoot = mw.html.create('ul')
:addClass('hlist hlist-separated')
:css('display', 'inline')
:css('margin', 0)
for _, e in ipairs(args) do
listRoot
:tag('li')
:wikitext(interproLink(e))
end
return tostring(listRoot)
end
function p.main(frame)
local args = getArgs(frame)
if not args[1] then
return '<div class="error">[[Module:InterPro content]]: required argument 1 is missing</div>'
elseif not args[2] then
return '<div role="note" style="font-style: italic;">' .. beginText .. interproLink(args[1]) .. '</div>'
else
return '<div role="note" style="font-style: italic;">' .. beginText .. renderList(args) .. '</div>'
end
end
return p