Jump to content

Module:TestModule: Difference between revisions

From NewsWikiTestbed
AdamZachar (talk | contribs)
No edit summary
AdamZachar (talk | contribs)
No edit summary
Line 3: Line 3:
function p.hello( frame )
function p.hello( frame )
  return "Hello, world!"
  return "Hello, world!"
  -- if row.shape == targetShape then
  -- output = output .. " <li>" .. "[[" .. row.shape .. "]]"
  -- end
end
end


function p.externalDataTest( frame )
function p.externalDataTest( frame )
  local output = ""
  local output = ""
  local targetShape = frame.args.targetShape
  local parentCase = frame.args.parentCase
  local data, errors =
  local topics, errors =
   mw.ext.externaldata.getWebData
   mw.ext.externaldata.getDbData
   {
   {
   url = 'https://discoursedb.org/wiki/Special:GetData/Fruits_data',
   source = CaseData,
   data = {name = 'Name',  color = 'Color', shape = 'Shape'},
  query = childrenTopics,
   format = 'CSV with header'
   data = {topicName = topic_name},
   parameters = parentCase
   }
   }


  output = output .. "<ul>"
  output = output .. "<ul>"
  for i, row in ipairs(data) do
  for i, topic in ipairs(topics) do
  output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
end


  if row.shape == targetShape then
  output = output .. " <li>" .. "'''[[" .. row.shape .. "]]'''"
  else
  output = output .. " <li>" .. "[[" .. row.shape .. "]]"
  end
end
  output = output .. "</ul>"
  output = output .. "</ul>"



Revision as of 10:59, 10 June 2025


local p = {} --p stands for package

function p.hello( frame )
 return "Hello, world!"

  -- if row.shape == targetShape then
   -- output = output .. " <li>" .. "[[" .. row.shape .. "]]"
  -- end

end

function p.externalDataTest( frame )
 local output = ""
 local parentCase = frame.args.parentCase
 local topics, errors =
  mw.ext.externaldata.getDbData
  {
   source = CaseData,
   query = childrenTopics,
   data = {topicName = topic_name},
   parameters = parentCase
  }

 output = output .. "<ul>"
 for i, topic in ipairs(topics) do
  output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
 end

 output = output .. "</ul>"

 return output
end

return p