Jump to content

Module:LogEntry

From glossaLAB

Documentation for this module may be created at Module:LogEntry/doc

local p = {}

function p.render(frame)
    local args = frame:getParent().args
    
    -- Parameters
    local date = args.date or os.date("%Y-%m-%d")
    local title = args.title or "Operational Update"
    local status = (args.status or "In Progress"):upper()
    local tags = args.tags or "General"
    
    -- Asterisk Fix: Prepend a newline to content so MediaWiki parses bullets correctly
    local content = "\n" .. (args.content or "")
    
    -- Status Color Mapping (Using Codex Variables)
    -- Fallbacks are provided for older skins or browsers
    local statusColors = {
        ["COMPLETED"] = "var(--color-success, #00af89)", 
        ["SUCCESS"]   = "var(--color-success, #00af89)",
        ["CRITICAL"]  = "var(--color-destructive, #d33)",
        ["BUG"]       = "var(--color-destructive, #d33)",
        ["RESEARCH"]  = "var(--color-progressive, #36c)",
        ["IN PROGRESS"] = "var(--color-notice, #edab00)" 
    }
    local accentColor = statusColors[status] or "var(--color-base, #202122)"

    -- Build the HTML Output
    local container = mw.html.create('div')
        :css('font-family', '"Courier New", Courier, monospace')
        -- Use interactive/subtle backgrounds for better theme integration
        :css('background-color', 'var(--background-color-neutral, #f8f9fa)')
        :css('color', 'var(--color-base, #202122)')
        :css('border-left', '5px solid ' .. accentColor)
        :css('padding', '15px')
        :css('margin', '15px 0')
        :css('border-radius', '0 8px 8px 0')
        :css('box-shadow: 1px 2px 2px 1px color-mix(in srgb, var(--box-shadow-color-base) 40%, transparent)');

    -- Header (Date & Status)
    local header = container:tag('div')
        :css('font-size', '0.85em')
        :css('border-bottom', '1px solid var(--border-color-subtle, #c8ccd1)')
        :css('margin-bottom', '10px')
        :css('padding-bottom', '5px')
        :css('display', 'flex')
        :css('justify-content', 'space-between')

    header:tag('span'):wikitext("📅 STARDATE: " .. date)
    header:tag('span')
        :css('color', accentColor)
        :css('font-weight', 'bold')
        :wikitext("[" .. status .. "]")

    -- Title
    container:tag('div')
        :css('font-size', '1.2em')
        :css('font-weight', 'bold')
        -- Headings look better with slightly higher contrast
        :css('color', 'var(--color-emphasized, #000)')
        :css('margin-bottom', '10px')
        :wikitext(title)

    -- Body Content
    container:tag('div')
        :css('line-height', '1.5')
        :wikitext(content)

    -- Footer (Tags)
    container:tag('div')
        :css('margin-top', '15px')
        :css('font-size', '0.8em')
        :css('color', 'var(--color-subtle, #54595d)')
        :wikitext("🏷️ TAGS: " .. tags)

    -- Semantic MediaWiki Integration
    if mw.smw then
        mw.smw.set({
            ["Has log date"] = date,
            ["Has log status"] = status,
            ["Has log tag"] = tags,
            ["Is log entry"] = title
        })
    end

    return tostring(container)
end

return p
This website only uses its own cookies for technical purposes; it does not collect or transfer users' personal data without their knowledge. However, it contains links to third-party websites with third-party privacy policies, which you can accept or reject when you access them.