Jump to content

Module:InterPro content: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m colon, .hlist-separated
baseUrl string for easier editing
Line 2: Line 2:


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 baseUrl = 'https://www.ebi.ac.uk/interpro/entry/'


local p = {}
local p = {}


local function interproLink(entry)
local function interproLink(id)
return '[https://www.ebi.ac.uk/interpro/entry/' .. entry .. ' ' .. entry .. ']'
return '[' .. baseUrl .. id .. ' ' .. id .. ']'
end
end


Line 15: Line 16:
:css('margin', 0)
:css('margin', 0)


for _, e in ipairs(args) do
for _, a in ipairs(args) do
listRoot
listRoot
:tag('li')
:tag('li')
:wikitext(interproLink(e))
:wikitext(interproLink(a))
end
end



Revision as of 23:50, 30 August 2018

local getArgs = require('Module:Arguments').getArgs

local beginText = 'This article incorporates text from the public domain [[Pfam]] and [[InterPro]]: '
local baseUrl = 'https://www.ebi.ac.uk/interpro/entry/'

local p = {}

local function interproLink(id)
	return '[' .. baseUrl .. id .. ' ' .. id .. ']'
end

local function renderList(args)
	local listRoot = mw.html.create('ul')
		:addClass('hlist hlist-separated')
		:css('display', 'inline')
		:css('margin', 0)

    for _, a in ipairs(args) do
		listRoot
			:tag('li')
				:wikitext(interproLink(a))
    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