Строка 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 |