From WikiChip
Difference between revisions of "Module:chip"

Line 27: Line 27:
 
         :tag('tr')
 
         :tag('tr')
 
           :tag('td')
 
           :tag('td')
           :attr('style', 'font-weight: bold; font-size 1.2em; font-color: red;')
+
           :attr('style', 'font-weight: bold; font-size 2.5em; color: red;')
 
           :wikitext('ERROR: MISSING TITLE!')
 
           :wikitext('ERROR: MISSING TITLE!')
 
     end
 
     end
Line 34: Line 34:
 
     if frame.args.image then
 
     if frame.args.image then
 
       local image = p.add_file_prefix(frame.args.image)
 
       local image = p.add_file_prefix(frame.args.image)
 +
      local image_size = frame.args.image_size or "150px"
 
       infobox
 
       infobox
 
         :tag('tr')
 
         :tag('tr')
Line 39: Line 40:
 
             :attr('class', 'chip-infobox-pic')
 
             :attr('class', 'chip-infobox-pic')
 
             :attr('colspan', '2')
 
             :attr('colspan', '2')
             :wikitext('[[image::' .. image .. '| ]][[' .. image .. ']]')
+
             :wikitext('[[image::' .. image .. '| ]][[' .. image .. '|' .. image_size .. ']]')
 
     end
 
     end
  

Revision as of 16:39, 3 January 2017

To add this template, simple add
{{chip}}
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 = {}

function p.add_file_prefix(str)
  if string.match(string.lower(str), '^file:') then
    return str
  else
    return 'File:' .. str
  end
end

function p.chip(frame)
    local infobox = mw.html.create('table')

    infobox
        :attr('class', 'chip-infobox')

    -- header
    if frame.args.title then
      infobox
        :tag('tr')
          :tag('td')
            :attr('class', 'chip-infobox-header')
            :attr('colspan', '2')
            :wikitext('[[name::' .. frame.args.title .. ']]')
    else
      infobox
        :tag('tr')
          :tag('td')
          :attr('style', 'font-weight: bold; font-size 2.5em; color: red;')
          :wikitext('ERROR: MISSING TITLE!')
    end

    -- image
    if frame.args.image then
      local image = p.add_file_prefix(frame.args.image)
      local image_size = frame.args.image_size or "150px" 
      infobox
        :tag('tr')
          :tag('td')
            :attr('class', 'chip-infobox-pic')
            :attr('colspan', '2')
            :wikitext('[[image::' .. image .. '| ]][[' .. image .. '|' .. image_size .. ']]')
    end

    return infobox
end

return p