From WikiChip
Module:gpu
To add this template, simple add
{{gpu}}to the page and save. The chip infobox will have a small
[Edit Values]
button at the top-right corner which can be used to add values using a form.
local p = {}
local origArgs
function p.add_file_prefix(str)
if string.match(string.lower(str), '^file:') then
return str
else
return 'File:' .. str
end
end
function p.add_separator(box, title)
box:tag('tr')
:tag('td')
:attr('class', 'header')
:attr('colspan', '2')
:wikitext(title)
end
function p.add_entry(value, right)
local e = mw.html.create('tr')
e:tag('td')
:attr('class', 'label')
:wikitext(value)
e:node(right)
return e
end
function has_arg(name)
-- The argument can exist and be empty or not exist at all
return string.len(origArgs[name] or '') > 0
end
function arg(name)
return origArgs[name]
end
function p.chip(frame)
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
else
origArgs = frame.args
end
local infobox = mw.html.create('table')
infobox
:attr('class', 'infobox')
infobox
:tag('tr')
:tag('td'):attr('colspan', '2')
:tag('small'):attr('style', 'float: right;')
:wikitext('[[Special:FormEdit/gpu/' .. frame:preprocess('{{FULLPAGENAME}}') .. '|<i class="fa fa-edit"></i>Edit Values]]')
-- header
if has_arg('name') then
infobox
:tag('tr')
:tag('td')
:attr('class', 'header-main')
:attr('colspan', '2')
:wikitext('[[name::' .. arg('name') .. ']]')
end
-- some general info first
p.add_separator(infobox, 'General Info')
-- type
if has_arg('type') then
if arg('type') == 'integrated' then
infobox:node(p.add_entry('Type', mw.html.create('td'):wikitext('[[instance of::integrated graphics processor| ]] IGP')))
infobox:wikitext('[[Category:integrated graphics processor models]]')
end
if arg('type') == 'discrete' then
infobox:node(p.add_entry('Type', mw.html.create('td'):wikitext('[[instance of::discrete graphics processor| ]] DGP')))
infobox:wikitext('[[Category:discrete graphics processor models]]')
end
end
-- designer
if has_arg('designer') then
local designers = mw.html.create('td'):attr('style', 'width: 99%;')
designers:wikitext('[[designer::' .. arg('designer') .. '| ]][[' .. arg('designer') .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
if has_arg('microarch') then
designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer')) ..
' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
end
for i = 2, 10 do
if not has_arg('designer ' .. i) then break end
designers:wikitext(', [[designer::' .. arg('designer ' .. i) .. '| ]][[' .. arg('designer ' .. i) .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
if has_arg('microarch') then
designers:wikitext('[[category:microprocessor models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
end
end
infobox:node(p.add_entry('Designer', designers))
end
-- manufacturer
if has_arg('manufacturer') then
local manufacturers = '[[manufacturer::' .. arg('manufacturer') .. '| ]][[' .. arg('manufacturer') .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('manufacturer')) .. ']]'
for i = 2, 10 do
if not has_arg('manufacturer ' .. i) then break end
manufacturers = manufacturers .. ', [[manufacturer::' .. arg('manufacturer ' .. i) .. '| ]][[' .. arg('manufacturer ' .. i) .. ']]' ..
'[[category:microprocessor models by ' .. mw.ustring.lower(arg('manufacturer ' .. i)) .. ']]'
end
infobox:node(p.add_entry('Manufacturer', mw.html.create('td'):wikitext(manufacturers)))
end
infobox:wikitext('[[full page name::' .. frame:preprocess('{{FULLPAGENAME}}') .. '| ]]')
if has_arg('future') and
(string.lower(arg('future')) == 'yes' or string.lower(arg('future')) == 'true') then
infobox:wikitext('[[Category:future microprocessor models]][[ldate::3000| ]]')
elseif has_arg('first launched') then
infobox:wikitext('[[ldate::' .. arg('first launched') .. '| ]]')
elseif has_arg('first announced') then
infobox:wikitext('[[ldate::' .. arg('first announced') .. '| ]]')
else --alright launched but no date?
infobox:wikitext('[[ldate::1000| ]]')
end
return infobox
end
return p