「モジュール:Pococha」の版間の差分

提供: エケペディア
ナビゲーションに移動 検索に移動
Motodai (トーク | 投稿記録)
17Liveに準じて、Pococha も作成、当面は、僕青のみ
 
Motodai (トーク | 投稿記録)
編集の要約なし
 
48行目: 48行目:
end
end


local t_name2 = '(@' .. t_name  ..')';
-- local t_name2 = '(@' .. t_name  ..')';
if mw.ustring.match(name, '%(' .. t_name .. '%)$') then
if mw.ustring.match(name, '%(' .. t_name .. '%)$') then
t_name2 = '';
t_name2 = '';
54行目: 54行目:


     -- Pococha は記事が作成されるまではリンクは張らない
     -- Pococha は記事が作成されるまではリンクは張らない
return '[' ..url ..' ' ..name ..'] ' ..t_name2 ..' - Pococha';
-- return '[' ..url ..' ' ..name ..'] ' ..t_name2 ..' - Pococha';
return '[' ..url ..' ' ..name ..'] - Pococha';
end
end


return p;
return p;

2026年10月2日 (金) 23:01時点における最新版

このモジュールについての説明文ページを モジュール:Pococha/doc に作成できます

local p = {};

local function setProperty(t_name)
	
	-- メイン空間のみ
	if not mw.title.getCurrentTitle().namespace == 0 then
		return true;
	end
	
	if not mw.smw then
        return true;
    end
    
    local dataStore = {}
    dataStore['Pocochaアカウント'] = t_name

    local result = mw.smw.set( dataStore )

    if result == true then
        -- everything ok
    else
        -- error message to be found in result.error
    end
end	

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

	--  ID
	local t_name = args[1] or args.id or '';
	
	--  URL
	local formatterURL = "https://www.pococha.com/ja-jp/app/users/$1";
	local url = mw.ustring.gsub(formatterURL,"$1", t_name);
	
	-- 表示名
	local name = args[2] or args.name or '';
	
	-- SemanticMediaWiki
	if not args.nosmw then
		setProperty(t_name);
	end


	-- 表示名デフォルト
	if name == '' then
		name = "Pocochaアカウント";
	end

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

    -- Pococha は記事が作成されるまではリンクは張らない
	-- return '[' ..url ..' ' ..name ..'] ' ..t_name2 ..' - Pococha';
	return '[' ..url ..' ' ..name ..'] - Pococha';
end

return p;