Jump to content

Module:TestModule: Difference between revisions

From NewsWikiTestbed
AdamZachar (talk | contribs)
No edit summary
AdamZachar (talk | contribs)
No edit summary
Line 43: Line 43:
end
end


function testFunc()
function testFunc(arg1)
  return "test!"
  return "test! " .. arg1 .. " test!"
end
end


Line 51: Line 51:
  --final = funcRecurseLineage({output=frame.args.output, parentTopic=frame.args.parentTopic})
  --final = funcRecurseLineage({output=frame.args.output, parentTopic=frame.args.parentTopic})


  return testFunc()
  return testFunc({arg1="hi"})


end
end

Revision as of 12:30, 10 June 2025


local p = {} --p stands for package

function funcRecurseLineage(output, parentTopic)

 local topics, errors = mw.ext.externaldata.getExternalData {
   source = "CaseData",
   query = "childrenTopics",
   data = "topicName=topic_name",
   parameters = parentTopic
  }

 if topics ~= nil then

  output = output .. "<ul>"

  for i, topic in ipairs(topics) do

   output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"

   local childTopics, errors3 = mw.ext.externaldata.getExternalData {
    source = "CaseData",
    query = "childrenTopics",
    data = "topicName=topic_name",
    parameters = topic.topicName
   }

   if childTopics ~= nil then
    output = output .. "<ul>"
    for i, childTopic in ipairs(childTopics) do
     output = output .. " <li>" .. "[[" .. childTopic.topicName .. "]]"
    end
    output = output .. "</ul>"
   end

  end

  output = output .. "</ul>"

 end

 return output

end

function testFunc(arg1)
 return "test! " .. arg1 .. " test!"
end

function p.recurseLineage( frame )

 --final = funcRecurseLineage({output=frame.args.output, parentTopic=frame.args.parentTopic})

 return testFunc({arg1="hi"})

end

function p.topicLineage( frame )

 local output = ""
 local parentTopic = frame.args.parentTopic

 local topics, errors = mw.ext.externaldata.getExternalData {
   source = "CaseData",
   query = "childrenTopics",
   data = "topicName=topic_name",
   parameters = parentTopic
  }

 if topics ~= nil then

  output = output .. "<ul>"

  for i, topic in ipairs(topics) do

   output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"

   local childTopics, errors3 = mw.ext.externaldata.getExternalData {
    source = "CaseData",
    query = "childrenTopics",
    data = "topicName=topic_name",
    parameters = topic.topicName
   }

   if childTopics ~= nil then
    output = output .. "<ul>"
    for i, childTopic in ipairs(childTopics) do
     output = output .. " <li>" .. "[[" .. childTopic.topicName .. "]]"
    end
    output = output .. "</ul>"
   end

  end

  output = output .. "</ul>"

 end

 return output

end


return p