Модуль:Links
Материал из Указатель частей и соединений РККА 1941-1945
Версия от 11:13, 23 марта 2020; Строк (обсуждение | вклад)
Для документации этого модуля может быть создана страница Модуль:Links/doc
local links = {} local tools = require( 'Module:Tools' ) local report = require( 'Module:Report' ) function links.WP_Page( frame ) local args = tools.checkargs( frame:getParent().args, { true, true, ['комментарий'] = true, ['сноска'] = true, } ) local test = frame.args.test test = test and test ~= '' local wikiru = args[1] local rkka = args[2] if not rkka and not test then if not wikiru then return '<table class="table table-condensed table-hover table-bordered show-disambig">' .. '<tr><th>Страница Википедии</th><th>Страница указателя</th><th>Комментарий</th></tr>' elseif wikiru == 'конец' then local ref = require( 'Module:Ref' ) ref.refStart() return '</table>[' .. tostring( mw.uri.fullUrl( mw.title.getCurrentTitle().fullText,'test=1' ) ).. ' текст для проверки]' .. ref.refOut() end end local out = { '<tr><td>' } if wikiru then if test then return ' * [<i></i>[' .. wikiru .. ']]' end table.insert( out, '[[вп:' .. wikiru .. '|' .. wikiru .. ']]' ) end table.insert( out, '</td><td>' ) local dry = mw.title.getCurrentTitle().namespace ~= 4 if rkka and not test then local pagesA = {} local hiddenBraces = {} local rkkaX = string.gsub( rkka, '%b()', function ( str ) table.insert( hiddenBraces, str ) return '(' .. #hiddenBraces .. ')' end ) local pages = mw.text.split( rkkaX, '%s*[,;]%s*' ) for _, page in ipairs( pages ) do if page ~= '' then page = string.gsub( page, '%((%d+)%)', function( str ) return hiddenBraces[tonumber( str )] end ) page = report.bigfuller( page ) local a = '[[' .. page .. ']]' if wikiru and not dry then a = a .. frame:callParserFunction( '#cargo_store', { [1] = '', _table = 'ext_links', unit = page, media = 1, link = wikiru, addendum = args['комментарий'], ref = args['сноска'], } ) end table.insert( pagesA, a ) end end table.insert( out, table.concat( pagesA, ' • ' ) ) end table.insert( out, '</td><td>' ) if args['комментарий'] then table.insert( out, args['комментарий'] ) end if args['сноска'] then local ref = require( 'Module:Ref' ) ref.refStart() table.insert( out, ref.refReturn( ref.use( args['сноска'] ) ) ) end table.insert( out, '</td></tr>' ) return table.concat( out ) end function links.AllAces_Page( frame ) local args = tools.checkargs( frame:getParent().args, { ['ссылка'] = true, ['кратко'] = true, ['полно'] = true, true, ['комментарий'] = true, ['сноска'] = true, } ) -- local test = frame.args.test -- test = test and test ~= '' local aaUrl, aaShort, aaFull = args['ссылка'], args['кратко'] , args['полно'] local rkka = args[1] if not rkka and not aaFull then return '<table class="table table-condensed table-hover table-bordered show-disambig">' .. '<tr><th colspan=2>Страница сайта <i>allaces.ru</i></th><th>Страница указателя</th><th>Комментарий</th></tr>' elseif rkka == 'конец' then local ref = require( 'Module:Ref' ) ref.refStart() return ref.refReturn( '</table>' .. ref.refOut() ) end local out = { '<tr><td>' } if aaShort then if aaUrl then table.insert( out, '[http://allaces.ru' .. aaUrl .. ' ' .. aaShort .. ']' ) else table.insert( out, '<span class=text-muted>' .. aaShort .. '</span>' ) end end table.insert( out, '</td><td>' ) if aaFull then if aaUrl then table.insert( out, --[['[http://allaces.ru' .. aaUrl .. ' ' ..]] aaFull --[[.. ']']] ) else table.insert( out, '<span class=text-muted>' .. aaFull .. '</span>' ) end end table.insert( out, '</td><td>' ) local dry = mw.title.getCurrentTitle().namespace ~= 4 if rkka then local pagesA = {} local hiddenBraces = {} local rkkaX = string.gsub( rkka, '%b()', function ( str ) table.insert( hiddenBraces, str ) return '(' .. #hiddenBraces .. ')' end ) local pages = mw.text.split( rkkaX, '%s*[,;]%s*' ) for _, page in ipairs( pages ) do if page ~= '' then page = string.gsub( page, '%((%d+)%)', function( str ) return hiddenBraces[tonumber( str )] end ) page = report.bigfuller( page ) local a = '[[' .. page .. ']]' if aaUrl and not dry then a = a .. frame:callParserFunction( '#cargo_store', { [1] = '', _table = 'ext_links', unit = page, media = 2, link = aaUrl .. ' ' .. (aaFull or '') .. ' (' .. ( aaShort or '_' ) .. ')', addendum = args['комментарий'], ref = args['сноска'], } ) end table.insert( pagesA, a ) end end table.insert( out, table.concat( pagesA, ' • ' ) ) end table.insert( out, '</td><td>' ) if args['комментарий'] then table.insert( out, args['комментарий'] ) end if args['сноска'] then local ref = require( 'Module:Ref' ) ref.refStart() table.insert( out, ref.refReturn( ref.use( args['сноска'] ) ) ) end table.insert( out, '</td></tr>' ) return table.concat( out ) end function links.Proza_Page( frame ) local args = tools.checkargs( frame:getParent().args, { ['ссылка'] = true, ['заголовок'] = true, true, ['комментарий'] = true, ['сноска'] = true, } ) -- local test = frame.args.test -- test = test and test ~= '' local prRuUrl, prRuHeader = args['ссылка'], args['заголовок'] local rkka = args[1] if not rkka and not prRuHeader then return '<table class="table table-condensed table-hover table-bordered show-disambig">' .. '<tr><th>Страница сайта <i>proza.ru</i></th><th>Страница указателя</th><th>Комментарий</th></tr>' elseif rkka == 'конец' then local ref = require( 'Module:Ref' ) ref.refStart() return ref.refReturn( '</table>' .. ref.refOut() ) end local out = { '<tr><td>' } table.insert( out, '[https://www.proza.ru' .. prRuUrl .. ' ' .. prRuHeader .. ']' ) table.insert( out, '</td><td>' ) local dry = mw.title.getCurrentTitle().namespace ~= 4 if rkka then local pagesA = {} local hiddenBraces = {} local rkkaX = string.gsub( rkka, '%b()', function ( str ) table.insert( hiddenBraces, str ) return '(' .. #hiddenBraces .. ')' end ) local pages = mw.text.split( rkkaX, '%s*[,;]%s*' ) for _, page in ipairs( pages ) do if page ~= '' then page = string.gsub( page, '%((%d+)%)', function( str ) return hiddenBraces[tonumber( str )] end ) page = report.bigfuller( page ) local a = '[[' .. page .. ']]' if prRuUrl and not dry then a = a .. frame:callParserFunction( '#cargo_store', { [1] = '', _table = 'ext_links', unit = page, media = 3, link = prRuUrl .. ' ' .. prRuHeader, addendum = args['комментарий'], ref = args['сноска'], } ) end table.insert( pagesA, a ) end end table.insert( out, table.concat( pagesA, ' • ' ) ) end table.insert( out, '</td><td>' ) if args['комментарий'] then table.insert( out, args['комментарий'] ) end if args['сноска'] then local ref = require( 'Module:Ref' ) ref.refStart() table.insert( out, ref.refReturn( ref.use( args['сноска'] ) ) ) end table.insert( out, '</td></tr>' ) return table.concat( out ) end return links