Module:Search: Difference between revisions

Content deleted Content added
nop
 
(5 intermediate revisions by 2 users not shown)
Line 1:
-- This module implements {{search}}
local p = {}
 
local ll = ''
 
local function urlencode(text)
Line 12 ⟶ 9:
end
 
local function addlinkmake_link(purl, uexpansion, adisplay_text, t, safter)
return mw.ustring.format(
local item = ll:tag('li'):css('display', 'inline')
'[%s <abbr title="%s">%s</abbr>]%s',
item:wikitext(p .. '[' .. u .. ' ')
url,
item:tag('abbr')
expansion,
:attr('title', a)
display_text,
:css('border-bottom', 'none')
after or ''
:css('text-decoration', 'none')
)
:css('cursor', 'inherit')
:wikitext(t)
item:wikitext(']' .. s)
end
 
Line 28 ⟶ 23:
wrappers = 'Template:Search'
})
 
local ss = args[1] or 'example phrase'
local ssencsearch_phrase_encoded = urlencode(ssargs[1] or 'example phrase')
local short_module_args = {
class = 'template-search plainlinks',
addlink make_link('(', 'https://en.wikipedia.org/w/index.php?title=Special:Search&search=' .. ssencsearch_phrase_encoded, 'Wikipedia', 'wp'), ' ')
addlink make_link('', 'https://www.google.com/search?q=' .. ssencsearch_phrase_encoded, 'Google', 'g'), ' ')
addlinkmake_link('', 'https://www.bing.com/search?q=' .. ssencsearch_phrase_encoded, 'Bing', 'b'), ')')
}
local long_module_args = {
class = 'template-search plainlinks',
make_link('https://en.wikipedia.org/w/index.php?title=Special:Search&search=' .. search_phrase_encoded, 'Wikipedia', 'wp'),
addlinkmake_link('', 'https://www.google.com/search?q=site%3Awikipedia.org+' .. ssencsearch_phrase_encoded, 'Wikipedia over Google', 'gwp'), ' ')
addlinkmake_link('', 'https://www.binggoogle.com/search?q=' .. ssencsearch_phrase_encoded, 'BingGoogle', 'bg'), ' | ')
addlinkmake_link('', 'https://www.bing.com/search?q=site%3Awikipedia.org+' .. ssencsearch_phrase_encoded, 'Wikipedia over Bing', 'bwp'), ' ')
make_link('https://www.bing.com/search?q=' .. search_phrase_encoded, 'Bing', 'b', ' |'),
addlinkmake_link('', 'https://www.britannica.com/search?nop&query=' .. ssencsearch_phrase_encoded, 'Encyclopaedia Britannica', 'eb'), ' ')
addlinkmake_link('', 'httphttps://www.bartleby.com/cgi-bin/texis/webinator/65search?query=' .. ssencsearch_phrase_encoded, 'Columbia Encyclopedia', 'co'), ' ')
addlinkmake_link('', 'https://www.google.com/search?q=site%3Ahttp%3A%2F%2Fwww.pcmag.com%2Fencyclopedia_term%2F+' .. ssencsearch_phrase_encoded, 'PC Magazine Encyclopedia over Google', 'gct'), ' ')
addlinkmake_link('', 'httphttps://scienceworld.wolfram.com/search/index.cgi?as_q=' .. ssencsearch_phrase_encoded, 'World of Science', 'sw'), ' ')
addlinkmake_link('', 'https://archive.org/search.php?query=' .. ssencsearch_phrase_encoded, 'Internet Archive', 'arc'), ' ')
addlinkmake_link('', 'https://babel.hathitrust.org/cgi/ls?field1=ocr;q1=' .. ssencsearch_phrase_encoded .. ';a=srchls;lmt=ft', 'HathiTrust', 'ht'), ')')
}
local long = (args.long or '') ~= ''
local ubl = require('Module:List').unbulleted
local list = ubl(long and long_module_args or short_module_args)
local ret = mw.html.create('div')
return frame:extensionTag{
:addClass('plainlist')
name = 'templatestyles', args = { src = 'Module:Search/styles.css' }
:addClass('plainlinks')
item:wikitext(p} .. '[(' .. ulist .. ' )')
:css('display', 'inline')
ll = ret:tag('ul'):css('display', 'inline')
addlink('(', '//en.wikipedia.org/w/index.php?title=Special:Search&search=' .. ssenc, 'Wikipedia', 'wp', ' ')
if long then
addlink('', 'https://www.google.com/search?q=site%3Awikipedia.org+' .. ssenc, 'Wikipedia over Google', 'gwp', ' ')
end
addlink('', 'https://www.google.com/search?q=' .. ssenc, 'Google', 'g', ' ')
if long then
addlink('', 'https://www.bing.com/search?q=site%3Awikipedia.org+' .. ssenc, 'Wikipedia over Bing', 'bwp', ' ')
addlink('', 'https://www.bing.com/search?q=' .. ssenc, 'Bing', 'b', ' | ')
addlink('', 'https://www.britannica.com/search?nop&query=' .. ssenc, 'Encyclopaedia Britannica', 'eb', ' ')
addlink('', 'http://www.bartleby.com/cgi-bin/texis/webinator/65search?query=' .. ssenc, 'Columbia Encyclopedia', 'co', ' ')
addlink('', 'https://www.google.com/search?q=site%3Ahttp%3A%2F%2Fwww.pcmag.com%2Fencyclopedia_term%2F+' .. ssenc, 'PC Magazine Encyclopedia over Google', 'gct', ' ')
addlink('', 'http://scienceworld.wolfram.com/search/index.cgi?as_q=' .. ssenc, 'World of Science', 'sw', ' ')
addlink('', 'https://archive.org/search.php?query=' .. ssenc, 'Internet Archive', 'arc', ' ')
addlink('', 'https://babel.hathitrust.org/cgi/ls?field1=ocr;q1=' .. ssenc .. ';a=srchls;lmt=ft', 'HathiTrust', 'ht', ')')
else
addlink('', 'https://www.bing.com/search?q=' .. ssenc, 'Bing', 'b', ')')
end
return ret
end