Mudanças entre as edições de "Módulo:Changelog"

De Wiki Gla
Ir para navegação Ir para pesquisar
m
m
Linha 41: Linha 41:
   local content = item:tag('div'):addClass('notice-content'):css('flex','1')
   local content = item:tag('div'):addClass('notice-content'):css('flex','1')


   -- Header row: title (left) and date (right)
   -- Header: optional inline icon + title, with date shown to the right in the same row
   if has(title) or has(date) then
   if has(title) or has(date) then
     local header = content:tag('div'):addClass('notice-header')
     local header = content:tag('div'):addClass('notice-header')
    local left = header:tag('div'):addClass('notice-header-left')
     -- inline icon (visible only on small screens) goes first
    local right = header:tag('div'):addClass('notice-header-right')
 
     -- inline icon (visible only on small screens) goes in header-left before text
     if inline_icon_wikitext then
     if inline_icon_wikitext then
       left:wikitext(inline_icon_wikitext)
       header:wikitext(inline_icon_wikitext)
     end
     end
     if has(title) then
     if has(title) then
       local holder = left:tag('span'):addClass('notice-title')
       local holder = header:tag('span'):addClass('notice-title')
       if has(link) then
       if has(link) then
         holder:wikitext('[' .. link .. ' ' .. title .. ']')
         holder:wikitext('[' .. link .. ' ' .. title .. ']')
Linha 60: Linha 56:
       end
       end
     end
     end
     if has(date) then
     if has(date) then
       right:tag('span'):addClass('notice-date'):wikitext(date)
       header:tag('span'):addClass('notice-date'):wikitext(' ' .. date)
     end
     end
   end
   end

Edição das 20h34min de 2 de setembro de 2025

A documentação para este módulo pode ser criada em Módulo:Changelog/doc

local p = {}

local function N(s) return s and mw.text.trim(tostring(s)) or '' end
local function has(s) return N(s) ~= '' end

function p.item(frame)
  local parent = frame:getParent()
  local a = parent and parent.args or frame.args

  local title = N(a.title)
  local link  = N(a.link)
  local date  = N(a.date)
  local desc  = N(a.description)
  local icon  = N(a.icon)
  local color = N(a.color)

  local item = mw.html.create('div'):addClass('notice-item')
  -- layout and visuals are handled by stylesheet in MainPageChangelog.html

  if has(color) then item:css('--notice-color', color) end

  local overlay_icon_wikitext = nil
  local inline_icon_wikitext = nil
  if has(icon) then
    local lowered = string.lower(icon)
    local filename_like = not string.find(lowered, '://', 1, true) and not string.find(icon, 'File:', 1, true) and not string.find(icon, 'Image:', 1, true)
    if filename_like then
      overlay_icon_wikitext = string.format('[[File:%s|alt=%s|class=notice-icon notice-icon--overlay]]', mw.text.trim(icon), mw.text.trim(title))
      inline_icon_wikitext  = string.format('[[File:%s|alt=%s|class=notice-icon notice-icon--inline]]', mw.text.trim(icon), mw.text.trim(title))
    else
      if string.find(lowered, '://', 1, true) then
        overlay_icon_wikitext = string.format('<img src="%s" alt="%s" class="notice-icon notice-icon--overlay" />', mw.text.trim(icon), mw.text.trim(title))
        inline_icon_wikitext  = string.format('<img src="%s" alt="%s" class="notice-icon notice-icon--inline" />', mw.text.trim(icon), mw.text.trim(title))
      else
        overlay_icon_wikitext = string.format('[[%s|alt=%s|class=notice-icon notice-icon--overlay]]', mw.text.trim(icon), mw.text.trim(title))
        inline_icon_wikitext  = string.format('[[%s|alt=%s|class=notice-icon notice-icon--inline]]', mw.text.trim(icon), mw.text.trim(title))
      end
    end
  end

  local content = item:tag('div'):addClass('notice-content'):css('flex','1')

  -- Header: optional inline icon + title, with date shown to the right in the same row
  if has(title) or has(date) then
    local header = content:tag('div'):addClass('notice-header')
    -- inline icon (visible only on small screens) goes first
    if inline_icon_wikitext then
      header:wikitext(inline_icon_wikitext)
    end
    if has(title) then
      local holder = header:tag('span'):addClass('notice-title')
      if has(link) then
        holder:wikitext('[' .. link .. ' ' .. title .. ']')
      else
        holder:wikitext(title)
      end
    end
    if has(date) then
      header:tag('span'):addClass('notice-date'):wikitext(' ' .. date)
    end
  end

  if has(desc) then
    content:tag('p'):addClass('notice-desc')
      :wikitext(desc)
  end

  -- render overlay icon (absolute) so it doesn't alter layout
  if overlay_icon_wikitext then
    item:wikitext(overlay_icon_wikitext)
  end

  return tostring(item)  -- já sai como HTML + wikitexto parseável
end

return p