Модуль:Wikidata/media
ХӀокху модулах лаьцна хааман Модуль:Wikidata/media/doc агӀо кхолла мега
local p = {}-- Константыlocal contentLanguageCode = mw.getContentLanguage():getCode();function p.formatCommonsCategory( context, options, value ) local link = 'commons:Category:' .. value local title = value .. ' Викилармехь' if ( options['text'] and options['text'] ~= '' ) then title = options['text'] endcommons = '[[' .. link .. '|' .. title .. ']]'--Commons icon if ( not options['icon'] or options['icon'] ~= '-' ) then local icon_size = '15px' if ( options['icon_size'] and options['icon_size'] ~= '' ) then icon_size = options['icon_size'] end commons = '[[File:Commons-logo.svg|' .. icon_size .. '|link=' .. link .. '|alt=Викилармин логотип]] ' .. commons end--Text before and after link if ( options['text_before'] and options['text_before'] ~= '' ) then if ( options['text_before'] ~= '-' ) then commons = options['text_before'] .. ' ' .. commons end end if ( options['text_after'] and options['text_after'] ~= '' ) then if ( options['text_after'] ~= '-' ) then commons = commons .. ' ' .. options['text_after'] end end return commonsend--[[Временный хак, нужно добавить config, getConfig и getCategoryByCodeв options, чтобы они были доступны в любом месте кода.]]local config;local function getCategoryByCode( code, sortkey )if config == nil thenconfig = require( 'Module:Wikidata/config' );end;local value = config[ 'categories' ][ code ];if not value or value == '' thenreturn '';endreturn '[[Category:' .. value .. ']]';endlocal function getCaption( context, options )local caption = ''if options.qualifiers and options.qualifiers.P2096 thenfor i, qualifier in pairs( options.qualifiers.P2096 ) doif ( qualifierand qualifier.datavalueand qualifier.datavalue.type == 'monolingualtext'and qualifier.datavalue.valueand qualifier.datavalue.value.language == contentLanguageCode ) thencaption = qualifier.datavalue.value.textbreakendendendif options['appendTimestamp'] and options.qualifiers and options.qualifiers.P585 and options.qualifiers.P585[1] thenlocal moment = context.formatValueDefault( context, options, options.qualifiers.P585[1].datavalue )if not caption or caption == '' then caption = momentelsecaption = caption .. ', ' .. momentendendlocal localValue = '';if options[ 'value' ] and options[ 'value' ] ~= '' thenlocalValue = options[ 'value' ];endlocal localCaption = '';if options[ 'caption' ] and options[ 'caption' ] ~= '' thenlocalCaption = options[ 'caption' ];endif localValue ~= '' thencaption = localCaption;endlocal formattedCaption = ''if caption ~= '' thenformattedCaption = context.wrapQualifier( caption, 'P2096', { class = 'media-caption', style = 'display:block' } );endif localValue == '' and localCaption ~= '' thenformattedCaption = formattedCaption .. getCategoryByCode( 'media-contains-local-caption' )if options.frame:preprocess('{{REVISIONID}}') == '' thenformattedCaption = formattedCaption .. '<span class="error" style="font-size:94%;">Локалан куьг гойтуш дац, сурт Викихаамашкара гойтуш ду.</span>'endendreturn caption, formattedCaptionendfunction p.formatCommonsMediaValue( context, options, value )local image = value;local caption, formattedCaption = getCaption( context, options )if not string.find( value, '[%[%]%{%}]' ) and not string.find( value, 'UNIQ%-%-imagemap' ) then-- если в value не содержится викикод или imagemap, то викифицируем имя файла-- ищем слово imagemap в строке, потому что вставляется плейсхолдер: [[PHAB:T28213]]image = '[[File:' .. value .. '|frameless';if options[ 'border' ] and options[ 'border' ] ~= '' thenimage = image .. '|border';endlocal size = options[ 'size' ];if size and size ~= '' thenif not string.match( size, 'px$' )and not string.match( size, 'пкс$' ) -- TODO: использовать перевод для языка викиthensize = size .. 'px'end-- временноif string.match( size, 'pxpx' ) thenimage = '[[Категори:Википеди:Pxpx чуьра сурт барамехь]]' .. imageendelsesize = fileDefaultSize;endimage = image .. '|' .. size;if options[ 'alt' ] and options[ 'alt' ] ~= '' thenimage = image .. '|alt=' .. options[ 'alt' ];endif caption ~= '' thenimage = image .. '|' .. captionendimage = image .. ']]';if formattedCaption ~= '' thenimage = image .. '<br>' .. formattedCaption;endelseimage = image .. formattedCaption .. getCategoryByCode( 'media-contains-markup' );endif options.entity and options.fixdouble thenlocal page = mw.title.getCurrentTitle()local txt = page:getContent()if txt and txt:match(':' .. value) and mw.title.getCurrentTitle():inNamespace(0) thenif options.frame:preprocess('{{REVISIONID}}') == '' thenimage = image .. '<span class="error">ХӀара сурт лахахь йозанан йукъахь долуш ду; дехар до, царахь цхьа копи дӀайакха (суртан хаам Ӏалашбеш)</span>'endimage = image .. getCategoryByCode( 'media-contains-local-double' )endendreturn imageendreturn p
🔥 Top keywords: Коьрта агӀоВикипеди:ФорумЭджворт (Пенсильвани)ШолгӀа дуьненан тӀомАхмадов, Муса Магомедович.neКеп:Динан адамНохчийчуьра акхаройВикипеди:Цуьнах лаьцнаГӀирс:ЛахарВикипеди:ГӀоГӀирс:Керла нисдаршВикипедиКеп:Динан цхьаьнакхетарКеп:Адам/ИсламВикипеди:Йукъараллин ковБадуев, СаьӀид СулеймановичАль-БарбахӀариБарта кхоллараллаКиранцНохчийчоьАмерикин Цхьаьнатоьхна ШтаташКов:Карара хилларшНохчийн моттЙоккха БританиВикипеди:Хаьржина йаззамашВикипеди:Йаззам кечбарКеп:Динан цхьаьнакхетар/docХьанбалийн мазхӀабВикипеди:Элпнашца гайтарМухьаммадВикипеди:Бакъонаш а, куьйгалла аInstagramБексултанов, Муса ЭльмурзаевичКеп:Infobox softwareВикипеди:Массо а маттахь хилайеза агӀонашАрсанукаев, Шайхи Ӏабдулмуслиман воӀВикипеди:Категорешца лахарГорник (Айова)