Module:Test

From Test Wiki
Revision as of 15:54, 15 April 2021 by Q8j (talk | contribs)
Jump to navigation Jump to search
--[[ This is a test page for testing lua in mediawiki
place your code below this comment
please remove when you are done testing,
Thank You! and have fun
]]

local p ={}
function p.Main(frame)
	local m_title = mw.title.new(tonumber(frame.args[1]))
	local m_exist = m_title ~= nil
	local m_pageidlink = '[[:mw:Manual:Page_table/ja#page_id|ID]] : [[Special:Redirect/page/' .. frame.args[1] .. '|' .. frame.args[1] .. ']]'
	local m_titlestring = ''
	local m_talkpagelink = ''
	local m_historyurl = ''
	local m_loglink = ''
	local m_whatlinkshere = ''

	if m_exist then
		m_titlestring = mw.allToString(m_title)
		m_talkpagelink = '[[' .. mw.allToString(m_title.talkPageTitle) .. '|ノート]]'
		m_historyurl = '[' .. mw.allToString(mw.uri.fullUrl(m_titlestring,'action=history')) .. ' 履歴]'
		m_loglink = '[//ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:Log&page=' .. mw.uri.encode(m_titlestring,"WIKI") .. ' ログ]'
		m_whatlinkshere = '[[Special:WhatLinksHere/' .. m_titlestring .. '|リンク元]]'
	end
	
	if m_exist then
		if m_title.isTalkPage then
			return m_pageidlink .. '<span style="font-size:smaller" class="plainlinks">(' .. m_historyurl .. ' / ' .. m_loglink .. ' / ' .. m_whatlinkshere .. ')</span>'
		else
			return m_pageidlink .. '<span style="font-size:smaller" class="plainlinks">(' .. m_talkpagelink .. ' / ' .. m_historyurl .. ' / ' .. m_loglink .. ' / ' .. m_whatlinkshere .. ')</span>'
		end
	else
		return m_pageidlink .. '<span style="font-size:smaller">(非存在)</span>'
	end
	
end
return p