Строка 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 |
Строка 138: |
Строка 179: |
| local output_str = '' -- result string to show | | local output_str = '' -- result string to show |
| -- variables for 'view' parameter | | -- variables for 'view' parameter |
− | local view_popup, view_footnote, view_brackets = false | + | local view_popup, view_footnote, view_brackets, view_link = false |
| -- variables for 'style' parameter | | -- variables for 'style' parameter |
| local font_grey = false -- make font grey | | local font_grey = false -- make font grey |
Строка 156: |
Строка 197: |
| if mw.ustring.find(view,'сноска',1,true) ~= nil then view_footnote = true end | | if mw.ustring.find(view,'сноска',1,true) ~= nil then view_footnote = true end |
| if mw.ustring.find(view,'скобки',1,true) ~= nil then view_brackets = true end | | if mw.ustring.find(view,'скобки',1,true) ~= nil then view_brackets = true end |
| + | if mw.ustring.find(view,'ссылка',1,true) ~= nil then view_link = true end |
| -- parse 'style' for values | | -- parse 'style' for values |
| if mw.ustring.find(style,'серый',1,true) ~= nil then font_grey = true end | | if mw.ustring.find(style,'серый',1,true) ~= nil then font_grey = true end |
Строка 251: |
Строка 293: |
| term_with_link = term_with_link ..', '.. specification | | term_with_link = term_with_link ..', '.. specification |
| term_without_link = term_without_link ..', '.. specification | | term_without_link = term_without_link ..', '.. specification |
| + | end |
| + | |
| + | -- add LINK to original text |
| + | if view_link then |
| + | if not isempty(frame.args['wiki_page']) then |
| + | text = '[['.. frame.args['wiki_page'] ..'|'.. text ..']]' |
| + | end |
| end | | end |
| | | |
Строка 259: |
Строка 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 |
− | if add_origin then output_str = output_str ..' '.. origin end
| |
− | if add_description then output_str = output_str ..'. – '.. description end
| |
| text = '<span style="border-bottom: 1px dotted gray; cursor: help;" title="' .. output_str .. ' (БТС).">' .. text .. '</span>' | | text = '<span style="border-bottom: 1px dotted gray; cursor: help;" title="' .. output_str .. ' (БТС).">' .. text .. '</span>' |
| 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 |
Строка 306: |
Строка 347: |
| output_str = output_str ..' '.. origin | | output_str = output_str ..' '.. origin |
| else | | else |
− | 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 |
Строка 315: |
Строка 356: |
| end | | end |
| | | |
− | output_str = ' [' .. output_str .. ']' | + | output_str = ' <nowiki>[</nowiki>' .. output_str .. ']' |
| if font_grey then output_str = '<span style="color: gray;">' .. output_str ..'</span>' end | | if font_grey then output_str = '<span style="color: gray;">' .. output_str ..'</span>' end |
| text = text .. output_str | | text = text .. output_str |