Module:Search/sandbox: Difference between revisions

Content deleted Content added
why is long like this
remove that bit about a middle
 
(4 intermediate revisions by the same user not shown)
Line 1:
-- This module implements {{search}}
local p = {}
 
local ll = ''
 
local function urlencode(text)
Line 12 ⟶ 10:
end
 
local function addlinkmake_link(url, unabbreviatedexpansion, abbreviationdisplay_text, after)
return mw.ustring.format(
return '[' .. url .. ' <abbr title="' .. unabbreviated .. '">' .. abbreviation ..'</abbr>]'
'[%s <abbr title="%s">%s</abbr>]%s',
url,
expansion,
display_text,
after or ''
)
end
 
Line 20 ⟶ 24:
wrappers = 'Template:Search'
})
 
local ss = args[1] or 'example phrase'
local ssencsearch_phrase_encoded = urlencode(ssargs[1] or 'example phrase')
local short_module_args = {
local long = (args.long or '') ~= ''
:addClass(class = 'template-search-sand plainlinks'),
addlinkmake_link('//en.wikipedia.org/w/index.php?title=Special:Search&search=' .. ssencsearch_phrase_encoded, 'Wikipedia', 'wp'),
local ret = mw.html.create('div')
addlinkmake_link('https://www.binggoogle.com/search?q=' .. ssencsearch_phrase_encoded, 'BingGoogle', 'bg'),
:addClass('template-search')
make_link('https://www.bing.com/search?q=' .. search_phrase_encoded, 'Bing', 'b'),
:addClass('plainlinks')
local list1 = {
addlink('//en.wikipedia.org/w/index.php?title=Special:Search&search=' .. ssenc, 'Wikipedia', 'wp')
}
local list1long_module_args = {
class = 'template-search-sand plainlinks',
if long then
make_link('//en.wikipedia.org/w/index.php?title=Special:Search&search=' .. search_phrase_encoded, 'Wikipedia', 'wp'),
table.insert(list1, addlinkmake_link('https://www.google.com/search?q=site%3Awikipedia.org+' .. ssencsearch_phrase_encoded, 'Wikipedia over Google', 'gwp')),
end
table.insert(list1, addlink make_link('https://www.google.com/search?q=' .. ssencsearch_phrase_encoded, 'Google', 'g')),
make_link('https://www.bing.com/search?q=site%3Awikipedia.org+' .. search_phrase_encoded, 'Wikipedia over Bing', 'bwp'),
if long then
table.insert(list1, addlinkmake_link('https://www.bing.com/search?q=site%3Awikipedia.org+' .. ssencsearch_phrase_encoded, 'Wikipedia over Bing', 'bwpb', ' |')),
table.insert(list1, addlinkmake_link('https://www.bingbritannica.com/search?qnop&query=' .. ssencsearch_phrase_encoded, 'BingEncyclopaedia Britannica', 'beb')),
make_link('https://www.bartleby.com/cgi-bin/texis/webinator/65search?query=' .. search_phrase_encoded, 'Columbia Encyclopedia', 'co'),
end
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'),
local list2 = long and {
addlinkmake_link('https://wwwscienceworld.britannicawolfram.com/search/index.cgi?nop&queryas_q=' .. ssencsearch_phrase_encoded, 'EncyclopaediaWorld of BritannicaScience', 'ebsw'),
addlinkmake_link('https://wwwarchive.bartlebyorg/search.com/cgi-bin/texis/webinator/65searchphp?query=' .. ssencsearch_phrase_encoded, 'ColumbiaInternet EncyclopediaArchive', 'coarc'),
addlinkmake_link('https://babel.hathitrust.org/cgi/ls?field1=ocr;q1=' .. ssencsearch_phrase_encoded .. ';a=srchls;lmt=ft', 'HathiTrust', 'ht'),
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('https://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')
} or {
addlink('https://www.bing.com/search?q=' .. ssenc, 'Bing', 'b')
}
local make_listlong = require(args.long or 'Module:List').makeList ~= ''
local ubl = require('Module:List').unbulleted
ret:wikitext('(')
local list = ubl(long and long_module_args or short_module_args)
:wikitext(make_list('unbulleted', list1))
if long then ret:wikitext(' | ') end
ret:wikitext(make_list('unbulleted', list2))
:wikitext(')')
return frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Search/sandbox/styles.css' }
} .. tostring'(ret' .. list .. ')'
end