<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AWikiProjectBanner%2FContext</id>
	<title>Module:WikiProjectBanner/Context - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AWikiProjectBanner%2FContext"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:WikiProjectBanner/Context&amp;action=history"/>
	<updated>2026-06-19T02:12:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:WikiProjectBanner/Context&amp;diff=480027&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:WikiProjectBanner/Context&amp;diff=480027&amp;oldid=prev"/>
		<updated>2021-07-16T07:58:23Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-------------------------------------------------------------------------------&lt;br /&gt;
--                               Context class                               --&lt;br /&gt;
-- This module contains the Context class used in Module:WikiProjectBanner.  --&lt;br /&gt;
-- It stores data about the title we are being called from, provides access  --&lt;br /&gt;
-- to the config and banner config modules, generates data commonly used by  --&lt;br /&gt;
-- subclasses (e.g. project name), and provides a place to store data        --&lt;br /&gt;
-- generated by subclasses that needs to be reused (e.g. Grade objects)      --&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
-- Load required modules&lt;br /&gt;
local mShared = require('Module:WikiProjectBanner/shared')&lt;br /&gt;
local libraryUtil = require('libraryUtil')&lt;br /&gt;
local checkType = libraryUtil.checkType&lt;br /&gt;
&lt;br /&gt;
-- Lazily load modules we don't always need.&lt;br /&gt;
local yesno&lt;br /&gt;
&lt;br /&gt;
local Context = {}&lt;br /&gt;
&lt;br /&gt;
function Context.new(bannerName, args, cfg, bannerCfg)&lt;br /&gt;
	local obj = {}&lt;br /&gt;
&lt;br /&gt;
	-- Check the input set default values.&lt;br /&gt;
	checkType('Context.new', 1, project, 'string')&lt;br /&gt;
	checkType('Context.new', 2, args, 'table', true)&lt;br /&gt;
	checkType('Context.new', 3, cfg, 'table', true)&lt;br /&gt;
	checkType('Context.new', 4, bannerCfg, 'table', true)&lt;br /&gt;
	obj.bannerName = bannerName&lt;br /&gt;
	obj.args = args or {}&lt;br /&gt;
	obj.cfg = cfg or mw.loadData('Module:WikiProjectBanner/config')&lt;br /&gt;
	obj.bannerCfg = bannerCfg or mShared.maybeRequire(&lt;br /&gt;
		'Module:WikiProjectBanner/banners/' .. data.bannerName&lt;br /&gt;
	)&lt;br /&gt;
	if not obj.bannerCfg then&lt;br /&gt;
		error(&lt;br /&gt;
			'banner data page [[Module:WikiProjectBanner/banners/' ..&lt;br /&gt;
			bannerName ..&lt;br /&gt;
			']] does not exist',&lt;br /&gt;
			0&lt;br /&gt;
		)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Set properties that we will need every time or that are inexpensive.&lt;br /&gt;
	obj.currentTitle = mw.title.getCurrentTitle()&lt;br /&gt;
	obj.subjectTitle = obj.currentTitle.subjectPageTitle&lt;br /&gt;
