<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikiyouth.eu/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ACity</id>
	<title>Module:City - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikiyouth.eu/w/index.php?action=history&amp;feed=atom&amp;title=Module%3ACity"/>
	<link rel="alternate" type="text/html" href="https://wikiyouth.eu/w/index.php?title=Module:City&amp;action=history"/>
	<updated>2026-04-15T06:48:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wikiyouth.eu/w/index.php?title=Module:City&amp;diff=35596&amp;oldid=prev</id>
		<title>Admin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wikiyouth.eu/w/index.php?title=Module:City&amp;diff=35596&amp;oldid=prev"/>
		<updated>2025-04-09T08:42:59Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:42, 9 April 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wiki_wikiyouth:diff:1.41:old-35595:rev-35596 --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://wikiyouth.eu/w/index.php?title=Module:City&amp;diff=35595&amp;oldid=prev</id>
		<title>en&gt;Marsupium: function p.qCode(): adjustment for last edit: don&#039;t use redirected gallery page name for further search to avoid redirect targets like that of Susa on this page</title>
		<link rel="alternate" type="text/html" href="https://wikiyouth.eu/w/index.php?title=Module:City&amp;diff=35595&amp;oldid=prev"/>
		<updated>2024-10-26T18:55:07Z</updated>

		<summary type="html">&lt;p&gt;function p.qCode(): adjustment for last edit: don&amp;#039;t use redirected gallery page name for further search to avoid redirect targets like that of &lt;a href=&quot;/w/index.php?title=Susa&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Susa (page does not exist)&quot;&gt;Susa&lt;/a&gt; on &lt;a href=&quot;/wiki/Special:PermanentLink/795100560&quot; title=&quot;Special:PermanentLink/795100560&quot;&gt;this page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.qCode(place)&lt;br /&gt;
	-- recover a q-code based on place name, also if one can link to a page on commons return such link&lt;br /&gt;
	local item, link = nil, nil&lt;br /&gt;
