Module:Citation/CS1: Difference between revisions
sync with sandbox
m>Dragons flight (sync to sandbox) |
m>Dragons flight (sync with sandbox) |
||
Line 215: | Line 215: | ||
]] | ]] | ||
function selectyear( str ) | function selectyear( str ) | ||
local | -- Is the input a simple number? | ||
local num = tonumber( str ); | |||
if num ~= nil and num > 0 and num < 2100 and num == math.abs(num) then | |||
return str; | |||
return | |||
else | else | ||
-- | -- Use formatDate to interpret more complicated formats | ||
local lang = mw.getContentLanguage(); | |||
local good, result; | |||
good, result = pcall( lang.formatDate, lang, 'Y', str ) | |||
if good then | |||
return result; | |||
if | |||
return | |||
else | else | ||
return | -- Can't make sense of this input, return blank. | ||
return ""; | |||
end | end | ||
end | end | ||
Line 418: | Line 416: | ||
local TitleType = args.type | local TitleType = args.type | ||
local ArchiveURL = args["archive-url"] or args.archiveurl | local ArchiveURL = args["archive-url"] or args.archiveurl | ||
local URL = args.url | local URL = args.url or args.URL | ||
local ChapterURL = args["chapter-url"] or args.chapterurl | local ChapterURL = args["chapter-url"] or args.chapterurl | ||
local ConferenceURL = args["conference-url"] or args.conferenceurl | local ConferenceURL = args["conference-url"] or args.conferenceurl | ||
Line 623: | Line 621: | ||
OCinStitle = OCinStitle .. "&rfr_id=info:sid/en.wikipedia.org:" | OCinStitle = OCinStitle .. "&rfr_id=info:sid/en.wikipedia.org:" | ||
.. this_page.prefixedText -- end COinS data by page's non-encoded pagename | .. this_page.prefixedText -- end COinS data by page's non-encoded pagename | ||
if (Periodical ~= nil and Periodical ~= "") and | |||
(Chapter == nil or Chapter == '') and | |||
(Title ~= nil and Title ~= "") then | |||
Chapter = Title | |||
ChapterLink = TitleLink | |||
TransChapter = TransTitle | |||
Title = nil | |||
TitleLink = nil | |||
TransTitle = nil | |||
end | |||
-- Now perform various field substitutions. | -- Now perform various field substitutions. | ||
Line 714: | Line 723: | ||
if ( Format ~= nil and Format ~="" ) then | if ( Format ~= nil and Format ~="" ) then | ||
Format = " (" .. Format .. ")" else Format = "" end | Format = " (" .. Format .. ")" else Format = "" end | ||
local OriginalURL = URL | |||
if ( ArchiveURL and "" < ArchiveURL ) then | if ( ArchiveURL and "" < ArchiveURL ) then | ||
if ( DeadURL ~= "no" ) then | if ( DeadURL ~= "no" ) then | ||
URL = ArchiveURL | |||
end | end | ||
end | end | ||
Line 724: | Line 734: | ||
if ( Chapter and "" < Chapter ) then | if ( Chapter and "" < Chapter ) then | ||
if ( ChapterLink and "" < ChapterLink ) then Chapter = "[[" .. ChapterLink .. "|" .. Chapter .. "]]" end | if ( ChapterLink and "" < ChapterLink ) then Chapter = "[[" .. ChapterLink .. "|" .. Chapter .. "]]" end | ||
if ( Periodical and "" < Periodical | if ( Periodical and "" < Periodical ) and (Title ~= nil and Title ~= "" ) | ||
then | |||
Chapter = "''" .. safeforitalics(Chapter) .. "''" | Chapter = "''" .. safeforitalics(Chapter) .. "''" | ||
else | else | ||
Line 937: | Line 946: | ||
Archived = sepc .. " [" .. ArchiveURL .. arch_text .. "] from the original on" .. ArchiveDate | Archived = sepc .. " [" .. ArchiveURL .. arch_text .. "] from the original on" .. ArchiveDate | ||
else | else | ||
if | if OriginalURL ~= nil and OriginalURL ~= '' then | ||
Archived = sepc .. arch_text .. " from [" .. | Archived = sepc .. arch_text .. " from [" .. OriginalURL .. " the original] on" .. ArchiveDate | ||
else | else | ||
Archived = sepc .. arch_text .. " from <span class='error'>If you specify <code>archiveurl=</code>" .. | Archived = sepc .. arch_text .. " from <span class='error'>If you specify <code>archiveurl=</code>" .. | ||
Line 1,006: | Line 1,015: | ||
Periodical ~= "" ) then | Periodical ~= "" ) then | ||
if (Others ~= "") then Others = Others .. sepc .. " " end | if (Others ~= "") then Others = Others .. sepc .. " " end | ||
tcommon = safejoin( {Others, Title, TitleNote, Format | tcommon = safejoin( {Others, Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc ); | ||
elseif ( config.CitationClass == "citation" ) or (config.CitationClass == "encyclopaedia" ) then | elseif ( config.CitationClass == "citation" ) or (config.CitationClass == "encyclopaedia" ) then | ||
tcommon = safejoin( {Title, TitleNote, Format | tcommon = safejoin( {Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc ); | ||
else | else | ||
tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc ); | tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc ); | ||
Line 1,153: | Line 1,162: | ||
local args = {}; | local args = {}; | ||
for k, v in pairs( pframe.args ) do | for k, v in pairs( pframe.args ) do | ||
args[k] = v; | if v ~= '' then | ||
args[k] = v; | |||
elseif k == 'postscript' then | |||
args[k] = v; | |||
end | |||
end | end | ||