Module:Athena

-- A t e n e a -- local athena = {}

local userError = require("Dev:User error") local page = mw.title.getCurrentTitle --local u = require('Dev:Utility') local json = require("Dev:Json")

function athena.getId return page.id end

function athena.getData(f) local param = f.args[1] return athena.printData(param, athena.loadData[param]) end

function athena.getExternalData(f) local param = f.args[2] return athena.printData(param, athena.loadData(f.args[1])[param]) end

function athena.exportToJSON(f) local id = f.args[1] return json.encode(athena.loadData(id)) end

function athena.decodeJSON(f) local id = f.args[1] return json.decode(id) end

function athena.loadData(id) return mw.loadData("Module:Athena/" .. (id or page.id)) or userError("Data not found") end

-- - @name printData -  @desc "Pretty" prints the data with proper data attributes for easy access -  @type function -  @params[    param - Parameter of the data    value - Value of the data    @example: athena.printData('a', 'b') outputs b -- function athena.printData(param, value) return tostring(mw.html.create("span"):addClass("athenaData"):attr("data-param", param):wikitext(value)) or       userError("Couldn't print data") end

return athena