&lt;br /&gt;
    -- === STEP 1: if &amp;quot;place&amp;quot; is empty than return nothing ==============&lt;br /&gt;
	if (not place) or (place == &amp;quot;&amp;quot;) then&lt;br /&gt;
		return item, link&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
  -- === STEP 2: Check if &amp;quot;place&amp;quot;  holds a q-code or matches any of the hardwired names  ==============&lt;br /&gt;
	if string.match(place, &amp;quot;^Q%d+$&amp;quot;) then&lt;br /&gt;
		return place, link -- place string contains a q-code&lt;br /&gt;
	else&lt;br /&gt;
		-- if multiple calls to {{City}} from a single file, than mw.loadData should load [[Module:City/data]] only once&lt;br /&gt;
		local LookupTable = mw.loadData(&amp;quot;Module:City/data&amp;quot;)&lt;br /&gt;
		item = LookupTable[mw.ustring.lower(place)]&lt;br /&gt;
		if item then&lt;br /&gt;
			return item, link&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- === STEP 3: Check if &amp;quot;place&amp;quot; matches existing template, gallery or category and if so provide the link  ===&lt;br /&gt;
	if #place&amp;gt;=3 and #place&amp;lt;40 then&lt;br /&gt;
		local page = mw.title.new( place, &amp;#039;&amp;#039; )&lt;br /&gt;
		if page and page.exists then&lt;br /&gt;
			local page_name = place&lt;br /&gt;
			if page.redirectTarget then&lt;br /&gt;
				page_name = page.redirectTarget.prefixedText&lt;br /&gt;
			end&lt;br /&gt;
			item = mw.wikibase.getEntityIdForTitle( page_name )&lt;br /&gt;
			link = &amp;quot;[[&amp;quot; .. page_name .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			if item then&lt;br /&gt;
				return item, link&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		page = mw.title.new( place, &amp;#039;category&amp;#039; )&lt;br /&gt;
		if page and page.exists then&lt;br /&gt;
			local resolve_redirect = require(&amp;quot;Module:Resolve category redirect&amp;quot;).rtarget&lt;br /&gt;
			place = resolve_redirect(place)&lt;br /&gt;
			item = mw.wikibase.getEntityIdForTitle( &amp;#039;Category:&amp;#039; .. place )&lt;br /&gt;
			link = &amp;quot;[[:Category:&amp;quot; .. place .. &amp;quot;|&amp;quot; .. place .. &amp;quot;]]&amp;quot;&lt;br /&gt;
			if item then&lt;br /&gt;
				local entity = mw.wikibase.getEntityObject(item)&lt;br /&gt;
				if entity then &lt;br /&gt;
					local s = entity:getBestStatements( &amp;#039;P31&amp;#039; )&lt;br /&gt;
					if s[1] and s[1].mainsnak.datavalue.value.id==&amp;quot;Q4167836&amp;quot; then &lt;br /&gt;
						-- if &amp;quot;instance of &amp;quot;(P31) = &amp;quot;Wikimedia category&amp;quot; (Q4167836)&lt;br /&gt;
						s = entity:getBestStatements( &amp;#039;P301&amp;#039; ) -- category&amp;#039;s main topic &lt;br /&gt;
						if s[1] then -- if property &amp;quot;category&amp;#039;s main topic&amp;quot; (P301) is set&lt;br /&gt;
							item = s[1].mainsnak.datavalue.value.id &lt;br /&gt;
						else&lt;br /&gt;
							item = nil&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			return item, link&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- === STEP 4: Check if &amp;quot;place&amp;quot; matches an interwiki link to a Wikipedia&lt;br /&gt;
	-- page with the link label matching the full page name that is linked to a&lt;br /&gt;
	-- Wikidata item ===&lt;br /&gt;
	local langcode, pagename = mw.ustring.match(place, &amp;quot;^%[%[w?:(.+):(.+)|%2%]%]$&amp;quot;)&lt;br /&gt;
	if langcode and pagename then&lt;br /&gt;
		item = mw.wikibase.getEntityIdForTitle( pagename, langcode .. &amp;#039;wiki&amp;#039; )&lt;br /&gt;
		link = place&lt;br /&gt;
	end&lt;br /&gt;
	return item, link&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._city(place, lang, link)&lt;br /&gt;
	if (not place) or (place == &amp;quot;&amp;quot;) then&lt;br /&gt;
		return &amp;quot;&amp;quot; --if &amp;quot;place&amp;quot; is empty than do nothing&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if string.match(place, &amp;quot;[%{%{|%[%[].+[%}%}|%]%]]&amp;quot;) then&lt;br /&gt;
		return place --  if &amp;quot;place&amp;quot; already has a link and if so than skip the rest of the template&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
    -- Check if we can recover a q-code&lt;br /&gt;
	local item, linkStr = p.qCode(place)&lt;br /&gt;
	if item then&lt;br /&gt;
		local wikidata = require(&amp;quot;Module:Wikidata label&amp;quot;)&lt;br /&gt;
		return wikidata._getLabel(item, lang, link)&lt;br /&gt;
	elseif linkStr then&lt;br /&gt;
		return linkStr -- no q-code but we matched one of the galleries or categories&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- return as is&lt;br /&gt;
	return place&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.city(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	if not (args.lang and mw.language.isSupportedLanguage(args.lang)) then &lt;br /&gt;
		args.lang = frame:callParserFunction( &amp;quot;int&amp;quot;, &amp;quot;lang&amp;quot; ) -- get user&amp;#039;s chosen language &lt;br /&gt;
	end&lt;br /&gt;
	if (not args.link) or (mw.text.trim(args.link) == &amp;quot;&amp;quot;) then&lt;br /&gt;
		args.link = &amp;quot;wikipedia&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	args.place = mw.text.trim(args.place or &amp;#039;&amp;#039;)&lt;br /&gt;
	return p._city(args.place, args.lang, args.link)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>en&gt;Marsupium</name></author>
	</entry>
</feed>