Modul:Citation/CS1/peskovnik: Razlika med redakcijama
Izbrisana vsebina Dodana vsebina
mBrez povzetka urejanja |
mBrez povzetka urejanja |
||
Vrstica 5:
]]
local dates, year_date_check, reformat_dates
local is_set, in_array, substitute, error_comment, set_error, select_one, -- functions in Modul:Citation/CS1/Utilities
Vrstica 18:
local cfg = {}; -- table of configuration tables that are defined in Modul:Citation/CS1/Configuration
local whitelist = {}; -- table of tables listing valid template parameter names; defined in Modul:Citation/CS1/Whitelist
--[[--------------------------< F I R S T _ S E T >------------------------------------------------------------
Vrstica 71 ⟶ 62:
local added_vanc_errs; -- flag so we only emit one Vancouver error / category
local function add_vanc_error (
if not added_vanc_errs then
added_vanc_errs = true; -- note that we've added this category
table.insert( z.message_tail, { set_error( 'vancouver', {
end
end
Vrstica 484 ⟶ 475:
script_value = script_value:gsub ('^%l%l%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
if in_array (lang, {'am', 'ar', 'be', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
add_prop_cat ('script_with_name', {name, lang})
else
Vrstica 850 ⟶ 841:
return str;
end
--[[--------------------------< I S _ G O O D _ V A N C _ N A M E >--------------------------------------------
Vrstica 881 ⟶ 858:
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods
At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.
]]
local function is_good_vanc_name (last, first)
if nil == mw.ustring.find (last, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%']*$") or nil == mw.ustring.find (first, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%'%.]*$") then
add_vanc_error ();
return false; -- not a string of latin characters; Vancouver required Romanization
end;
return true;
Vrstica 917 ⟶ 877:
Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.
Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().
Vrstica 925 ⟶ 885:
local function reduce_to_initials(first)
local initials = {}
table.insert(initials, mw.ustring.sub(word,1,1)) -- Vancouver format does not include full stops.
i = i + 1; -- bump the counter
if 2 <= i then break; end -- only two initials allowed in Vancouver system; if 2, quit
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
Vrstica 1.143 ⟶ 1.065:
When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from
template's metadata. When this occurs, the page is added to a maintenance category.
Vrstica 1.210 ⟶ 1.132:
and the associated code is not two or three characters, this function returns only the Wikimedia language name.
Adapted from code taken from
]]
Vrstica 1.453 ⟶ 1.375:
--[[--------------------------< E X T R A _ T E X T _ I N _ P A G E _ C H E C K >------------------------------
Adds page to Kategorija:CS1
abbreviation in the first characters of the parameter content.
Vrstica 1.486 ⟶ 1.408:
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.
This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.
TODO: check for names like Coon V JS (Coon JS 5th at PMID 25205766, John S. Coon V at doi:10.1093/humupd/dmu048)?
]]
Vrstica 1.497 ⟶ 1.419:
local v_name_table = {};
local etal = false; -- return value set to true when we find some form of et al. vauthors parameter
local last, first, link, mask
local corporate = false;
vparam, etal = name_has_etal (vparam, etal, true); -- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
if vparam:find ('%[%[') or vparam:find ('%]%]') then -- no wikilinking vauthors names
add_vanc_error (
end
v_name_table = mw.text.split(vparam, "%s*,%s*") -- names are separated by commas
for i, v_name in ipairs(v_name_table) do
if v_name:match ('^%(%(.+%)%)$') then -- corporate authors are wrapped in doubled
first = ''; -- set to empty string for concatenation and because it may have been set for previous author/editor
last = v_name:match ('^%(%((.+)%)%)$')
corporate = true;
elseif string.find(v_name, "%s") then
local lastfirstTable = {}
lastfirstTable = mw.text.split(v_name, "%s")
first = table.remove(lastfirstTable); -- removes and returns value of last element in table which should be author intials
last = table.concat(lastfirstTable, " ") -- returns a string that is the concatenation of all other names that are not initials
if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
add_vanc_error (); -- matches last II last; the case when a comma is missing or a space between two intiials
end
else
Vrstica 1.534 ⟶ 1.446:
end
if is_set (first) and not mw.ustring.match (first, "^%u?%u$") then -- first shall contain one or two upper-case letters, nothing else
add_vanc_error ();
end
-- this from extract_names ()
link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
Vrstica 1.756 ⟶ 1.657:
Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the
save snapshot url
When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a
This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
|archive-url= holds an archive.org save command url
|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the correct place
otherwise returns |archive-url= and |archive-date=
Vrstica 1.777 ⟶ 1.676:
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.
]=]
Vrstica 1.791 ⟶ 1.684:
if not url:match('//web%.archive%.org/') then
return url, date; -- not an archive.org archive, return
end
if url:match('//web%.archive%.org/save/') then -- if a save command url, we don't want to allow saving of the target page
table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } ); -- add error message
return '', ''; -- return empty strings for archiveURL and ArchiveDate
end
path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/'); -- split out some of the url parts for evaluation
if not is_set(timestamp) or 14 ~= timestamp:len() then
err_msg = 'timestamp';
elseif is_set(path) and 'web/' ~= path then -- older archive urls do not have the extra 'web/' path element
err_msg = 'path';
Vrstica 1.826 ⟶ 1.712:
-- if here something not right so
table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } ); -- add error message and
return '', ''; -- return empty strings for archiveURL and ArchiveDate
end
Vrstica 1.975 ⟶ 1.857:
ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
-- local ArchiveDate = A['ArchiveDate'];
-- local ArchiveURL = A['ArchiveURL'];
-- if ArchiveURL:match('//web%.archive%.org/save/') then -- if an archive.org save command url, we don't want to save target page ...
-- ArchiveURL = ''; -- every time a reader clicks the link so
-- ArchiveDate = ''; -- unset these
-- table.insert( z.message_tail, { set_error( 'archive_save', {}, true ) } ); -- and add error message
-- end
local DeadURL = A['DeadURL']
if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then -- set in config.defaults to 'yes'
Vrstica 2.391 ⟶ 2.280:
local error_message = '';
-- AirDate has been promoted to Date so not necessary to check it
anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);
if is_set (Year) and is_set (Date) then -- both |date= and |year= not normally needed;
Vrstica 2.409 ⟶ 2.294:
end
end
if is_set(error_message) then
Vrstica 2.827 ⟶ 2.689:
if is_set (Translators) then
end
Vrstica 3.133 ⟶ 2.994:
text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
else
if
text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
else
Vrstica 3.170 ⟶ 3.031:
namelist = e;
end
end
options.id = id;
Vrstica 3.240 ⟶ 3.097:
local validation, utilities, identifiers, metadata;
if nil ~= string.find (frame:getTitle(), 'peskovnik', 1, true) then -- did the {{#invoke:}} use
cfg = mw.loadData ('Modul:Citation/CS1/Configuration/peskovnik'); -- load
whitelist = mw.loadData ('Modul:Citation/CS1/Whitelist/peskovnik');
utilities = require ('Modul:Citation/CS1/Utilities/peskovnik');
Vrstica 3.265 ⟶ 3.122:
year_date_check = validation.year_date_check;
reformat_dates = validation.reformat_dates;
is_set = utilities.is_set; -- imported functions from Modul:Citation/CS1/Utilities
Vrstica 3.288 ⟶ 3.144:
COinS = metadata.COinS;
local args = {};
Vrstica 3.320 ⟶ 3.169:
else
if nil == suggestions.suggestions then -- if this table is nil then we need to load it
if nil ~= string.find (frame:getTitle(), 'peskovnik', 1, true) then -- did the {{#invoke:}} use
suggestions = mw.loadData( 'Modul:Citation/CS1/Suggestions/peskovnik' ); -- use the
else
suggestions = mw.loadData( 'Modul:Citation/CS1/Suggestions' ); -- use the live version
|