Изменения

по умолчанию считаем всех живыми
Строка 16: Строка 16:  
local cfg = {}; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration
 
local cfg = {}; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration
 
local whitelist = {}; -- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist
 
local whitelist = {}; -- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist
 +
 +
local boxDate = require('Module:Calendar').bxDate; -- РУВИКИ: все даты делаем человекочитаемыми
      Строка 423: Строка 425:     
return base_url;
 
return base_url;
 +
end
 +
 +
--[[--------------------------< F O R M A T E _  D A T E >-----------------------------------------------------
 +
 +
Call a calendar module that turns all non-local language dates (including ISO dates) into local language dates.
 +
Used for archiving and review dates.
 +
 +
]]
 +
 +
local function formatDate(txtDateIn, strFormat, params)
 +
local txtDateOut, date, status = boxDate(txtDateIn, strFormat, params)
 +
if status.brk then
 +
return error(status.errorText)
 +
else
 +
return txtDateOut
 +
end
 
end
 
end
   Строка 664: Строка 682:  
periodical = ''; -- to be safe for concatenation
 
periodical = ''; -- to be safe for concatenation
 
else
 
else
periodical = utilities.wrap_style ('italic-title', periodical); -- style  
+
periodical = utilities.wrap_style ('italic-title', periodical); -- style
 
end
 
end
   Строка 1392: Строка 1410:  
This function will only emit one error and one maint message for the current template.  Does not emit both error
 
This function will only emit one error and one maint message for the current template.  Does not emit both error
 
and maint messages/categories for the same parameter value.
 
and maint messages/categories for the same parameter value.
  −
returns nothing
      
]]
 
]]
Строка 1768: Строка 1784:     
for _, lang in ipairs (names_t) do -- reuse lang here because we don't yet know if lang is a language name or a language tag
 
for _, lang in ipairs (names_t) do -- reuse lang here because we don't yet know if lang is a language name or a language tag
 +
 +
local fromEnglishToCode = { -- костыль для РУВИКИ: замена распространённых англоназваний на коды, в следующей итерации использовать Module:Language.
 +
['Arabic'] = 'ar',
 +
['Azerbaijani'] = 'az',
 +
['Belarusian'] = 'be',
 +
['Bulgarian'] = 'bg',
 +
['Czech'] = 'cs',
 +
['Danish'] = 'da',
 +
['German'] = 'de',
 +
['Greek'] = 'el',
 +
['Spanish'] = 'es',
 +
['English'] = 'en',
 +
['Finnish'] = 'fi',
 +
['French'] = 'fr',
 +
['Hebrew'] = 'he',
 +
['Croatian'] = 'hr',
 +
['Hungarian'] = 'hu',
 +
['Armenian'] = 'hy',
 +
['Indonesian'] = 'id',
 +
['Italian'] = 'it',
 +
['Japanese'] = 'ja',
 +
['Korean'] = 'ko',
 +
['Latin'] = 'la',
 +
['Dutch'] = 'nl',
 +
['Norwegian'] = 'no',
 +
['Polish'] = 'pl',
 +
['Portuguese'] = 'pt',
 +
['Romanian'] = 'ro',
 +
['Russian'] = 'ru',
 +
['Slovenian'] = 'sl',
 +
['Serbian'] = 'sr',
 +
['Swedish'] = 'sv',
 +
['Thai'] = 'th',
 +
['Turkish'] = 'tr',
 +
['Ukrainian'] = 'uk',
 +
['Chinese'] = 'zh',
 +
}
 +
if fromEnglishToCode[lang] then
 +
lang = fromEnglishToCode[lang]
 +
end
 +
 
name, tag = name_tag_get (lang); -- attempt to get name/tag pair for <lang>; <name> has proper capitalization; <tag> is lowercase
 
name, tag = name_tag_get (lang); -- attempt to get name/tag pair for <lang>; <name> has proper capitalization; <tag> is lowercase
   Строка 1795: Строка 1852:  
return ''; -- if one language and that language is this wiki's return an empty string (no annotation)
 
return ''; -- if one language and that language is this wiki's return an empty string (no annotation)
 
end
 
end
return (" " .. wrap_msg ('language', name)); -- otherwise wrap with '(in ...)'
+
return (mw.getCurrentFrame():expandTemplate{ -- РУВИКИ: используем шаблон для отображения языка
 +
title= utilities.substitute (cfg.messages ['language'], tag)
 +
}); -- otherwise wrap with '(in ...)'
 
