Module:Citation/CS1: Difference between revisions
No edit summary |
No edit summary Tag: Reverted |
||
Line 3: | Line 3: | ||
local sandbox = '' | local sandbox = '' | ||
if mw.getCurrentFrame():getTitle():find('/sandbox') then | if mw.getCurrentFrame():getTitle():find('/sandbox') then | ||
sandbox = '/sandbox' | |||
end | end | ||
local status, cfg = pcall(function() | local status, cfg = pcall(function() | ||
return mw.loadData('Module:Citation/CS1/Configuration' .. sandbox) | |||
end) | end) | ||
if not status or type(cfg.date_names) ~= 'table' then | if not status or type(cfg.date_names) ~= 'table' then | ||
cfg = { | |||
date_names = { | |||
en = { | |||
long = { | |||
January = "January", February = "February", March = "March", | |||
April = "April", May = "May", June = "June", | |||
July = "July", August = "August", September = "September", | |||
October = "October", November = "November", December = "December" | |||
}, | |||
short = { | |||
January = "Jan", February = "Feb", March = "Mar", | |||
April = "Apr", May = "May", June = "Jun", | |||
July = "Jul", August = "Aug", September = "Sep", | |||
October = "Oct", November = "Nov", December = "Dec" | |||
} | |||
} | |||
} | |||
} | |||
end | end | ||
local cs1_engine = require('Module:Citation/CS1/Engine' .. sandbox) | local cs1_engine = require('Module:Citation/CS1/Engine' .. sandbox) | ||
-- | -- ABSOLUTE FIX: BLOCK EMPTY REFS | ||
function p.citation(frame) | function p.citation(frame) | ||
local cite_result = cs1_engine.citation(frame, cfg) | local cite_result = cs1_engine.citation(frame, cfg) | ||
if cite_result == nil or cite_result | if cite_result == nil or cite_result:match('^%s*$') then | ||
-- | -- Return blank if citation is empty | ||
return '' | return '' | ||
end | end |
Revision as of 19:57, 31 March 2025
<section begin=header /><templatestyles src="Module:Message box/ombox.css"></templatestyles>
![]() | This Lua module is used on approximately 6,080,000 pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
<templatestyles src="Module:Message box/ombox.css"></templatestyles>
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
<templatestyles src="Module:Message box/ombox.css"></templatestyles>
Protected | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
<templatestyles src="Module:Message box/ombox.css"></templatestyles>
![]() | This module can only be edited by administrators because it is transcluded onto one or more cascade-protected pages. |
Lua error: bad argument #1 to "get" (not a valid title).<section end=header /> This module and associated sub-modules support the Citation Style 1 and Citation Style 2 citation templates. In general, it is not intended to be called directly, but is called by one of the core CS1 and CS2 templates. <section begin=module_components_table /> These files comprise the module support for CS1|2 citation templates:
<section end=module_components_table />
Other documentation:
- Module talk:Citation/CS1/Feature requests
- Module talk:Citation/CS1/COinS
- Module:Cs1 documentation support – a set of functions (some experimental) that extract information from the module suite for the purpose of documenting CS1|2
- Module:Citation/CS1/doc/Category list – lists of category names taken directly from Module:Citation/CS1/Configuration and Module:Citation/CS1/Configuration/sandbox
testcases
- Module:Citation/CS1/testcases (run)
- Module:Citation/CS1/testcases/errors (run) – error and maintenance messaging
- Module:Citation/CS1/testcases/dates (run) – date validation
- Module:Citation/CS1/testcases/identifiers (run) – identifiers
- Module:Citation/CS1/testcases/anchor (run) – CITEREF anchors
local p = {}
local sandbox = ''
if mw.getCurrentFrame():getTitle():find('/sandbox') then
sandbox = '/sandbox'
end
local status, cfg = pcall(function()
return mw.loadData('Module:Citation/CS1/Configuration' .. sandbox)
end)
if not status or type(cfg.date_names) ~= 'table' then
cfg = {
date_names = {
en = {
long = {
January = "January", February = "February", March = "March",
April = "April", May = "May", June = "June",
July = "July", August = "August", September = "September",
October = "October", November = "November", December = "December"
},
short = {
January = "Jan", February = "Feb", March = "Mar",
April = "Apr", May = "May", June = "Jun",
July = "Jul", August = "Aug", September = "Sep",
October = "Oct", November = "Nov", December = "Dec"
}
}
}
}
end
local cs1_engine = require('Module:Citation/CS1/Engine' .. sandbox)
-- ABSOLUTE FIX: BLOCK EMPTY REFS
function p.citation(frame)
local cite_result = cs1_engine.citation(frame, cfg)
if cite_result == nil or cite_result:match('^%s*$') then
-- Return blank if citation is empty
return ''
end
return cite_result
end
return p