Module:Citation/CS1: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | |||
-- Set sandbox if present | |||
local sandbox = '' | local sandbox = '' | ||
if mw.getCurrentFrame():getTitle():find('/sandbox') then | if mw.getCurrentFrame():getTitle():find('/sandbox') then | ||
Line 4: | Line 7: | ||
end | end | ||
local | -- Safe load of configuration | ||
if not | local status, cfg = pcall(function() | ||
return mw.loadData('Module:Citation/CS1/Configuration' .. sandbox) | |||
end) | |||
-- If cfg failed or cfg.date_names is nil, inject safe fallback | |||
if not status or type(cfg.date_names) ~= 'table' then | |||
cfg = { | cfg = { | ||
date_names = { | date_names = { | ||
Line 26: | Line 34: | ||
end | end | ||
local | -- Attempt to load engine module | ||
local cs1_engine = require('Module:Citation/CS1/Engine' .. sandbox) | |||
function p.citation(frame) | function p.citation(frame) | ||
return | return cs1_engine.citation(frame, cfg) | ||
end | end | ||
return p | return p |
Revision as of 12:11, 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 = {}
-- Set sandbox if present
local sandbox = ''
if mw.getCurrentFrame():getTitle():find('/sandbox') then
sandbox = '/sandbox'
end
-- Safe load of configuration
local status, cfg = pcall(function()
return mw.loadData('Module:Citation/CS1/Configuration' .. sandbox)
end)
-- If cfg failed or cfg.date_names is nil, inject safe fallback
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
-- Attempt to load engine module
local cs1_engine = require('Module:Citation/CS1/Engine' .. sandbox)
function p.citation(frame)
return cs1_engine.citation(frame, cfg)
end
return p