--[[ TODO: should only return blank or name rather than full list
 
--[[ TODO: should only return blank or name rather than full list
 
so we can clean up the bunched parenthetical elements Language, Type, Format
 
so we can clean up the bunched parenthetical elements Language, Type, Format
Строка 2551: Строка 2610:  
end
 
end
 
end
 
end
      
--[[--------------------------< D I S P L A Y _ N A M E S _ S E L E C T >--------------------------------------
 
--[[--------------------------< D I S P L A Y _ N A M E S _ S E L E C T >--------------------------------------
Строка 2596: Строка 2654:  
end
 
end
 
end
 
end
      
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
 
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
Строка 2639: Строка 2696:  
a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList'); -- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
 
a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList'); -- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
 
elseif 3 == selected then
 
elseif 3 == selected then
Authors = A['Authors']; -- use content of |people= or |credits=; |authors= is deprecated; TODO: constrain |people= and |credits= to cite av media, episode, serial?
+
Authors = A['Authors']; -- use content of |authors=
 
end
 
end
 
if utilities.is_set (Collaboration) then
 
if utilities.is_set (Collaboration) then
Строка 2713: Строка 2770:  
local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
 
local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
 
 
if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
+
if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
 
local param;
 
local param;
 
if utilities.is_set (Periodical) then -- get a parameter name from one of these periodical related meta-parameters
 
if utilities.is_set (Periodical) then -- get a parameter name from one of these periodical related meta-parameters
Строка 2873: Строка 2930:  
end
 
end
 
end
 
end
 +
 +
-- no_tracking_cats = "true"; -- выключаем всю категоризацию для РУВИКИ
 
-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
 
-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
 
utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters'); -- this is a dummy call simply to get the error message and category
 
utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters'); -- this is a dummy call simply to get the error message and category
Строка 3484: Строка 3543:  
OriginalFormat = ChapterFormat; -- and original |chapter-format=
 
OriginalFormat = ChapterFormat; -- and original |chapter-format=
   −
if 'live' ~= UrlStatus then
+
if utilities.in_array (UrlStatus, {'unfit', 'deviated', 'dead', 'usurped', 'bot: unknown'}) then
 
ChapterURL = ArchiveURL -- swap-in the archive's URL
 
ChapterURL = ArchiveURL -- swap-in the archive's URL
 
ChapterURL_origin = A:ORIGIN('ArchiveURL') -- name of |archive-url= parameter for error messages
 
ChapterURL_origin = A:ORIGIN('ArchiveURL') -- name of |archive-url= parameter for error messages
Строка 3496: Строка 3555:  
OriginalAccess = UrlAccess;
 
OriginalAccess = UrlAccess;
   −
if 'live' ~= UrlStatus then -- if URL set then |archive-url= applies to it
+
if utilities.in_array (UrlStatus, {'unfit', 'deviated', 'dead', 'usurped', 'bot: unknown'}) then -- if URL set then |archive-url= applies to it
 
URL = ArchiveURL -- swap-in the archive's URL
 
URL = ArchiveURL -- swap-in the archive's URL
 
URL_origin = A:ORIGIN('ArchiveURL') -- name of archive URL parameter for error messages
 
URL_origin = A:ORIGIN('ArchiveURL') -- name of archive URL parameter for error messages
Строка 3584: Строка 3643:  
('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then -- special case for cite map when the map is in a periodical treat as an article
 
('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then -- special case for cite map when the map is in a periodical treat as an article
 
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from module provided quote marks
 
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from module provided quote marks
Title = utilities.wrap_style ('quoted-title', Title);
+
Title = utilities.wrap_style ('quoted-title', Title);
 
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
 
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
 
TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
 
TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
Строка 3737: Строка 3796:  
if utilities.is_set (AccessDate) then
 
if utilities.is_set (AccessDate) then
 
local retrv_text = " " .. cfg.messages['retrieved']
 
local retrv_text = " " .. cfg.messages['retrieved']
 
+
local status, result = pcall(formatDate, AccessDate) -- РУВИКИ: человекочитаемые даты
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
+
if status then
 +
AccessDate = string.format("<span class='date'>%s</span>", result)
 +
else
 +
AccessDate = string.format("<span class='error'>(Строка «%s» не является верной датой, пожалуйста, укажите дату в формате <code>ГГГГ-ММ-ДД</code>)</span>", args.date)
 +
end
 +
-- AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
 
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if mode is cs2, lower case
 
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if mode is cs2, lower case
 
AccessDate = utilities.substitute (retrv_text, AccessDate); -- add retrieved text
 
AccessDate = utilities.substitute (retrv_text, AccessDate); -- add retrieved text
Строка 3838: Строка 3902:  
if utilities.is_set (ArchiveURL) then
 
if utilities.is_set (ArchiveURL) then
 
local arch_text;
 
local arch_text;
if "live" == UrlStatus then
+
local status, result = pcall(formatDate, ArchiveDate) -- РУВИКИ: человекочитаемые даты
 +
if status then
 +
ArchiveDate = string.format("<span class='date'>%s</span>", result)
 +
else
 +
ArchiveDate = string.format("<span class='error'>(Строка «%s» не является верной датой, пожалуйста, укажите дату в формате <code>ГГГГ-ММ-ДД</code>)</span>", ArchiveDate)
 +
end
 +
if "live" == UrlStatus or "" == UrlStatus then
 
arch_text = cfg.messages['archived'];
 
arch_text = cfg.messages['archived'];
 
if sepc ~= "." then arch_text = arch_text:lower() end
 
if sepc ~= "." then arch_text = arch_text:lower() end
Строка 3880: Строка 3950:  
Archived = '';
 
Archived = '';
 
end
 
end
+
 
 
local TranscriptURL = A['TranscriptURL']
 
local TranscriptURL = A['TranscriptURL']
 
local TranscriptFormat = A['TranscriptFormat'];
 
local TranscriptFormat = A['TranscriptFormat'];
Строка 3903: Строка 3973:  
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
 
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
 
else
 
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
+
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
 
end
 
end
 
elseif utilities.is_set (PublicationPlace) then  
 
elseif utilities.is_set (PublicationPlace) then  
Строка 4000: Строка 4070:  
local text;
 
local text;
 
local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;
 
local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;
 
+
 
local OrigDate = A['OrigDate'];
 
local OrigDate = A['OrigDate'];
 
OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
 
OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
Строка 4014: Строка 4084:  
end
 
end
 
end
 
end
 +
 
if utilities.is_set (Authors) then
 
if utilities.is_set (Authors) then
 
if (not utilities.is_set (Date)) then -- when date is set it's in parentheses; no Authors termination
 
if (not utilities.is_set (Date)) then -- when date is set it's in parentheses; no Authors termination
Строка 4084: Строка 4155:  
local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true); -- nil when |ref=harv; A['Ref'] else
 
local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true); -- nil when |ref=harv; A['Ref'] else
    +
-- Если указан параметр ref, то формируем ref-якорь по логике из рувики
 +
-- Если параметр не указан или ref=harv, то формируем якорь по енвики
 +
-- После зачистки всех ref=harv (~350), можно будет убрать код внутри utilities.is_set(Ref)
 
if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
 
if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
local namelist_t = {}; -- holds selected contributor, author, editor name list
+
local citeref_id = Ref
 
local year = first_set ({Year, anchor_year}, 2); -- Year first for legacy citations and for YMD dates that require disambiguation
 
local year = first_set ({Year, anchor_year}, 2); -- Year first for legacy citations and for YMD dates that require disambiguation
 
+
if not utilities.is_set(Ref) then
if #c > 0 then -- if there is a contributor list
+
local namelist_t = {}; -- holds selected contributor, author, editor name list
namelist_t = c; -- select it
+
elseif #a > 0 then -- or an author list
+
if #c > 0 then -- if there is a contributor list
namelist_t = a;
+
namelist_t = c; -- select it
elseif #e > 0 then -- or an editor list
+
elseif #a > 0 then -- or an author list
namelist_t = e;
+
namelist_t = a;
end
+
elseif #e > 0 then -- or an editor list
local citeref_id;
+
namelist_t = e;
if #namelist_t > 0 then -- if there are names in namelist_t
+
end
citeref_id = make_citeref_id (namelist_t, year); -- go make the CITEREF anchor
+
if #namelist_t > 0 then -- if there are names in namelist_t
if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then -- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
+
citeref_id = make_citeref_id (namelist_t, year); -- go make the CITEREF anchor
utilities.set_message ('maint_ref_duplicates_default');
+
if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then -- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
 +
utilities.set_message ('maint_ref_duplicates_default');
 +
end
 +
else
 +
citeref_id = ''; -- unset
 +
end
 +
elseif mw.ustring.sub(Ref, 0, 7) ~= 'CITEREF' then                      -- для рувики: иная генерация ref-якорей
 +
if mw.ustring.match(citeref_id, '%d%d%d%d') then
 +
citeref_id = 'CITEREF' .. citeref_id
 +
else
 +
local yearForRef = nil
 +
if year and mw.ustring.match(year, '^%d%d%d%d$') then
 +
yearForRef = mw.ustring.match(year, '^%d%d%d%d$')
 +
elseif Date and mw.ustring.match(Date, '%d%d%d%d') then
 +
yearForRef = mw.ustring.match(Date, '%d%d%d%d')
 +
end
 +
if yearForRef then
 +
citeref_id = 'CITEREF' .. citeref_id .. yearForRef
 +
else
 +
citeref_id = '' -- TODO: для рувики: выдавать ошибку?
 +
end
 
end
 
end
else
  −
citeref_id = ''; -- unset
   
end
 
end
options_t.id = Ref or citeref_id;
+
options_t.id = citeref_id or '';
 
end
 
end
   Строка 4184: Строка 4276:  
end
 
end
   −
for _, v in ipairs (z.prop_cats_t) do -- append properties categories
+
-- for _, v in ipairs (z.prop_cats_t) do -- append properties categories
table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v)); -- no sort keys
+
-- table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v)); -- no sort keys
end
+
-- end
 
end
 
end
  
Анонимный участник