Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:Vyhledávací šablony
p = {}
function p.Wikisource(frame)
-- Handle Wikisource.
-- Search each argument in quotes, regardless whether it is passed with quotes.
-- The language has to be passed as 1st param.
local languageCode, pageName, search, searchTerms, expressions, url, out
if frame:getParent().args and frame:getParent().args ~= "" then
languageCode = frame:getParent().args
else
return "Wikizdroje: První parametr s kódem jazyka je povinný."
end
if frame:getParent().args and frame:getParent().args ~= "" then
pageName = frame:getParent().args
else
local title = mw.title.getCurrentTitle()
pageName = title.text
end
local numOfArgs = 0
for p in pairs(frame:getParent().args) do
numOfArgs = numOfArgs + 1
end
search = ""
searchTerms = ""
if numOfArgs > 2 then
n = 2
while n <= numOfArgs do
if n > 2 then
search = search .. "+OR+"
searchTerms = searchTerms .. ", "
end
argN = frame:getParent().args
argNQuoteless = mw.ustring.gsub(argN, "\"", "")
argNQuoted = "\"" .. argNQuoteless .. "\""
search = search .. mw.uri.encode(argNQuoted, "QUERY" )
searchTerms = searchTerms .. argNQuoted
n = n + 1
end
else
impliedArg = pageName
impliedArgQuoteless = mw.ustring.gsub(impliedArg, "\"", "")
impliedArgQuoted = "\"" .. impliedArgQuoteless .. "\""
search = mw.uri.encode(impliedArgQuoted, "QUERY")
searchTerms = impliedArgQuoted
end
if numOfArgs > 2 then
expressions = "výrazů"
else
expressions = "výrazu"
end
url = "https://" .. languageCode .. ".wikisource.orghttps://cs.wiktionary.org/w/index.php?search=" .. search .. "&title=Special:Search&profile=advanced&fulltext=1&ns0=1"
out = "Wikizdroje. Vyhledávání " .. expressions .. " ."
return out
end
local langCodeToCzechLabel = {}
langCodeToCzechLabel = "češtinu"
langCodeToCzechLabel = "dánštinu"
langCodeToCzechLabel = "němčinu"
langCodeToCzechLabel = "angličtinu"
langCodeToCzechLabel = "polštinu"
langCodeToCzechLabel = "slovenštinu"
langCodeToCzechLabel = "ruštinu"
langCodeToCzechLabel = "švédštinu"
langCodeToCzechLabel = "arabštinu"
langCodeToCzechLabel = "francouzštinu"
langCodeToCzechLabel = "hebrejštinu"
function p.GBK(frame)
-- Handle Google Books.
-- Search each argument in quotes, regardless whether it is passed with quotes.
-- The language has to be passed as 1st param.
local languageCode, pageName, search, searchTerms, expressions, url, out
if frame:getParent().args and frame:getParent().args ~= "" then
languageCode = frame:getParent().args
else
return "Google Books: První parametr s kódem jazyka je povinný."
end
if frame:getParent().args and frame:getParent().args ~= "" then
pageName = frame:getParent().args
else
local title = mw.title.getCurrentTitle()
pageName = title.text
end
local numOfArgs = 0
for p in pairs(frame:getParent().args) do
numOfArgs = numOfArgs + 1
end
search = ""
searchTerms = ""
if numOfArgs > 2 then
n = 2
while n <= numOfArgs do
if n > 2 then
search = search .. "+OR+"
searchTerms = searchTerms .. ", "
end
argN = frame:getParent().args
argNQuoteless = mw.ustring.gsub(argN, "\"", "")
argNQuoted = "\"" .. argNQuoteless .. "\""
search = search .. mw.uri.encode(argNQuoted, "QUERY" )
searchTerms = searchTerms .. argNQuoted
n = n + 1
end
else
impliedArg = pageName
impliedArgQuoteless = mw.ustring.gsub(impliedArg, "\"", "")
impliedArgQuoted = "\"" .. impliedArgQuoteless .. "\""
search = mw.uri.encode(impliedArgQuoted, "QUERY")
searchTerms = impliedArgQuoted
end
if numOfArgs > 2 then
expressions = "výrazů"
else
expressions = "výrazu"
end
langCzechLabelAccusative = langCodeToCzechLabel
if langCzechLabelAccusative == nil then
langCzechLabelAccusative = "jazyk s kódem " .. languageCode
end
url = "https://www.google.com/search?tbm=bks&nfpr=1&q=" .. search .. "&lr=lang_" .. languageCode
out = "Google Books. Vyhledávání " .. expressions .. " pro " .. langCzechLabelAccusative .. "."
return out
end
return p