Diferencia entre revisiones de «Módulo:URL»

De Hispanopedia
Sin resumen de edición
Sin resumen de edición
Línea 2: Línea 2:


function z.enlazar(url, texto)
function z.enlazar(url, texto)
if not url then
    if not url then
return
return
end
elseif url:find('%[') then
return url
--Falta escribir
elseif texto then
-- [http://www.wittgen-cam.ac.uk/ Archivo Wittgedstein]
-- url sin nada
if texto then
    return '[' .. url .. ' ' .. texto .. ']'
    return '[' .. url .. ' ' .. texto .. ']'
else
else

Revisión del 11:46 29 mar 2015

Uso

Este módulo proporciona operaciones sobre URL.

Funciones

url

Formatea una url añadiéndole el texto especificado. Sintaxis:

{{#Invoke:URL|url|<url>|<texto>}}
Ejemplos
  • {{#Invoke:URL|url|www.ejemplo.com|Sitio web oficial}} → [www.ejemplo.com www.ejemplo.com]
  • {{#Invoke:URL|url|http://www.ejemplo.coml}}http://www.ejemplo.com
  • {{#Invoke:URL|url|[http://www.ejemplo.com Ejemplo]|Sitio web oficial}}Ejemplo
  • {{#Invoke:URL|url||Sitio web oficial}} → [ ]
Notas

Para llamar a la función desde LUA puede utilizarse en su lugar la función enlazar:

enlazar(<url>, <texto>)

local z = {}

function z.enlazar(url, texto)
    if not url then
		return
	elseif url:find('%[') then
		return url
	elseif texto then
	    return '[' .. url .. ' ' .. texto .. ']'
	else
		return '[' .. url .. ']'
	end
end

function z.url(frame)
	if not frame or not frame.args then
		return
	end
	
	return z.enlazar(frame.args[1], frame.args[1])
end

--function z.enlacePlano
	-- Ver la plantilla Enlace plano
--	return
--end

-- Ver la función checkurl del módulo de citas.
function z.esValida(url)
	return url:sub(1,2) == "//" or url:match( "^[^/]*:" )
end

return z