Модуль:Wikidata2/link: юрамалар арасында аерма

Wikipedia — ирекле энциклопедия проектыннан ([http://tt.wikipedia.org.ttcysuttlart1999.aylandirow.tmf.org.ru/wiki/Wikidata2/link latin yazuında])
Контент бетерелгән Контент өстәлгән
Marat-avgust (бәхәс | кертем)
к Marat-avgust юнәлтү калдырмыйча Модуль:Wikidata/link сәхифәсен Модуль:Wikidata2/link итеп күчерде
Kaganer (бәхәс | кертем)
update
 
Юл номеры - 3: Юл номеры - 3:
function p.fromTemplate( frame )
function p.fromTemplate( frame )
local args = frame.args;
local args = frame.args;
return p.generateLink( args[ 1 ], args[ 2 ], args[ 'title' ] );
local propertyId = args[1];
local id = args[2];
return p[propertyId]( nil, nil, id );
end
end

function p.fromModule( context, options, id )
return p.generateLink( options[ 'property' ], id, options[ 'title' ], context, options );
end

function p.generateLink( propertyId, id, title, context, options )
propertyId = propertyId:upper()
if p[ propertyId ] then
return p[ propertyId ]( context, options, id );
end

local pattern = p.findPattern( propertyId )
if pattern then
local link = mw.ustring.gsub( pattern, '$1', id );

if not title or title == '' then
title = id;
end

return '[' .. link .. ' ' .. title .. ']';
end

return id
end



function p.p163( context, options, id )
function p.p163( context, options, id )

28 сен 2020, 16:17 өчен соңгы юрама

Викимәгълүмат базасыннан ID номерларны эшләүче сылтамаларга әйләндерү өчен кирәк. {{Wikidata/link}} калыбы белән берлектә эшли.


p = {}

function p.fromTemplate( frame )
	local args = frame.args;
	return p.generateLink( args[ 1 ], args[ 2 ], args[ 'title' ] );
end

function p.fromModule( context, options, id )
	return p.generateLink( options[ 'property' ], id, options[ 'title' ], context, options );
end

function p.generateLink( propertyId, id, title, context, options )
	propertyId = propertyId:upper()
	
	if p[ propertyId ] then
		return p[ propertyId ]( context, options, id );
	end

	local pattern = p.findPattern( propertyId )
	if pattern then
		local link = mw.ustring.gsub( pattern, '$1', id );

		if not title or title == '' then
			title = id;
		end

		return '[' .. link .. ' ' .. title .. ']';
	end

	return id
end


function p.p163( context, options, id )
	return '[[' .. id .. '|Байрак]]';
end

function p.p212( context, options, id )
	return '[[Special:Booksources/' .. id .. '|' .. id .. ']]';
end

function p.p231( context, options, id )
	return '[http://www.chemnet.com/cas/supplier.cgi?exact=dict&terms=' .. id .. ' ' .. id .. ']';
end

function p.p237( context, options, id )
	return '[[' .. id .. '|Герб]]';
end

function p.p247( context, options, id )
	return '[http://nssdc.gsfc.nasa.gov/nmc/spacecraftOrbit.do?id=' .. id .. ' ' .. id .. ']';
end

function p.p267( context, options, id )
	local frame = mw.getCurrentFrame()
	return frame:expandTemplate{ title = 'АТХ', args = { id } };
end

function p.p296( context, options, id )
	return '[http://osm.sbin.ru/esr/esr:' .. id .. ' ' .. id .. ']';
end

function p.p345( context, options, id )
    local number = string.sub( id, 3 )
    local label = 'ID ' .. number
    if string.match( id, '^ch' ) then
		return '[[IMDbCharacter:' .. number .. '|' .. label .. ']]'
    end
    if string.match( id, '^co' ) then
		return '[[IMDbCompany:' .. number .. '|' .. label .. ']]'
    end
    if string.match( id, '^nm' ) then
		return '[[IMDbName:' .. number .. '|' .. label .. ']]'
    end
    if string.match( id, '^tt' ) then
		return '[[IMDbTitle:' .. number .. '|' .. label .. ']]'
    end

	return id;
end

function p.p377( context, options, id )
	return '[http://www.n2yo.com/satellite/?s=' .. id .. ' ' .. id .. ']';
end

function p.p628( context, options, id )
	return '[http://www.codexalimentarius.net/gsfaonline/additives/results.html?searchBy=ins&ins=' .. id .. ' ' .. id .. ']';
end

function p.p661( context, options, id )
	return '[//www.chemspider.com/Chemical-Structure.' .. id .. '.html ' .. id .. ']';
end

function p.p662( context, options, id )
	return '[http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=' .. id .. ' ' .. id .. ']';
end

function p.p685( context, options, id )
	return '[http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id=' .. id .. ' ' .. id .. ']';
end

function p.p715( context, options, id )
	return '[http://www.drugbank.ca/drugs/DB' .. id .. ' ' .. id .. ']';
end

function p.p721( context, options, id )
	local label = '';
    for i = mw.ustring.len( id ), 1, -3 do
    	if ( i ~= mw.ustring.len( id ) ) then
    		label = ' ' .. label;
    	end
    	if ( i - 2 <= 0 ) then
        	label = mw.ustring.sub( id, 0, i ) .. label;
    	else
        	label = mw.ustring.sub( id, i - 2, i ) .. label;
        end
    end
	return '[http://classif.spb.ru/classificators/view/okt.php?st=A&kr=1&kod=' .. id .. ' ' .. label .. ']';
end

function p.p764( context, options, id )
	local label = '';
    for i = mw.ustring.len( id ), 1, -3 do
    	if ( i ~= mw.ustring.len( id ) ) then
    		label = ' ' .. label;
    	end
    	if ( i - 2 <= 0 ) then
        	label = mw.ustring.sub( id, 0, i ) .. label;
    	else
        	label = mw.ustring.sub( id, i - 2, i ) .. label;
        end
    end
	return '[http://classif.spb.ru/classificators/view/tma.php?st=A&kr=1&kod=' .. id .. ' ' .. label .. ']';
end

function p.p815( context, options, id )
	return '[http://www.itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=' .. id .. ' ' .. id .. ']';
end

function p.p830( context, options, id )
	return '[http://www.eol.org/pages/' .. id .. ' ' .. id .. ']';
end

function p.p884( context, options, id )
	return '[http://vwo.osm.rambler.ru/?page=findname&name=' .. id .. ' ' .. id .. ']';
end

function p.p957( context, options, id )
	return '[[Special:Booksources/' .. id .. '|' .. id .. ']]';
end

function p.p961( context, options, id )
	return '[http://www.ipni.org/ipni/idPlantNameSearch.do?id=' .. id .. ' ' .. id .. ']';
end

function p.p962( context, options, id )
	return '[http://www.mycobank.org/Biolomics.aspx?Table=Mycobank&MycoBankNr_=' .. id .. ' ' .. id .. ']';
end

function p.p959( context, options, id )
	return '[http://www.bucknell.edu/msw3/browse.asp?id=' .. id .. ' ' .. id .. ']';
end

function p.p1070( context, options, id )
	return '[http://www.theplantlist.org/tpl1.1/record/' .. id .. ' ' .. id .. ']';
end

function p.p1146( context, options, id )
	return '[http://www.iaaf.org/athletes/athlete=' .. id .. '/ ' .. id .. ']';
end

function p.p1258( context, options, id )
	return '[http://www.rottentomatoes.com/' .. id .. '/ тулырак]';
end

function p.p1483( context, options, id )
	return '[http://kulturnoe-nasledie.ru/monuments.php?id=' .. id .. ' ' .. id .. ']';
end

function p.p1883( context, options, id )
	return '[http://declarator.org/person/' .. id .. '/ ' .. id .. ']';
end

return p;