Изменения

м
-output design in literature_origin()
Строка 1: Строка 1:  
local ctd = {} -- функции для Большого теософского словаря; copied from https://ru.teopedia.org/lib/Module:CTD
 
local ctd = {} -- функции для Большого теософского словаря; copied from https://ru.teopedia.org/lib/Module:CTD
 +
 +
-- === LOCAL FUNCTIONS ========================================================
    
local function isempty(s)
 
local function isempty(s)
Строка 17: Строка 19:  
     return t
 
     return t
 
end
 
end
      
-- Convert local links [[link|text]] and URL [link text] to plain text.
 
-- Convert local links [[link|text]] and URL [link text] to plain text.
Строка 65: Строка 66:  
return str
 
return str
 
end
 
end
 +
 +
 +
-- === FUNCTIONS FOR EXTERNAL USAGE ===========================================
 +
 +
-- Create origin string for literature
 +
-- Used in : Шаблон:Литература БТС
 +
-- Call example:
 +
-- {{#invoke: CTD | literature_origin
 +
--  | origin =
 +
--  | language =
 +
--  | author  =
 +
--  | title    =
 +
-- }}
 +
function ctd.literature_origin( frame )
 +
local result = ''
 +
 +
-- if 'origin' set, use it and skip other parameters
 +
if not isempty(frame.args['origin']) then
 +
result = frame.args['origin']
 +
else -- check every other parameter for existance
 +
if not isempty(frame.args['language']) then
 +
result = frame.args['language']
 +
if not isempty(frame.args['author']) or not isempty(frame.args['title']) then
 +
result = result .. ': '
 +
end
 +
end
 +
if not isempty(frame.args['author']) then
 +
result = result .. frame.args['author']
 +
if not isempty(frame.args['title']) then
 +
result = result .. ', '
 +
end
 +
end
 +
if not isempty(frame.args['title']) then
 +
result = result .. '<i>' .. frame.args['title'] .. '</i>'
 +
end
 +
end
 +
 +
return result
 +
end
 +
    
-- Create short description without hyper links
 
-- Create short description without hyper links
Строка 267: Строка 308:  
if add_origin then
 
if add_origin then
 
output_str = output_str ..' '.. origin  
 
output_str = output_str ..' '.. origin  
else
+
elseif not isempty(lifetime) then
output_str = output_str .. ' ('.. lifetime ..')'
+
output_str = output_str .. ' ('.. lifetime ..')'  
 
end
 
end
 
if add_description then output_str = output_str ..'. – '.. description end
 
if add_description then output_str = output_str ..'. – '.. description end
 
else -- для 'понятие' и 'выражение'
 
else -- для 'понятие' и 'выражение'
output_str = description
+
output_str = term_without_link ..'. '.. description
 
if add_origin then output_str = output_str ..' '.. origin end
 
if add_origin then output_str = output_str ..' '.. origin end
 
end
 
end
Строка 278: Строка 319:  
end
 
end
   −
-- add publishing date for a literature and lifetime for a person
  −
local optional_lifetime =''
  −
if term_type == 'литература' or term_type == 'личность' then
  −
optional_lifetime = ', '.. lifetime
  −
end
  −
   
-- FOOTNOTE should be added
 
-- FOOTNOTE should be added
 
if view_footnote then
 
if view_footnote then
if add_link then
+
-- всегда добавлять ссылку в сноске
output_str = term_with_link
+
output_str = term_with_link
else
  −
output_str = term_without_link
  −
end
   
if add_origin then
 
if add_origin then
 
output_str = output_str ..' '.. origin  
 
output_str = output_str ..' '.. origin  
 
else  
 
else  
output_str = output_str .. optional_lifetime
+
if term_type == 'личность' then
 +
output_str = output_str .. ' ('.. lifetime ..')'
 +
end
 +
 
end
 
end
 
if add_description then output_str = output_str ..'. – '.. description end
 
if add_description then output_str = output_str ..'. – '.. description end