Modul:Vyhledávací šablony: Porovnání verzí
Skočit na navigaci
Skočit na vyhledávání
Smazaný obsah Přidaný obsah
Bez shrnutí editace |
google books search : přidán parametr pro zabránění náhrady za podle googla běžnější podobný tvar |
||
Řádek 125: | Řádek 125: | ||
end |
end |
||
out = "Google Books. Vyhledávání " .. expressions .. " [https://www.google.com/search?tbm=bks&q=" .. search .. "&lr=lang_" .. languageCode .. " " .. searchTerms .. "] pro " .. langCzechLabelAccusative .. "." |
out = "Google Books. Vyhledávání " .. expressions .. " [https://www.google.com/search?tbm=bks&nfpr=1&q=" .. search .. "&lr=lang_" .. languageCode .. " " .. searchTerms .. "] pro " .. langCzechLabelAccusative .. "." |
||
return out |
return out |
Verze z 24. 7. 2024, 11:29
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, out
if frame:getParent().args[1] and frame:getParent().args[1] ~= "" then
languageCode = frame:getParent().args[1]
else
return "Wikizdroje: První parametr s kódem jazyka je povinný."
end
if frame:getParent().args[2] and frame:getParent().args[2] ~= "" then
pageName = frame:getParent().args[2]
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[n]
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
out = "Wikizdroje. Vyhledávání " .. expressions .. " [https://" .. languageCode .. ".wikisource.org/w/index.php?search=" .. search .. "&title=Special:Search&profile=advanced&fulltext=1&ns0=1 " .. searchTerms .. "]."
return out
end
local langCodeToCzechLabel = {}
langCodeToCzechLabel["cs"] = "češtinu"
langCodeToCzechLabel["da"] = "dánštinu"
langCodeToCzechLabel["de"] = "němčinu"
langCodeToCzechLabel["en"] = "angličtinu"
langCodeToCzechLabel["pl"] = "polštinu"
langCodeToCzechLabel["sk"] = "slovenš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, out
if frame:getParent().args[1] and frame:getParent().args[1] ~= "" then
languageCode = frame:getParent().args[1]
else
return "Google Books: První parametr s kódem jazyka je povinný."
end
if frame:getParent().args[2] and frame:getParent().args[2] ~= "" then
pageName = frame:getParent().args[2]
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[n]
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[languageCode]
if langCzechLabelAccusative == nil then
langCzechLabelAccusative = "jazyk s kódem " .. languageCode
end
out = "Google Books. Vyhledávání " .. expressions .. " [https://www.google.com/search?tbm=bks&nfpr=1&q=" .. search .. "&lr=lang_" .. languageCode .. " " .. searchTerms .. "] pro " .. langCzechLabelAccusative .. "."
return out
end
return p