&lt;br /&gt;
	-- Set up the metatable and define functions for properties to be&lt;br /&gt;
	-- generated on the fly. These functions are used for properties that are&lt;br /&gt;
	-- expensive to generate and that we might not need.&lt;br /&gt;
	local propertyFuncs = {}&lt;br /&gt;
	setmetatable(obj, {&lt;br /&gt;
		__index = function (t, key)&lt;br /&gt;
			local func = propertyFuncs[key]&lt;br /&gt;
			if func then&lt;br /&gt;
				local val = func()&lt;br /&gt;
				obj[key] = val&lt;br /&gt;
				return val&lt;br /&gt;
			else&lt;br /&gt;
				return Context[key]&lt;br /&gt;
			end			&lt;br /&gt;
		end&lt;br /&gt;
	})&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.pageType()&lt;br /&gt;
		return require('Module:Pagetype')._main{}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.project()&lt;br /&gt;
		-- Gets the project name from the banner name.&lt;br /&gt;
		-- For example, for &amp;quot;WikiProject Tulips&amp;quot;, the project name would be&lt;br /&gt;
		-- &amp;quot;Tulips&amp;quot;.&lt;br /&gt;
		if obj.bannerCfg.project then&lt;br /&gt;
			return obj.bannerData.project&lt;br /&gt;
		else&lt;br /&gt;
			local pattern = obj.cfg.msg['project-page-name-pattern']&lt;br /&gt;
			return mw.ustring.match(obj.bannerName, pattern) or obj.bannerName&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.projectLink()&lt;br /&gt;
		-- The project page, e.g. &amp;quot;Wikipedia:WikiProject Tulips&amp;quot;.&lt;br /&gt;
		if obj.bannerCfg.projectLink then&lt;br /&gt;
			return obj.bannerCfg.projectLink&lt;br /&gt;
		else&lt;br /&gt;
			local msg = obj.cfg.msg['project-link']&lt;br /&gt;
			return mShared.substituteParams(msg, obj.project)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.projectName()&lt;br /&gt;
		-- The project name without a namespace prefix,&lt;br /&gt;
		-- e.g. &amp;quot;WikiProject Tulips&amp;quot;.&lt;br /&gt;
		if obj.bannerCfg.projectName then&lt;br /&gt;
			return obj.bannerCfg.projectName&lt;br /&gt;
		else&lt;br /&gt;
			local msg = obj.cfg.msg['project-name']&lt;br /&gt;
			return mShared.substituteParams(msg, obj.project)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.projectScope()&lt;br /&gt;
		-- A link to an article that encapsulates the project's scope,&lt;br /&gt;
		-- e.g. &amp;quot;[[Tulips]]&amp;quot;. The link will have square brackets added if they&lt;br /&gt;
		-- are not already present.&lt;br /&gt;
		local scope = obj.bannerCfg.projectScope&lt;br /&gt;
		if scope and scope:find('^%[%[') then&lt;br /&gt;
			return scope&lt;br /&gt;
		elseif scope then&lt;br /&gt;
			return mShared.makeWikilink(scope)&lt;br /&gt;
		else&lt;br /&gt;
			return mShared.makeWikilink(obj.project)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.projectLinkTalk()&lt;br /&gt;
		-- A link to the project talk page, without square brackets, e.g.&lt;br /&gt;
		-- &amp;quot;Wikipedia talk:WikiProject Tulips&amp;quot;.&lt;br /&gt;
		return mw.title.new(obj.projectLink).talkPageTitle.prefixedText&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.assessmentLink()&lt;br /&gt;
		-- The page containing the project's assessment scales.&lt;br /&gt;
		if obj.bannerCfg.assessmentLink ~= nil then&lt;br /&gt;
			-- Custom link or false for no link&lt;br /&gt;
			return bannerCfg.assessmentLink&lt;br /&gt;
		else&lt;br /&gt;
			local assessmentPage = obj.projectLink .. '/Assessment'&lt;br /&gt;
			local assessmentTitle = mw.title.new(assessmentPage)&lt;br /&gt;
			return assessmentTitle&lt;br /&gt;
				and assessmentTitle.exists&lt;br /&gt;
				and assessmentTitle.prefixedText&lt;br /&gt;
				or false&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	function propertyFuncs.isSmall()&lt;br /&gt;
		-- Whether we are outputting a small banner or not.&lt;br /&gt;
		yesno = yesno or require('Module:Yesno')&lt;br /&gt;
		return yesno(obj.args.small)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	function propertyFuncs.isDemo()&lt;br /&gt;
		-- Whether we are outputting a demo page.&lt;br /&gt;
		local currentPage = obj.currentTitle.prefixedText&lt;br /&gt;
		local template = mw.site.namespaces[10].name .. ':' .. obj.bannerName&lt;br /&gt;
		local sandboxSubpage = obj.cfg.msg['sandbox-subpage']&lt;br /&gt;
		return currentPage == template&lt;br /&gt;
			or currentPage == template .. '/' .. sandboxSubpage&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return obj&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return Context&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>