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

Property:Twitter型データ取り込み用
(Motodai (トーク) による編集を 48wiki による直前の版へ差し戻しました)
タグ: 巻き戻し モバイル編集 モバイルウェブ編集 改良版モバイル編集
(Property:Twitter型データ取り込み用)
1行目: 1行目:
local p = {};
local p = {};


local function setProperty(t_name)
local function setProperty(dataStore)
-- メイン空間のみ
-- メイン空間のみ
11行目: 11行目:
         return true;
         return true;
     end
     end
   
    local dataStore = {}
    dataStore['twitterアカウント'] = t_name


     local result = mw.smw.set( dataStore )
     local result = mw.smw.set( dataStore )
22行目: 19行目:
         -- error message to be found in result.error
         -- error message to be found in result.error
     end
     end
end
end


function p.main( frame )
function p.main( frame )
28行目: 25行目:


-- Twitter ID
-- Twitter ID
local t_name = args[1] or args.id or '';
local i_name = args[1] or args.id or '';
-- Twitter URL
-- Twitter URL
local formatterURL = "http://twitter.com/$1";
local formatterURL = "https://twitter.com/$1";
local url = mw.ustring.gsub(formatterURL, "\$1", t_name);
local url = mw.ustring.gsub(formatterURL, "\$1", i_name);
-- Twitter 表示名
-- Instagram 表示名
local name = args[2] or args.name or '';
local name = args[2] or args.name or '';
-- SemanticMediaWiki
-- Twitter verify
if not args.nosmw then
local verify = args[3] or args.verify or '';
setProperty(t_name);
    local v_veryfy = '';
if verify == '' then
verify = 'false';
        v_veryfy = '';
else
verify ='true';
v_veryfy = '[[ファイル:認証バッジ.png|15px]]';
end
end
 
 


-- Twitter 表示名デフォルト
-- Twitter 表示名デフォルト
if name == '' then
if name == '' then
name = "Twitterアカウント";
name = mw.ustring.gsub(mw.title.getCurrentTitle().text,"%s+%b()$","");
end
 
 
-- SemanticMediaWiki
    local dataStore = {}
    dataStore['Twitter'] = '' .. i_name .. ';'..verify .. ';'..name
 
if not args.nosmw then
setProperty(dataStore);
end
end


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


return '[' ..url ..' ' ..name ..'] ' ..t_name2 ..' - [[Twitter]]';
return '[' ..url ..' ' ..name ..'] ' ..i_name2 ..v_veryfy..'- [[Twitter]]';
end
end


return p;
return p;
user-upload
32,192

回編集