Module:Citation/CS1: Difference between revisions
Jump to navigation
Jump to search
(if nil_or_not == nil then) |
(test) |
||
Line 1: | Line 1: | ||
local z = { | local z = { | ||
error_categories = {}; | error_categories = {}; | ||
Line 221: | Line 216: | ||
label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id, | label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id, | ||
encode=handler.encode, separator = handler.separator}) | encode=handler.encode, separator = handler.separator}) | ||
end | end | ||
Line 300: | Line 262: | ||
end | end | ||
end | end | ||
--[[ | --[[ | ||
Line 535: | Line 445: | ||
local lang = mw.getContentLanguage(); | local lang = mw.getContentLanguage(); | ||
local good, result; | local good, result; | ||
good, result = pcall( lang.formatDate, lang, 'Y', str ) | good, result = pcall( lang.formatDate, lang, 'Y', str ) | ||
if good then | if good then | ||
return result; | return result; | ||
else | else | ||
-- | -- Can't make sense of this input, return blank. | ||
return ""; | |||
end | |||
end | |||
end | |||
end | |||
end | |||
end | |||
-- Attempts to convert names to initials. | -- Attempts to convert names to initials. | ||
Line 696: | Line 588: | ||
elseif k == 'OL' then | elseif k == 'OL' then | ||
table.insert( new_list, {handler.label, openlibrary( v ) } ); | table.insert( new_list, {handler.label, openlibrary( v ) } ); | ||
elseif k == 'ISBN' then | elseif k == 'ISBN' then | ||
local ISBN = internallinkid( handler ); | local ISBN = internallinkid( handler ); | ||
Line 960: | Line 848: | ||
local PublisherName = A['PublisherName']; | local PublisherName = A['PublisherName']; | ||
local SubscriptionRequired = A['SubscriptionRequired']; | local SubscriptionRequired = A['SubscriptionRequired']; | ||
local Via = A['Via']; | local Via = A['Via']; | ||
Line 975: | Line 862: | ||
local ASINTLD = A['ASINTLD']; | local ASINTLD = A['ASINTLD']; | ||
local IgnoreISBN = A['IgnoreISBN']; | local IgnoreISBN = A['IgnoreISBN']; | ||
local ID_list = extractids( args ); | local ID_list = extractids( args ); | ||
Line 991: | Line 877: | ||
local use_lowercase = ( sepc ~= '.' ); | local use_lowercase = ( sepc ~= '.' ); | ||
local this_page = mw.title.getCurrentTitle(); --Also used for COinS | local this_page = mw.title.getCurrentTitle(); --Also used for COinS | ||
if not is_set(no_tracking_cats) then | if not is_set(no_tracking_cats) then | ||
Line 998: | Line 884: | ||
no_tracking_cats = "true"; | no_tracking_cats = "true"; | ||
break; | break; | ||
end | |||
end | |||
end | |||
if ( config.CitationClass == "journal" ) then | |||
if not is_set(URL) and is_set(ID_list['PMC']) then | |||
local Embargo = A['Embargo']; | |||
if is_set(Embargo) then | |||
local lang = mw.getContentLanguage(); | |||
local good1, result1, good2, result2; | |||
good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo ); | |||
good2, result2 = pcall( lang.formatDate, lang, 'U' ); | |||
if good1 and good2 and tonumber( result1 ) < tonumber( result2 ) then | |||
URL = "http://www.ncbi.nlm.nih.gov/pmc/articles/PMC" .. ID_list['PMC']; | |||
URLorigin = cfg.id_handlers['PMC'].parameters[1]; | |||
end | |||
else | |||
URL = "http://www.ncbi.nlm.nih.gov/pmc/articles/PMC" .. ID_list['PMC']; | |||
URLorigin = cfg.id_handlers['PMC'].parameters[1]; | |||
end | end | ||
end | end | ||
Line 1,101: | Line 1,007: | ||
Authors = listpeople(control, a) | Authors = listpeople(control, a) | ||
end | end | ||
local EditorCount | local EditorCount | ||
Line 1,378: | Line 1,280: | ||
At = At .. Section .. Inset; | At = At .. Section .. Inset; | ||
end | end | ||
Others = is_set(Others) and (sepc .. " " .. Others) or ""; | Others = is_set(Others) and (sepc .. " " .. Others) or ""; | ||
TitleType = is_set(TitleType) and (" (" .. TitleType .. ")") or ""; | TitleType = is_set(TitleType) and (" (" .. TitleType .. ")") or ""; | ||
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or ""; | TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or ""; | ||
Language = is_set(Language) and (" " .. wrap( 'language', Language )) or ""; | |||
Edition = is_set(Edition) and (" " .. wrap( 'edition', Edition )) or ""; | Edition = is_set(Edition) and (" " .. wrap( 'edition', Edition )) or ""; | ||
Issue = is_set(Issue) and (" (" .. Issue .. ")") or ""; | Issue = is_set(Issue) and (" (" .. Issue .. ")") or ""; | ||
Line 1,416: | Line 1,299: | ||
------------------------------------ totally unrelated data | ------------------------------------ totally unrelated data | ||
-- | -- Mimic {{subscription required}} template; | ||
if is_set(Via) then | if is_set(Via) then | ||
Via = " " .. wrap( 'via', Via ); | Via = " " .. wrap( 'via', Via ); | ||
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; --citation always requires subscription if 'via' parameter is used | |||
elseif is_set(SubscriptionRequired) then | |||
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription_no_via']; --here when 'via' parameter not used but 'subscription' is | |||
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; -- | |||
elseif is_set( | |||
SubscriptionRequired = sepc .. " " .. cfg.messages[' | |||
end | end | ||
Line 1,440: | Line 1,316: | ||
if is_set(ID) then ID = sepc .." ".. ID; end | if is_set(ID) then ID = sepc .." ".. ID; end | ||
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN | ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} ); | ||
if is_set(URL) then | if is_set(URL) then |