Модуль:SB

<div style="color: #555555; font-size: 80%; font-style: italic; font-family: serif; text-align: center;">Материал из '''Библиотеки Теопедии''', http://ru.teopedia.org/lib</div>
Перейти к навигации Перейти к поиску

Этот модуль является копией модуля из английского раздела, где он развивается и документируется.


local sb = {} -- functions package for HPB Scrapbooks; copied from https://en.teopedia.org/lib/Module:SB

function sb.item_id2( frame )
	local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item']
    return id
end

local function isempty(s)
  return s == nil or s == ''
end

-- Create unique ID for the item, which consist of: Volume-Page-Item_on_page
-- ID example: 01-017-03
-- Call example: {{#invoke: SB | item_id | volume=1 | page=17 | item=3 }}
-- Values: volume=1..99, page=1..999, item=1..99
function sb.item_id( frame )
	local vNum = string.format("%.2d", frame.args['volume'])
	local iNum = string.format("%.2d", frame.args['item'])
	local p_int, p_frac = math.modf(frame.args['page'])
	local pNum = string.format("%.3d", p_int)  

	--mw.log('int= '.. p_int .. ', frac= ' .. p_frac)
	if p_frac > 0 then
		str = tostring(p_frac)
		pNum = pNum .. '.' .. string.sub(str,3,5)
	end

	local id = vNum .. '-' .. pNum .. '-' .. iNum
	return id
end


-- Create footnote with item summary and notes by editor and archivist
-- View: 
-- AUTHOR (подписано AUTHOR_SIGNED). TITLE (ORIGINAL_TITLE). SOURCE_TITLE, SOURCE_DETAILS. 
-- Язык оригинала: LANGUAGE, переводчик: TRANSLATOR. NOTES. 
-- ARCHIVIST_NOTES. – Архивариус Адьяра.
function sb.footnote( frame )
	local str = ''

	if not isempty(frame.args['author']) then
		str =  frame.args['author']
	else 
		if not isempty(frame.args['title']) then
			str = 'Автор не известен'
		else
			str = str .. frame.args['type'] .. ' неизвестного автора'
		end
	end

	if not isempty(frame.args['author_signed']) then
		str = str .. ' (подписано: ' .. frame.args['author_signed'] .. ')'
	end

	if not isempty(frame.args['title']) then
		str = str ..', «'.. frame.args['title'] ..'»'
	end
	if not isempty(frame.args['original_title']) then
		str = str ..' ('.. frame.args['original_title'] ..')'
	end

	if not isempty(frame.args['source_title']) then
		str = str .. '. <i>' .. frame.args['source_title'] .. '</i>'
	end
	if not isempty(frame.args['source_details']) then
		str = str .. ', ' .. frame.args['source_details'] 
	end

	if not isempty(frame.args['language']) then
		str = str .. '. Язык оригинала: ' .. frame.args['language'] 
		if not isempty(frame.args['translator']) then
			str = str .. ', переводчик: ' .. frame.args['translator'] 
		end
	elseif not isempty(frame.args['translator']) then
		str = str .. '. Переводчик: ' .. frame.args['translator'] 
	end
	str = str .. '. '
	if not isempty(frame.args['notes']) then
		str = str .. frame.args['notes'] 
	end

	if not isempty(frame.args['archivist_notes']) then
		str = str .. '<br>' .. frame.args['archivist_notes'] .. '. – Архивариус Адьяра.'
	end

	return str
end

return sb