Module:Citation/CS1: Difference between revisions

From AviationSafetyX Wiki
Jump to navigation Jump to search
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 ok, cfg = pcall(mw.loadData, 'Module:Citation/CS1/Configuration' .. sandbox)
-- Safe load of configuration
if not ok then
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 p = {}
-- Attempt to load engine module
local cs1_engine = require('Module:Citation/CS1/Engine' .. sandbox)


-- ✨ Define the citation function (even if just a placeholder)
function p.citation(frame)
function p.citation(frame)
return "[citation module under repair]"
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>

<templatestyles src="Module:Message box/ombox.css"></templatestyles>

<templatestyles src="Module:Message box/ombox.css"></templatestyles>

<templatestyles src="Module:Message box/ombox.css"></templatestyles>

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:

CS1 | CS2 modules
live sandbox diff description
Gold padlock Module:Citation/CS1 Module:Citation/CS1/sandbox [edit] diff Rendering and support functions
Module:Citation/CS1/Configuration Module:Citation/CS1/Configuration/sandbox [edit] diff Translation tables; error and identifier handlers
Module:Citation/CS1/Whitelist Module:Citation/CS1/Whitelist/sandbox [edit] diff List of active and deprecated CS1|2 parameters
Module:Citation/CS1/Date validation Module:Citation/CS1/Date validation/sandbox [edit] diff Date format validation functions
Module:Citation/CS1/Identifiers Module:Citation/CS1/Identifiers/sandbox [edit] diff Functions that support the named identifiers (ISBN, DOI, PMID, etc.)
Module:Citation/CS1/Utilities Module:Citation/CS1/Utilities/sandbox [edit] diff Common functions and tables
Module:Citation/CS1/COinS Module:Citation/CS1/COinS/sandbox [edit] diff Functions that render a CS1|2 template's metadata
Module:Citation/CS1/styles.css Module:Citation/CS1/sandbox/styles.css [edit] diff CSS styles applied to the CS1|2 templates
Silver padlock Module:Citation/CS1/Suggestions Module:Citation/CS1/Suggestions/sandbox [edit] diff List that maps common erroneous parameter names to valid parameter names

<section end=module_components_table />

Other documentation:

testcases


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