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

提供:エケペディア
ナビゲーションに移動 検索に移動
(ページの作成:「local p = {}; local function setProperty(fanpla_name) -- メイン空間のみ if not mw.title.getCurrentTitle().namespace == 0 then return true; end if not mw.smw then return true; end local dataStore = {} dataStore['fanpla_nameルームキー'] = fanpla_name local result = mw.smw.set( dataStore ) if result == true then -- everything ok else -- error message to be found in result.error end end…」)
 
編集の要約なし
 
13行目: 13行目:
      
      
     local dataStore = {}
     local dataStore = {}
     dataStore['fanpla_nameルームキー'] = fanpla_name
     dataStore['fanplaルームキー'] = fanpla_name


     local result = mw.smw.set( dataStore )
     local result = mw.smw.set( dataStore )

2022年12月22日 (木) 03:25時点における最新版

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

local p = {};

local function setProperty(fanpla_name)
	
	-- メイン空間のみ
	if not mw.title.getCurrentTitle().namespace == 0 then
		return true;
	end
	
	if not mw.smw then
        return true;
    end
    
    local dataStore = {}
    dataStore['fanplaルームキー'] = fanpla_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:fanpla', removeBlanks = false, parentFirst = true });

	-- fanpla ID
	local fanpla_name = args[1] or args.id or '';
	
	-- fanpla URL
	local formatterURL = "https://$1-rooms.fanpla.jp/";
	local url = mw.ustring.gsub(formatterURL, "\$1", fanpla_name);
	
	-- fanpla 表示名
	local name = args[2] or args.name or '';
	
	-- SemanticMediaWiki
	if not args.nosmw then
		setProperty(fanpla_name);
	end


	-- fanpla 表示名デフォルト
	if name == '' then
		name = "fanpla ROOM";
	end

	return '[' ..url ..' ' ..name ..']  - fanpla';
end

return p;