Module:Config: Difference between revisions

Kwwxis (talk | contribs)
Created page with "-- <pre> -------------------------------------------------------------------------------- -- Allows wikis to locally override `/config` subpages of modules. -- -- @script config -- @alias p -- @release experimental -- @require Module:No globals -- @require Module:TableTools -- @author User:ExE Boss -- @see Module:I18n - Inspired the way in which the @{Config} class works. -------------------------------------------------------------------------------- lo..."
 
Kuhlau (talk | contribs)
update to no longer require Devwiki (from petitplanet wiki, page created by Stevium)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
-- <pre>
-- <pre>
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Source: https://genshin-impact.fandom.com/wiki/Module:Config
-- Allows wikis to locally override `/config` subpages of modules.
-- Allows wikis to locally override `/config` subpages of modules.
--
--
Line 18: Line 19:


local tableTools = require('Module:TableTools');
local tableTools = require('Module:TableTools');
-- Module constants
local DEV_WIKI = 'https://dev.fandom.com';


local p = {};
local p = {};
Line 115: Line 113:
source = string.gsub(source, '^.', mw.ustring.upper);
source = string.gsub(source, '^.', mw.ustring.upper);
local hasNS = mw.ustring.find(source, ':');
local hasNS = mw.ustring.find(source, ':');
if (not hasNS) then
    if (not hasNS) then
source = source .. '/config';
        source = 'Module:' .. source .. '/config';
if (mw.site.server ~= DEV_WIKI) then
    end
-- If this is dev.fandom.com, then `"Module:" .. source .. "/config"`
-- and `"Dev:" .. source .. "/config"` point to the same configuration page
local exists, localData = pcall(mw.loadData, 'Module:' .. source);
if (exists and type(localData) == 'table') then
cfg._data[#cfg._data + 1] = localData;
end
end
source = 'Dev:' .. source;
end


cfg._data[#cfg._data + 1] = mw.loadData(source);
cfg._data[#cfg._data + 1] = mw.loadData(source);