モジュールの解説[表示] [編集] [履歴] [キャッシュを破棄]

{{Twitter}}の内部モジュール。

使用法

  • {{#invoke:Twitter|main}}

local p = {};

local function getWikidataProperty(property, from )
    local entity = nil;
    if from == '' then
        entity = mw.wikibase.getEntityObject( );
    else
        entity = mw.wikibase.getEntityObject(from);
    end
    if not entity then
        return nil;
    end
    local claims = entity.claims or {};
    local hasProp = claims[property];
    if not hasProp then
        return nil;
    end
    return hasProp[1].mainsnak.datavalue.value;
end	

function p.main( frame )
	local args = require( 'Module:Arguments' ).getArgs( frame, { wrappers = 'Template:Twitter', removeBlanks = false, parentFirst = true });

	local t_name = args[1] or args.id or '';
	local from = args.from or '';

	if t_name == '' then
		t_name = getWikidataProperty('P2002', from) or error('ウィキデータにIDが登録されていません。[[Category:ウィキデータにないTwitter]]');
	end
	local lang = args.lang or '';
	local lang2 = '';

	if lang ~= '' then
		lang = '<span xml:lang="' ..lang ..'" lang="' ..lang ..'">';
		lang2 = '</span>';
	end

	local formatterURL = mw.text.decode(getWikidataProperty('P1630', 'P2002'));
	local url = mw.ustring.gsub(formatterURL, "\$1", t_name);
	local name = args[2] or args.name or '';

	if name == '' then
		name = mw.ustring.gsub(mw.title.getCurrentTitle().text, "%s+%b()$", "");
	end

	local t_name2 = '(@' .. t_name  ..')';
	if mw.ustring.match(name, '%(' .. t_name .. '%)$') then
		t_name2 = '';
	end

	return '[' ..url ..' ' ..lang ..name ..lang2 ..'] ' ..t_name2 ..' - [[X (ソーシャル・ネットワーキング・サービス)|X(旧Twitter)]]';
end

return p;
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy