Module:No interwiki access
Jump to navigation
Jump to search
See Global Lua Modules/No interwiki access
-- <nowiki>
--------------------------------------------------------------------------------
-- No interwiki access restricts a module's usage to Fandom Developers Wiki.
-- This module is called on internal and project modules that are developed
-- specifically for Fandom Developers Wiki and do not support interwiki usage.
-- These modules are not part of the [[Global Lua Modules|global repository]]
-- and probably should be listed on a project page.
--
-- If an error is thrown at line 38, the caller module is not being used on
-- Fandom Developers Wiki. In essence, this module is the Lua equivalent of
-- the following HTTP CORS (Cross-Origin Resource Sharing) response header:
--
-- {{#tag:pre|Access-Control-Allow-Origin: https://dev.fandom.com}}

--
-- To use this module, add the following on your module:
--
-- {{#tag:pre|require('Dev:No interwiki access')}}
--
-- @script NO_INTERWIKI_ACCESS
-- @release beta
-- @author [[User:DarthKitty|DarthKitty]]
-- @author [[User:8nml|8nml]]
-- @usage
--
-- local p = {}
-- require('Dev:No interwiki access')
-- p.noop = function() end
-- return p
--
--------------------------------------------------------------------------------
if mw.uri.new(mw.site.server).host ~= 'dev.fandom.com' then
local message = 'module `%s\' not accessible outside https://dev.fandom.com'
local trace, caller_ptn = debug.traceback(), '[^\n]+\n[^\n]+\n%s+([\n]+)'
caller = trace:find(caller_ptn)
and trace:match(caller_ptn):gsub(':?[^:]*: .-$', '')
or mw.title.getCurrentTitle().prefixedText
error(string.format(message, caller), 3)
end
-- </nowiki>