Бюрократы, Администраторы интерфейса, Администраторы (Semantic MediaWiki), Кураторы (Semantic MediaWiki), Editors (Semantic MediaWiki), Скрывающие, Администраторы, trusted
69 383
правки
мНет описания правки |
мНет описания правки |
||
Строка 13: | Строка 13: | ||
return 'userparam='.. frame.args['userparam'] .. '; i=' .. i .. '; j=' .. '; sub1=' .. sub1 .. '; sub2=' .. sub2 | return 'userparam='.. frame.args['userparam'] .. '; i=' .. i .. '; j=' .. '; sub1=' .. sub1 .. '; sub2=' .. sub2 | ||
end | end | ||
-- Create short description | |||
function ctd.shortly( frame ) | |||
local result = '' | |||
-- check if sort description specified | |||
if not isempty(frame.args['shortly']) then | |||
result = frame.args['shortly'] | |||
else | |||
result = frame.args['description'] | |||
-- keep only text before Category | |||
local i = mw.ustring.find(result,'[[Категория',1,true) | |||
if i ~= nil then | |||
result = mw.ustring.sub(result, 1, i-1) | |||
end | |||
-- convert local links [[link|text]] to plain text | |||
result = mw.text.unstrip(result) | |||
i = mw.ustring.find(result,'[[',1,true) | |||
while i ~= nil do | |||
local j = mw.ustring.find(result,'|',i,true) | |||
local k = mw.ustring.find(result,']]',i,true) -- assume that there is no mistakes and brackets are always closed; otherwise we should consider k == nil | |||
local str = mw.ustring.sub(result, i+2, k-1) | |||
if j ~= nil then | |||
str = mw.ustring.sub(result, j+1, k-1) | |||
end | |||
result = mw.ustring.sub(result, 1, i-1) .. str .. mw.ustring.sub(result, k+2, -1) | |||
i = mw.ustring.find(result,'[[',1,true) | |||
end | |||
-- convert external links [link text] to plain text | |||
-- take only first 100 characters; string.sub() uses bytes instead of chars | |||
if mw.ustring.len(result) > 100 then | |||
result = mw.ustring.sub( result, 1, 100) .. '...' | |||
end | |||
end | |||
return result | |||
end | |||
-- Invoke information from CTD about a TERM and shows it in footnote, pop-up or right next to term in square brackets. | -- Invoke information from CTD about a TERM and shows it in footnote, pop-up or right next to term in square brackets. | ||
Строка 89: | Строка 129: | ||
end | end | ||
-- | -- DEBUG | ||
--text = '<p>DEBUG: view: ' .. view .. "; term: " .. term .. "; description: " .. description .. "; origin: " .. origin .. '</p>' .. text | --text = '<p>DEBUG: view: ' .. view .. "; term: " .. term .. "; description: " .. description .. "; origin: " .. origin .. '</p>' .. text | ||
return text .. reference | |||
return frame:preprocess( text .. reference ) | --return frame:preprocess( text .. reference ) | ||
end | end | ||