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

提供:エケペディア
ナビゲーションに移動 検索に移動
(認証バッジ verified は "○" か "" で)
(表示名や認証マークをdatastoreできないな。。。)
1行目: 1行目:
local p = {};
local p = {};


local function setProperty(t_name, i_v)
local function setProperty(t_name, n_name, i_v)
-- メイン空間のみ
-- メイン空間のみ
14行目: 14行目:
     local dataStore = {}
     local dataStore = {}
     dataStore['Instagramアカウント'] = t_name
     dataStore['Instagramアカウント'] = t_name
    dataStore['表示名'] = n_name
     dataStore['認証バッジ'] = i_v
     dataStore['認証バッジ'] = i_v


41行目: 42行目:
local verified = args[3] or args.v or '';
local verified = args[3] or args.v or '';
-- Instagram 表示名デフォルト
if name == '' then
name = mw.ustring.gsub(mw.title.getCurrentTitle().text,"%s+%b()$","");
end
-- SemanticMediaWiki
-- SemanticMediaWiki
if not args.nosmw then
if not args.nosmw then
setProperty(i_name, verified);
setProperty(i_name, name, verified);
end
end




-- Instagram 表示名デフォルト
if name == '' then
name = mw.ustring.gsub(mw.title.getCurrentTitle().text,"%s+%b()$","");
end


local i_name2 = '(@' .. i_name  ..')';
local i_name2 = '(@' .. i_name  ..')';

2022年2月11日 (金) 01:17時点における版

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

local p = {};

local function setProperty(t_name, n_name, i_v)
	
	-- メイン空間のみ
	if not mw.title.getCurrentTitle().namespace == 0 then
		return true;
	end
	
	if not mw.smw then
        return true;
    end
    
    local dataStore = {}
    dataStore['Instagramアカウント'] = t_name
    dataStore['表示名'] = n_name
    dataStore['認証バッジ'] = i_v

    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:Instagram', removeBlanks = false, parentFirst = true });

	-- Instagram ID
	local i_name = args[1] or args.id or '';
	
	-- Instagram URL
	local formatterURL = "https://instagram.com/$1";
	local url = mw.ustring.gsub(formatterURL, "\$1", i_name);
	
	-- Instagram 表示名
	local name = args[2] or args.name or '';
	
	-- Instagram 認証バッジ
	local verified = args[3] or args.v or '';
	

	-- Instagram 表示名デフォルト
	if name == '' then
		name = mw.ustring.gsub(mw.title.getCurrentTitle().text,"%s+%b()$","");
	end

	-- SemanticMediaWiki
	if not args.nosmw then
		setProperty(i_name, name, verified);
	end



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

    if verified == '' then
  	   return '[' ..url ..' ' ..name ..'] ' ..i_name2 ..' - [[Instagram]]';
    end
	return '[' ..url ..' ' ..name ..'] ' ..i_name2 ..'[[ファイル:認証バッジ.png|15px]] - [[Instagram]]';
end

return p;