Jump to content

Module:Citation/CS1 and Module:Citation/CS1/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
sync from sandbox;
 
No edit summary
 
Line 1: Line 1:
--[[
History of changes since last sync: 2024-03-23

2024-05-27: allow |agency= in {{cite magazine}}
2024-07-12: maint cat for |year= value more precise that a year; see Help_talk:Citation_Style_1#year_parameter

]]

require ('strict');
require ('strict');


Line 1,251: Line 1,259:
if one then -- if <one> has a value (name, mdash replacement, or mask text replacement)
if one then -- if <one> has a value (name, mdash replacement, or mask text replacement)
local proj, tag = interwiki_prefixen_get (one, true); -- get the interwiki prefixen if present
local proj, tag = interwiki_prefixen_get (one, true); -- get the interwiki prefixen if present

if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
proj = nil; -- for stuff like :w:de:<article>, :w is unnecessary TODO: maint cat?
proj = nil; -- for stuff like :w:de:<article>, :w is unnecessary TODO: maint cat?
end
end
if proj then
if proj then
proj = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj]; -- :w (wikipedia) for linking from a non-wikipedia project
local proj_name = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj]; -- :w (wikipedia) for linking from a non-wikipedia project
if proj then
if proj_name then
.. utilities.wrap_style ('interproj', proj); -- add resized leading space, brackets, static text, language name
.. utilities.wrap_style ('interproj', proj_name); -- add resized leading space, brackets, static text, language name
utilities.add_prop_cat ('interproj-linked-name', proj); -- categorize it; <proj> is sort key
tag = nil; -- unset; don't do both project and language
tag = nil; -- unset; don't do both project and language
end
end
Line 1,269: Line 1,277:
if lang then -- error messaging done in extract_names() where we know parameter names
if lang then -- error messaging done in extract_names() where we know parameter names
.. utilities.wrap_style ('interwiki', lang); -- add resized leading space, brackets, static text, language name
.. utilities.wrap_style ('interwiki', lang); -- add resized leading space, brackets, static text, language name
utilities.add_prop_cat ('interwiki-linked-name', tag); -- categorize it; <tag> is sort key
end
end
end
end
Line 3,158: Line 3,167:
local Year = A['Year'];
local Year = A['Year'];


if utilities.is_set (Year) then
validation.year_check (Year); -- returns nothing; emits maint message when |year= doesn't hold a 'year' value
end
if not utilities.is_set (Date) then
if not utilities.is_set (Date) then
Date = Year; -- promote Year to Date
Date = Year; -- promote Year to Date
Line 3,220: Line 3,233:
validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
end
end

if 0 == #error_list then -- error free dates only; 0 when error_list is empty
if 0 == #error_list then -- error free dates only; 0 when error_list is empty
local modified = false; -- flag
local modified = false; -- flag
Line 3,747: Line 3,760:


Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or ""; -- not the same as SeriesNum
Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or ""; -- not the same as SeriesNum
local Agency = A['Agency'] or ''; -- |agency= only supported in {{cite news}}, {{cite press release}}, {{cite web}} and certain {{citation}} templates
local Agency = A['Agency'] or ''; -- |agency= is supported by {{cite magazine}}, {{cite news}}, {{cite press release}}, {{cite web}}, and certain {{citation}} templates
if utilities.is_set (Agency) then -- this testing done here because {{citation}} supports 'news' citations
if utilities.is_set (Agency) then -- this testing done here because {{citation}} supports 'news' citations
if utilities.in_array (config.CitationClass, {'news', 'pressrelease', 'web'}) or ('citation' == config.CitationClass and utilities.in_array (Periodical_origin, {"newspaper", "work"})) then
if utilities.in_array (config.CitationClass, {'magazine', 'news', 'pressrelease', 'web'}) or ('citation' == config.CitationClass and utilities.in_array (Periodical_origin, {"magazine", "newspaper", "work"})) then
Agency = wrap_msg ('agency', {sepc, Agency}); -- format for rendering
Agency = wrap_msg ('agency', {sepc, Agency}); -- format for rendering
else
else