Diferencia entre revisiones de «Módulo:Citas»

2073 bytes eliminados ,  30 marzo
m
1 revisión importada
m (1 revisión importada)
m (1 revisión importada)
 
(No se muestran 5 ediciones intermedias de 4 usuarios)
Línea 280: Línea 280:
     end
     end
     return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str });
     return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str });
end
--[[--------------------------< H D L >------------------------------------------------------------------------
Formats an HDL with minor error checking.
HDL names contain two parts: prefix and suffix separated by a forward slash.
Prefix: character string using any character in the UCS-2 character set except '/'
Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant
This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.
HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.
Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.
]]
local function hdl (options)
local id = options.id;
local access = options.access;
local handler = options.handler;
local query_params = { -- list of known query parameters from http://www.handle.net/proxy_servlet.html
'noredirect',
'ignore_aliases',
'auth',
'cert',
'index',
'type',
'urlappend',
'locatt',
'action',
}
local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$'); -- look for query string
local found;
if hdl then -- when there are query strings, this is the handle identifier portion
for _, q in ipairs (query_params) do -- spin through the list of query parameters
if param:match ('^' .. q) then -- if the query string begins with one of the parameters
found = true; -- announce a find
break; -- and stop looking
end
end
end
if found then
id = hdl; -- found so replace id with the handle portion; this will be URL-encoded, suffix will not
else
suffix = ''; -- make sure suffix is empty string for concatenation else
end
local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})
if nil == id:match("^[^%s–]-/[^%s–]-[^%.,]$") then -- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
set_message ('err_bad_hdl' );
options.coins_list_t['HDL'] = nil; -- when error, unset so not included in COinS
end
return text;
end
end
--[[--------------------------< N O R M A L I Z E _ L C C N >--------------------------------------------------
--[[--------------------------< N O R M A L I Z E _ L C C N >--------------------------------------------------
Línea 432: Línea 367:
]]
]]
function pmid(id)
function pmid(id)
local test_limit = 36000000; -- update this value as PMIDs approach
local test_limit = 45000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local handler = cfg.id_handlers['PMID'];
local err_cat =  ''; -- presume that PMID is valid
local err_cat =  ''; -- presume that PMID is valid
Línea 478: Línea 413:
]]
]]
function pmc(id, embargo)
function pmc(id, embargo)
local test_limit = 10000000; -- update this value as PMCs approach
local test_limit = 12000000; -- update this value as PMCs approach
local handler = cfg.id_handlers['PMC'];
local handler = cfg.id_handlers['PMC'];
local err_cat =  ''; -- presume that PMC is valid
local err_cat =  ''; -- presume that PMC is valid
Línea 484: Línea 419:
local text;
local text;


if id:match("^PMC%d") then
id = id:sub(4, j) -- remove 'PMC' preffix if given
end
if id:match("[^%d]") then -- if PMC has anything but digits
if id:match("[^%d]") then -- if PMC has anything but digits
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
Línea 659: Línea 597:
     while true do
     while true do
pattern = pages:match("%[([%w/:\.]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url "
pattern = pages:match("%[(%w*:?//[^ ]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url "
if nil == pattern then break; end -- no more urls
if nil == pattern then break; end -- no more urls
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
Línea 917: Línea 855:
         elseif k == 'DOI' then
         elseif k == 'DOI' then
             table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
             table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'HDL' then
            table.insert( new_list, {handler.label, hdl( v ) } );
         elseif k == 'LCCN' then
         elseif k == 'LCCN' then
             table.insert( new_list, {handler.label, lccn( v ) } );
             table.insert( new_list, {handler.label, lccn( v ) } );
Línea 1337: Línea 1273:
      
      
     local Quote = A['Quote'];
     local Quote = A['Quote'];
     local PostScript = A['PostScript'];
     local TransQuote = A['TransQuote'];
local PostScript = A['PostScript'];


     local LayURL = A['LayURL'];
     local LayURL = A['LayURL'];
Línea 1898: Línea 1835:
     if is_set(Title) then
     if is_set(Title) then
         if not is_set(TitleLink) and is_set(URL) then  
         if not is_set(TitleLink) and is_set(URL) then  
             Title = externallink( URL, Title ) .. TransError .. Format       
             Title = externallink( URL, Title, URL_origin, UrlAccess ) .. TransError .. Format       
             URL = "";
             URL = "";
             TieneURL = true;
             TieneURL = true;
Línea 2123: Línea 2060:
     if is_set(URL) then
     if is_set(URL) then
         URL = " " .. externallink( URL, nil, URLorigin );
         URL = " " .. externallink( URL, nil, URLorigin, UrlAccess );
     end
     end
      
      
Línea 2137: Línea 2074:
end     
end     


     if is_set(Quote) then
     if is_set(Quote) or is_set(TransQuote) then
     -- Eliminar comillas de Quote
     -- Eliminar comillas de Quote
         if (Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"') or
         if (Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"') or
Línea 2148: Línea 2085:
           Quote:sub(-1,-1) == '!' then
           Quote:sub(-1,-1) == '!' then
           PostScript = ""
           PostScript = ""
         end
          end
         
         -- Eliminar comillas de TransQuote
        if (TransQuote:sub(1, 1) == '"' and TransQuote:sub(-1, -1) == '"') or
          (Quote:sub(1,1) == '«' and Quote:sub(-1,-1) == '»') then
TransQuote = TransQuote:sub(2, -2);
end
          
          
        -- No añadir el punto final a la cita si el campo TransQuote ya incluye un punto
        if TransQuote:sub(-1,-1) == '.' or TransQuote:sub(-1,-1) == '?' or
          TransQuote:sub(-1,-1) == '!' then
          PostScript = ""
          end
if TransQuote and TransQuote ~= '' then
          Quote = Quote .. " " .. wrap( 'trans-quoted-title', TransQuote );
          TransQuote = wrap( 'trans-quoted-title', TransQuote );
end
         Quote = sepc .." " .. wrap( 'quoted-text', Quote );  
         Quote = sepc .." " .. wrap( 'quoted-text', Quote );  
     end
     end
MediaWiki spam blocked by CleanTalk.