Module:CRTModel: Difference between revisions

No edit summary
No edit summary
Line 194: Line 194:
end
end


        -- Documents section
-- Documents section
addSectionRow(container, 'Documents')
addSectionRow(container, 'Documents')
Line 253: Line 253:
-- Strip any remaining HTML tags and get just the text
-- Strip any remaining HTML tags and get just the text
local cleanContent = cellContent:gsub('<[^>]+>', '')
local cleanContent = cellContent:gsub('<[^>]+>', '')
table.insert(cells, trim(cleanContent))
table.insert(cells, cleanContent)
end
end
-- cells[1] = page name, cells[2] = type, cells[3] = URL, cells[4] = file, cells[5] = title
-- cells[1] = page name, cells[2] = type, cells[3] = URL, cells[4] = file, cells[5] = title
if #cells >= 5 then
if #cells >= 2 then
local docType = cells[2]
local docType = trim(cells[2])
local docUrl = cells[3]
local docUrl = trim(cells[3])
local docFile = cells[4]
local docFile = trim(cells[4])
local docTitle = cells[5]
local docTitle = trim(cells[5])
-- Determine what to link to (URL or file)
-- Determine what to link to (URL or file)
local linkTarget = nil
local linkTarget = nil
if docUrl and docUrl ~= '' then
if docUrl then
linkTarget = docUrl
linkTarget = docUrl
elseif docFile and docFile ~= '' then
elseif docFile then
-- Extract filename from "File:..." format
-- Extract filename from "File:..." format if present
local filename = docFile:match('File:(.+)') or docFile
local filename = docFile:match('File:(.+)') or docFile
linkTarget = mw.uri.fullUrl('File:' .. filename)
linkTarget = mw.uri.fullUrl('File:' .. filename)
Line 276: Line 276:
-- Determine display text priority: custom title > type
-- Determine display text priority: custom title > type
local displayText = 'Document'
local displayText = 'Document'
if docTitle and docTitle ~= '' then
if docTitle then
displayText = docTitle
displayText = docTitle
elseif docType and docType ~= '' then
elseif docType then
displayText = docType
displayText = docType
end
end
MediaWiki Appliance - Powered by TurnKey Linux