মডিউল:উদ্ধৃতি: সংশোধিত সংস্করণের মধ্যে পার্থক্য
অবয়ব
পাতাকে 'return {}' দিয়ে প্রতিস্থাপিত করা হল ট্যাগ: প্রতিস্থাপিত পুনর্বহালকৃত |
সম্পাদনা সারাংশ নেই ট্যাগ: পুনর্বহালকৃত |
||
| ১ নং লাইন: | ১ নং লাইন: | ||
return {} | |||
local cs1 ={}; | |||
--[[--------------------------< F O R W A R D D E C L A R A T I O N S >-------------------------------------- | |||
]] | |||
local dates, year_date_check, reformat_dates, date_hyphen_to_dash, -- functions in Module:Citation/CS1/Date_validation | |||
date_name_xlate | |||
local is_set, in_array, substitute, error_comment, set_error, select_one, -- functions in Module:Citation/CS1/Utilities | |||
add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink; | |||
local z ={}; -- tables in Module:Citation/CS1/Utilities | |||
local extract_ids, extract_id_access_levels, build_id_list, is_embargoed; -- functions in Module:Citation/CS1/Identifiers | |||
local make_coins_title, get_coins_pages, COinS; -- functions in Module:Citation/CS1/COinS | |||
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 | |||
--[[--------------------------< P A G E S C O P E V A R I A B L E S >-------------------------------------- | |||
delare variables here that have page-wide scope that are not brought in from other modules; thatare created here | |||
and used here | |||
]] | |||
local added_deprecated_cat; -- boolean flag so that the category is added only once | |||
local added_prop_cats = {}; -- list of property categories that have been added to z.properties_cats | |||
local added_vanc_errs; -- boolean flag so we only emit one Vancouver error / category | |||
local Frame; -- holds the module's frame table | |||
--[[--------------------------< F I R S T _ S E T >------------------------------------------------------------ | |||
Locates and returns the first set value in a table of values where the order established in the table, | |||
left-to-right (or top-to-bottom), is the order in which the values are evaluated. Returns nil if none are set. | |||
This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs. With the pairs | |||
version the order of evaluation could not be guaranteed. With the ipairs version, a nil value would terminate | |||
the for-loop before it reached the actual end of the list. | |||
]] | |||
local function first_set (list, count) | |||
local i = 1; | |||
while i <= count do -- loop through all items in list | |||
if is_set( list[i] ) then | |||
return list[i]; -- return the first set list member | |||
end | |||
i = i + 1; -- point to next | |||
end | |||
end | |||
--[[--------------------------< A D D _ P R O P _ C A T >-------------------------------------------------------- | |||
Adds a category to z.properties_cats using names from the configuration file with additional text if any. | |||
foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages | |||
may be categorized but multiples of the same language are not categorized. | |||
added_prop_cats is a table declared in page scope variables above | |||
]] | |||
local function add_prop_cat (key, arguments) | |||
if not added_prop_cats [key] then | |||
added_prop_cats [key] = true; -- note that we've added this category | |||
key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1'); -- strip lang code from keyname | |||
table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments)); -- make name then add to table | |||
end | |||
end | |||
--[[--------------------------< A D D _ V A N C _ E R R O R >---------------------------------------------------- | |||
Module:নথি/রূপরেখা | |||
Adds a single Vancouver system error message to the template's output regardless of how many error actually exist. | |||
To prevent duplication, added_vanc_errs is nil until an error message is emitted. | |||
added_vanc_errs is a boolean declared in page scope variables above | |||
]] | |||
local function add_vanc_error (source) | |||
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', {source}, true ) } ); | |||
end | |||
end | |||
--[[--------------------------< I S _ S C H E M E >------------------------------------------------------------ | |||
does this thing that purports to be a uri scheme seem to be a valid scheme? The scheme is checked to see if it | |||
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says: | |||
Scheme names consist of a sequence of characters beginning with a | |||
letter and followed by any combination of letters, digits, plus | |||
("+"), period ("."), or hyphen ("-"). | |||
returns true if it does, else false | |||
]] | |||
local function is_scheme (scheme) | |||
return scheme and scheme:match ('^%a[%a%d%+%.%-]*:'); -- true if scheme is set and matches the pattern | |||
end | |||
--[=[-------------------------< I S _ D O M A I N _ N A M E >-------------------------------------------------- | |||
Does this thing that purports to be a domain name seem to be a valid domain name? | |||
Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5 | |||
BNF defined here: https://tools.ietf.org/html/rfc4234 | |||
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15; | |||
see also [[Single-letter second-level domain]] | |||
list of tlds: https://www.iana.org/domains/root/db | |||
rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit. Between | |||
the first and last characters the name may use letters, digits, and the hyphen. | |||
Also allowed are IPv4 addresses. IPv6 not supported | |||
domain is expected to be stripped of any path so that the last character in the last character of the tld. tld | |||
is two or more alpha characters. Any preceding '//' (from splitting a url with a scheme) will be stripped | |||
here. Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal. | |||
There are several tests: | |||
the first character of the whole domain name including subdomains must be a letter or a digit | |||
internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490 | |||
single-letter/digit second-level domains in the .org and .cash TLDs | |||
q, x, and z SL domains in the .com TLD | |||
i and q SL domains in the .net TLD | |||
single-letter SL domains in the ccTLDs (where the ccTLD is two letters) | |||
two-character SL domains in gTLDs (where the gTLD is two or more letters) | |||
three-plus-character SL domains in gTLDs (where the gTLD is two or more letters) | |||
IPv4 dot-decimal address format; TLD not allowed | |||
returns true if domain appears to be a proper name and tld or IPv4 address, else false | |||
]=] | |||
local function is_domain_name (domain) | |||
if not domain then | |||
return false; -- if not set, abandon | |||
end | |||
domain = domain:gsub ('^//', ''); -- strip '//' from domain name if present; done here so we only have to do it once | |||
if not domain:match ('^[%a%d]') then -- first character must be letter or digit | |||
return false; | |||
end | |||
-- Do most common case first | |||
if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then -- three or more character hostname.hostname or hostname.tld | |||
return true; | |||
elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then -- internationalized domain name with ACE prefix | |||
return true; | |||
elseif domain:match ('%f[%a%d][%a%d]%.cash$') then -- one character/digit .cash hostname | |||
return true; | |||
elseif domain:match ('%f[%a%d][%a%d]%.org$') then -- one character/digit .org hostname | |||
return true; | |||
elseif domain:match ('%f[%a][qxz]%.com$') then -- assigned one character .com hostname (x.com times out 2015-12-10) | |||
return true; | |||
elseif domain:match ('%f[%a][iq]%.net$') then -- assigned one character .net hostname (q.net registered but not active 2015-12-10) | |||
return true; | |||
elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then -- one character hostname and cctld (2 chars) | |||
return true; | |||
elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then -- two character hostname and tld | |||
return true; | |||
elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then -- IPv4 address | |||
return true; | |||
else | |||
return false; | |||
end | |||
end | |||
০৯:২৮, ৮ জানুয়ারি ২০২৬ তারিখে সংশোধিত সংস্করণ
এই মডিউলের জন্য মডিউল:উদ্ধৃতি/নথি-এ নথিপত্র তৈরি করা হয়ে থাকতে পারে
local cs1 ={};
--[[--------------------------< F O R W A R D D E C L A R A T I O N S >--------------------------------------
]]
local dates, year_date_check, reformat_dates, date_hyphen_to_dash, -- functions in Module:Citation/CS1/Date_validation
date_name_xlate
local is_set, in_array, substitute, error_comment, set_error, select_one, -- functions in Module:Citation/CS1/Utilities
add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;
local z ={}; -- tables in Module:Citation/CS1/Utilities
local extract_ids, extract_id_access_levels, build_id_list, is_embargoed; -- functions in Module:Citation/CS1/Identifiers
local make_coins_title, get_coins_pages, COinS; -- functions in Module:Citation/CS1/COinS
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
--[[--------------------------< P A G E S C O P E V A R I A B L E S >--------------------------------------
delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here
]]
local added_deprecated_cat; -- boolean flag so that the category is added only once
local added_prop_cats = {}; -- list of property categories that have been added to z.properties_cats
local added_vanc_errs; -- boolean flag so we only emit one Vancouver error / category
local Frame; -- holds the module's frame table
--[[--------------------------< F I R S T _ S E T >------------------------------------------------------------
Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated. Returns nil if none are set.
This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs. With the pairs
version the order of evaluation could not be guaranteed. With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.
]]
local function first_set (list, count)
local i = 1;
while i <= count do -- loop through all items in list
if is_set( list[i] ) then
return list[i]; -- return the first set list member
end
i = i + 1; -- point to next
end
end
--[[--------------------------< A D D _ P R O P _ C A T >--------------------------------------------------------
Adds a category to z.properties_cats using names from the configuration file with additional text if any.
foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.
added_prop_cats is a table declared in page scope variables above
]]
local function add_prop_cat (key, arguments)
if not added_prop_cats [key] then
added_prop_cats [key] = true; -- note that we've added this category
key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1'); -- strip lang code from keyname
table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments)); -- make name then add to table
end
end
--[[--------------------------< A D D _ V A N C _ E R R O R >----------------------------------------------------
Module:নথি/রূপরেখা
Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.
added_vanc_errs is a boolean declared in page scope variables above
]]
local function add_vanc_error (source)
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', {source}, true ) } );
end
end
--[[--------------------------< I S _ S C H E M E >------------------------------------------------------------
does this thing that purports to be a uri scheme seem to be a valid scheme? The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
Scheme names consist of a sequence of characters beginning with a
letter and followed by any combination of letters, digits, plus
("+"), period ("."), or hyphen ("-").
returns true if it does, else false
]]
local function is_scheme (scheme)
return scheme and scheme:match ('^%a[%a%d%+%.%-]*:'); -- true if scheme is set and matches the pattern
end
--[=[-------------------------< I S _ D O M A I N _ N A M E >--------------------------------------------------
Does this thing that purports to be a domain name seem to be a valid domain name?
Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db
rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit. Between
the first and last characters the name may use letters, digits, and the hyphen.
Also allowed are IPv4 addresses. IPv6 not supported
domain is expected to be stripped of any path so that the last character in the last character of the tld. tld
is two or more alpha characters. Any preceding '//' (from splitting a url with a scheme) will be stripped
here. Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.
There are several tests:
the first character of the whole domain name including subdomains must be a letter or a digit
internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
single-letter/digit second-level domains in the .org and .cash TLDs
q, x, and z SL domains in the .com TLD
i and q SL domains in the .net TLD
single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
two-character SL domains in gTLDs (where the gTLD is two or more letters)
three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
IPv4 dot-decimal address format; TLD not allowed
returns true if domain appears to be a proper name and tld or IPv4 address, else false
]=]
local function is_domain_name (domain)
if not domain then
return false; -- if not set, abandon
end
domain = domain:gsub ('^//', ''); -- strip '//' from domain name if present; done here so we only have to do it once
if not domain:match ('^[%a%d]') then -- first character must be letter or digit
return false;
end
-- Do most common case first
if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then -- three or more character hostname.hostname or hostname.tld
return true;
elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then -- internationalized domain name with ACE prefix
return true;
elseif domain:match ('%f[%a%d][%a%d]%.cash$') then -- one character/digit .cash hostname
return true;
elseif domain:match ('%f[%a%d][%a%d]%.org$') then -- one character/digit .org hostname
return true;
elseif domain:match ('%f[%a][qxz]%.com$') then -- assigned one character .com hostname (x.com times out 2015-12-10)
return true;
elseif domain:match ('%f[%a][iq]%.net$') then -- assigned one character .net hostname (q.net registered but not active 2015-12-10)
return true;
elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then -- one character hostname and cctld (2 chars)
return true;
elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then -- two character hostname and tld
return true;
elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then -- IPv4 address
return true;
else
return false;
end
end