Module:Search: Difference between revisions

Content deleted Content added
add optional |long= to avoid explosion of Category:Pages where template include size is exceeded
 
(11 intermediate revisions by 6 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',
local ret = mw.html.create('div')
make_link('https://en.wikipedia.org/w/index.php?title=Special:Search&search=' .. search_phrase_encoded, 'Wikipedia', 'wp'),
:addClass('plainlist')
addlinkmake_link('', 'https://www.binggoogle.com/search?q=' .. ssencsearch_phrase_encoded, 'BingGoogle', 'bg'), ')')
:addClass('plainlinks')
make_link('https://www.bing.com/search?q=' .. search_phrase_encoded, 'Bing', 'b'),
:css('display', 'inline')
}
ll = ret:tag('ul'):css('display', 'inline')
local long_module_args = {
class = 'template-search plainlinks',
addlink('(', frame:preprocess('{{fullurl:Special:Search|search=' .. ssenc .. '}}'), 'Wikipedia', 'wp', '')
addlink make_link('', 'https://wwwen.googlewikipedia.comorg/searchw/index.php?qtitle=Special:Search&search=site%3Awikipedia.org+' .. ssencsearch_phrase_encoded, 'Wikipedia over Google', 'gwpwp'), '')
addlink make_link('', 'https://www.google.com/search?q=site%3Awikipedia.org+' .. ssencsearch_phrase_encoded, 'Wikipedia over Google', 'ggwp'), '')
addlink make_link('', 'https://www.binggoogle.com/search?q=site%3Awikipedia.org+' .. ssencsearch_phrase_encoded, 'Wikipedia over BingGoogle', 'bwpg'), '')
make_link('https://www.bing.com/search?q=site%3Awikipedia.org+' .. search_phrase_encoded, 'Wikipedia over Bing', 'bwp'),
if (args.long or '') ~= '' then
addlinkmake_link('', 'https://www.bing.com/search?q=' .. ssencsearch_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'), ')')
}
else
addlink('', 'https://www.bing.com/search?q=' .. ssenc, 'Bing', 'b', ')')
end
local sslong = (args[1].long or 'example') phrase~= ''
return ret
local ubl = require('Module:List').unbulleted
local list = ubl(long and long_module_args or short_module_args)
return frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Search/styles.css' }
item:wikitext(p} .. '[(' .. ulist .. ' )')
end