Module:CRTModel: Difference between revisions
No edit summary |
No edit summary |
||
| Line 194: | Line 194: | ||
end | end | ||
-- Documents section | -- Documents section | ||
-- | addSectionRow(tbl, 'Documents') | ||
local | |||
-- Query for documents | |||
local documentsQueryWikitext = | |||
'{{#ask:\n' .. | '{{#ask:\n' .. | ||
' [[Category:Documents]]\n' .. | ' [[Category:Documents]]\n' .. | ||
' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ||
' | | ' |?Has document type\n' .. | ||
' |?Has document URL\n' .. | |||
' |mainlabel=-\n' .. | |||
'}}' | '}}' | ||
local | local documentsResult = frame:preprocess(documentsQueryWikitext) | ||
-- Build the upload link | -- Build the upload link | ||
| Line 216: | Line 219: | ||
) | ) | ||
-- | -- Check if we have any documents | ||
local hasDocuments = documentsResult and trim(documentsResult) and not documentsResult:match('^%s*$') | |||
if hasDocuments then | if hasDocuments then | ||
-- | -- Parse the results and build HTML list manually | ||
local | local docLinks = {} | ||
-- The #ask result returns results in a table-like format | |||
-- We need to query each document individually to get clean data | |||
local docListQueryWikitext = | |||
'{{#ask:\n' .. | |||
' [[Category:Documents]]\n' .. | |||
' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | |||
' |?Has document type=Type\n' .. | |||
' |?Has document URL=URL\n' .. | |||
' |format=list\n' .. | |||
'}}' | |||
-- Actually, let's use a simpler approach with custom format | |||
local docBuildWikitext = '' | |||
local askDocsWikitext = | |||
'{{#ask:\n' .. | '{{#ask:\n' .. | ||
' [[Category:Documents]]\n' .. | ' [[Category:Documents]]\n' .. | ||
' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ' [[Has related CRT model::' .. fullPageName .. ']]\n' .. | ||
' |?Has document | ' |?Has document type\n' .. | ||
' |?Has document URL | ' |?Has document URL\n' .. | ||
' |format= | ' |format=template\n' .. | ||
' |template=Document link inline\n' .. | ' |template=Document link inline\n' .. | ||
' |named args=yes\n' .. | ' |named args=yes\n' .. | ||
' | | ' |introtemplate=Document list intro\n' .. | ||
'}}' | '}}' | ||
local docsHtml = frame:preprocess(askDocsWikitext) | |||
local | |||
-- Combine with upload link | -- Combine with upload link | ||
local | local combinedContent = docsHtml .. '<div style="margin-top:0.5em; font-style:italic;">[' .. tostring(uploadUrl) .. ' Upload a document]</div>' | ||
addFullRow(tbl, combinedContent, 'padding:0.2em 0.4em;', true) | |||
addFullRow(tbl, | |||
else | else | ||
-- Just show the upload link | -- Just show the upload link | ||
local | local uploadLinkHtml = '<div style="font-style:italic;">[' .. tostring(uploadUrl) .. ' Upload a document]</div>' | ||
addFullRow(tbl, uploadLinkHtml, 'padding:0.2em 0.4em;', true) | |||
addFullRow(tbl, | |||
end | end | ||