Модуль:Wordlist-test
Внешний вид
Для документации этого модуля может быть создана страница Модуль:Wordlist-test/Документация
local moduleHeader = require('Module:Header')
local moduleTSD = require('Module:ТСД')
t = {
['title'] = '',
['pagename'] = '',
['currname'] = '',
['oldspell'] = '',
['tom'] = '',
['god'] = '',
[1] = {
['termin_so'] = '',
['termin_do'] = '',
['list'] = '',
['wordlist_str'] = '',
['numpage_scan'] = '',
['numpage_book'] = '',
['next'] = '',
['previous'] = '',
['indexlink'] = '',
},
[2] = {
['termin_so'] = '',
['termin_do'] = '',
['list'] = '',
['wordlist_str'] = '',
['numpage_scan'] = '',
['numpage_book'] = '',
['next'] = '',
['previous'] = '',
['indexlink'] = '',
},
[3] = {
['termin_so'] = '',
['termin_do'] = '',
['list'] = '',
['wordlist_str'] = '',
['numpage_scan'] = '',
['numpage_book'] = '',
['next'] = '',
['previous'] = '',
['indexlink'] = '',
},
['indexlinks_all'] = '',
['categories'] = '',
['bukvi_toma'] = {
{ 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ж', 'З' },
{ 'И', 'І', 'К', 'Л', 'М', 'Н', 'О' },
{ 'П' }, -- в ТСД-3 буква 'Р' в 3-м томе
{ 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Ѣ', 'Э', 'Ю', 'Ѧ', 'Я', 'Ѳ', 'Ѵ' }
},
['god_toma'] = { { 1863, 1865, 1865, 1866 }, { 1880, 1881, 1882, 1882 }, { 1903, 1905, 1907, 1909 } }
}
-- helper
function make_link(prefix, pagename, text)
return '[[' .. prefix .. pagename .. '|' .. text .. ']]'
end
-- проверка переменной, возврат её или nil если пустая
function is(var)
if (var == '' or var == nil) then return nil else return var end
end
--------------------------------------------
local currtitle = mw.title.getCurrentTitle()
local currname = currtitle["text"]
local currlist = currtitle["rootText"]
-- currname = 'ТСД/Алык/ДО' -- тест
local nameparts = mw.text.split(currname, "/")
if not is(nameparts[2]) then return t end
t['title'] = nameparts[2]
if nameparts[1] == 'ТСД' then
local pagename = nameparts[1] .. '/' .. nameparts[2]
t['pagename'] = pagename
if nameparts[3] == 'ДО' then t['oldspell'] = '/ДО' end
for i = 1, 3 do -- izdanie
local list, wordlist_str, tom, tso, tdo, previous, next, pns, pnb
list = moduleHeader.wordlist({ args = { nil, pagename, tostring(i) } })
if is(list) then
-- list = 'А'
t[i]['list'] = list
wordlist_str = 'ТСД-словник/' .. list .. '/' .. tostring(i) .. '-е изд.'
t[i]['wordlist_str'] = wordlist_str
tso = moduleHeader.title({ args = { pagename, wordlist_str, ['safe'] = true } })
if is(tso) then
t[i]['termin_so'] = tso
t['categories'] = t['categories'] .. '[[Категория:ТСД:Статьи из ' .. tostring(i) .. '-го издания]]'
tdo = moduleHeader.title({ args = { pagename, wordlist_str, ['ДО'] = true, ['safe'] = true } })
if is(tdo) then t[i]['termin_do'] = tdo end
previous = moduleHeader.previous({ args = { pagename, wordlist_str, ['type'] = 'name', ['safe'] = true } })
if is(previous) then
t[i]['previous'] = previous
t[i]['link_previous'] = make_link(nameparts[1] .. '/', t[i]['previous'] .. t['oldspell'], t[i]['previous'] .. t['oldspell'])
end
next = moduleHeader.next({ args = { pagename, wordlist_str, ['type'] = 'name', ['safe'] = true } })
if is(next) then
t[i]['next'] = next
t[i]['link_next'] = make_link(nameparts[1] .. '/', t[i]['next'] .. t['oldspell'], t[i]['next'] .. t['oldspell'])
end
tom = moduleTSD.tomcalc({ args = {i, t['title']} })
t[i]['tom'] = tom
t[i]['god'] = t['god_toma'][i][tom]
pnb = moduleHeader.pagenum({ args = { 'hard', ['name'] = pagename, ['list'] = wordlist_str } })
if is(pnb) then
t[i]['numpage_book'] = pnb
pns = moduleTSD.pagecalc({ args = { i, tom, pnb} })
if is(pns) then
t[i]['numpage_scan'] = pns
else
t['categories'] = t['categories'] .. '[[Категория:ТСД:' .. tostring(i) .. '-е издание, не указана страница скана]]'
end
else
t['categories'] = t['categories'] .. '[[Категория:ТСД:' .. tostring(i) .. '-е издание, не указана страница книги]]'
end
local indexlink = moduleTSD.indexlink({ args = {i, tom, pns, pnb} })
if indexlink then
-- оформление: ' • ' между ссылками
if is(t['indexlinks_all']) then
t['indexlinks_all'] = t['indexlinks_all'] .. ' • ' .. indexlink
else
t['indexlinks_all'] = indexlink
end
end
end
end
end
elseif nameparts[1] == 'ТСД-словник' then
local izdanie = tonumber(mw.ustring.sub(nameparts[3], 1, 1))
local tom = tonumber(moduleTSD.tomcalc({ args = {izdanie, t['title']} }))
t[izdanie]['tom'] = tom
t[izdanie]['god'] = t['god_toma'][izdanie][tom]
end
--[==[
elseif mw.ustring.find(nameparts[1], 'Толковый словарь') then
for god_page in mw.ustring.gmatch (nameparts[1], "(19%d%d)") do
for i, v in pairs(t['god_toma']) do
for god in pairs(v) do
if god == god_page then izdanie = i end
end
end
end
-- local izdanie = tonumber(mw.ustring.sub(nameparts[3], 1, 1))
izdanie = 3
tom = 2
local pattern
if mw.ustring.find(nameparts[1], ' Часть ') then pattern = "[Чч]асть (%d)" else pattern = "[Тт]ом (%d)" end
for tn in mw.ustring.gmatch (nameparts[1], pattern) do tom = tn end
-- local tom = tonumber(tomcalc(izdanie, t['title']))
t[izdanie]['tom'] = tom
t[izdanie]['god'] = god -- t['god_toma'][izdanie][tom]
end
--]==]
return t