د "Module:Cite" د بڼو تر مېنځ توپير

Content deleted Content added
gg
نښلنونه: د موبايل سمون د موبايل وېب سمون
 
.....
۴ کرښه:
local wikidata = require('Module:Wikidata2').formatStatementsFromLua
local quall = require('Module:Cite/quall')
--local wikidata2 = require(''Module:Wikidata2').formatEntityId -- table
local Options = {}
 
local function make_P345_link( s )
local IMDB_Table = {
['tt'] = 'https://www.imdb.com/title/$1/',
['co'] = 'https://www.imdb.com/search/title?companies=$1',
['ev'] = 'https://www.imdb.com/event/$1/',
['nm'] = 'https://www.imdb.com/name/$1/',
['ni'] = 'https://www.imdb.com/news/$1/',
}
local s2 = s:sub(1,2)
--mw.log("s2" .. s2 )
if IMDB_Table[s2] then
local fo = mw.ustring.gsub( IMDB_Table[s2], '$1', s )
return '[' .. fo .. ' ' .. fo .. ']'
end
return s
end
local function getentityprop(entity, p , pattern )
-- get automatically url
local addTracking = "t"
local Pattern = (pattern or 'autourl4')--autourl3
if p == "P345" then
local tot = wikidata({ property = p , pattern = Pattern , noref = 'true', conjunction = ' & ',enlabelcate ='true', addTrackingCat= "t" , noicon = "t" })
Pattern = ""
local tot1 = wikidata({entityId = entity, property = p , pattern = Pattern , noref = 'true', conjunction = ' & ',enlabelcate ='true', addTrackingCat= "t", noicon = "t" })
addTracking = ""
if not tot or tot == '' then
tot = tot1
end
local tot = wikidata({ property = p , pattern = Pattern"" , noref = 'true', conjunction = ' & ',enlabelcate ='true', addTrackingCat= "t" , noicon = "t" })addTracking
, noicon = "t" , raw2 = Options.raw or ""
})
if not tot or tot == '' then
local tot1 tot = wikidata({entityId = entity, property = p , pattern = Pattern , noref = 'true', conjunction = ' & ',enlabelcate ='true', addTrackingCat= "t", noicon = "t" })
, addTrackingCat= addTracking , noicon = "t" , raw2 = Options.raw or "" })
end
if p == "P345" then tot = make_P345_link(tot) end
-- if tot and tot ~= '' then
-- return tot --وصلة نښلول:
--end
Line ۳۳ ⟶ ۵۹:
and snak[property][1].datavalue.value['numeric-id']
then
houseid = snak[property][1].datavalue.value['numeric-id']
local l10n = quall[houseid]
if l10n then
local q = {}
for _, v in pairs(l10n) do
mw.log("Module:Cite finding " .. v[1] .. "house, id:" .. houseid )
b = getentityprop (entity, v[1] , v[3])
if b and b ~= ''
Line ۷۱ ⟶ ۹۷:
end
local function P1629(property,text)
--local pro = wikidata({property = 'P1629', nolink = 'true', entityId = property, enbartenfirstvalue = 'true', noref = 'true',enlabelcate ='true' , label = get_property_label(property) })
local pro = get_property_label(property)
if not text or text == '' then text = pro end
Line ۷۹ ⟶ ۱۰۵:
end
 
local function ValueFromItem(items, property,enbartenfirstvalue)
local pattern = 'autourl'
if property =='P212' or property =='P957' then pattern = nil end -- no automatic link for ISBN
for i, item in pairs(items) do
ednumber = wikidata({entityId = item, property = property , enbartenfirstvalue = enbartenfirstvalue, pattern =pattern
, noref = 'true', modifytime = 'longdate',enlabelcate ='true'})
end
Line ۸۹ ⟶ ۱۱۵:
end
 
local function ValueFromEntityId(entity, property,enbartenfirstvalue)
local pattern = 'autourl'
val = wikidata({entityId = entity, property = property, enbartenfirstvalue = enbartenfirstvalue, pattern = pattern
, noref = 'true', modifytime = 'longdate',enlabelcate ='true'})
if val then
Line ۹۸ ⟶ ۱۲۴:
end
 
--local function GetValueFromEntityId(snak,entity, property, enbartenfirstvalue)
local function GetValueFromEntityId(snak , property , enbartenfirstvalue)
--local A = wikidata({property = 'P1629', entityId = property,enlabelcate ='true' , enbartenfirstvalue = 'true', noref = 'true', label = get_property_label( property )})
local A = get_property_label(property)
local Pattern = "autourl"
local prop = wikidata({property = property, enbarten = enbarten, noref = 'true'
if property == "P345" then Pattern = "" end
, pattern = 'autourl', modifytime = 'longdate'}, snak)
local prop = wikidata({property = property, enbartenfirstvalue = enbartenfirstvalue, noref = 'true'
--if not prop then prop = ValueFromEntityId(entity, property,enbarten) end
, pattern = 'autourl'Pattern, modifytime = 'longdate'}, snak)
--mw.log("prop" .. prop )
if property == "P345" then prop = make_P345_link(prop) end
--mw.log('Module:Cite property:"' .. property .. '"' )
--mw.log('Module:Cite prop:"' .. prop .. '"' )
--if not prop then prop = ValueFromEntityId(entity, property,enbartenfirstvalue) end
if prop and prop ~= '' then
if A and A ~= '' then
Line ۱۱۴ ⟶ ۱۴۶:
end
 
local function GetValueFromItem(items, snak, property , text,enbartenfirstvalue)
local pattern = 'autourl'
if property =='P212' or property =='P957' then pattern = nil end -- no automatic link for ISBN
local prop = wikidata({property = property
, enbartenfirstvalue = enbartenfirstvalue
, pattern = pattern
, noref = 'true'
Line ۱۲۴ ⟶ ۱۵۶:
,enlabelcate ='true'}, snak)
if not prop
then prop = ValueFromItem(items, property,enbartenfirstvalue)
end
if prop and prop ~= '' then
Line ۱۳۴ ⟶ ۱۶۶:
local function get_number_from_item(items, property)
for i, item in pairs(items) do
ednumber = wikidata({entityId = item, property = property, enbartenfirstvalue = 'yes',enlabelcate ='true'})
if ednumber then
return ednumber
Line ۱۴۲ ⟶ ۱۷۴:
local function getnumber(items, snak, property,text)
 
--local tex = wikidata({property = 'P1629', entityId = property, enbartenfirstvalue = 'true', noref = 'true', label = get_property_label(property )
--, label = wikidata2(property, {nolink = 'true', noref = 'true',enlabelcate ='true'}).value
--})
local tex = get_property_label(property )
 
local number = wikidata({property = property, enbartenfirstvalue = 'true',enlabelcate ='true'}, snak)
if not number then
number = get_number_from_item(items, property)
Line ۱۶۱ ⟶ ۱۹۳:
end
 
local function GetItemValue(items, snak, property , text,enbartenfirstvalue)
local pattern = 'autourl'
-- if property =='P212' or property =='P957' then pattern = nil end -- no automatic link for ISBN
local prop = wikidata({property = property, enbartenfirstvalue = (enbartenfirstvalue or ''), pattern = pattern, noref = 'true', modifytime = 'longdate'
,separator='، او',conjunction='، او'}, snak)
if not prop then prop = ValueFromItem(items, property,(enbartenfirstvalue or '')) end
if prop and prop ~= '' then
Line ۱۷۴ ⟶ ۲۰۶:
end
 
local function GetNumberFromItem(items, snak, property , text,enbartenfirstvalue)
local prop = wikidata({property = property, enbartenfirstvalue = 't'}, snak)
for i, item in pairs(items) do
ednumber = wikidata({entityId = item, property = property , enbartenfirstvalue = 'true', noref = 'true'})
end
if not prop then prop = ednumber end
Line ۱۸۷ ⟶ ۲۱۹:
 
--[[
د ملکیتونو لپاره چې د ملکیت هیڅ حواله نه لري P1065,P854
جلب أي وصلة مرجع من الخواص مثل
P1065,P854
--]]
 
local function getLink(items, snak, property,text)
-- local tex = labeel(property,text)
local links = wikidata({property = property, pattern = 'true', noref = 'true' , enbartenfirstvalue = 'true'}, snak)
if links and links ~= '' then
if text and text ~= ''
Line ۲۰۱ ⟶ ۲۳۲:
end
end
local function getLink1get_Link_from_item(items, snak, property,text)
local links = ValueFromItem(items, property,'true')
local tex = labeel(property,text)
Line ۲۴۰ ⟶ ۲۷۱:
 
local function getedition(items, snak )
local ordning = {'اول', 'دوهم', 'دريم', 'څلرم', 'ّپنجم', 'شپږم', 'اووم', 'اتم', 'نهم', 'لسم', 'يوولس', 'دوولس'} local ednumber;
local ednumber;
if snak['P393'] then
ednumber = wikidata({property = 'P393', enbartenfirstvalue = 'true',enlabelcate ='true'}, snak)
else
ednumber = get_number_from_item(items, "P393")
Line ۲۵۱ ⟶ ۲۸۱:
end
if not tonumber(ednumber) then
return ' اشاعتنسخه ' .. ednumber
end
if ordning[tonumber(ednumber)] then
return ' اشاعت نسخه' .. ordning[tonumber(ednumber)]
end
local sist = string.sub(ednumber, string.len(ednumber))
if sist == '1' or sist == '2' then
return ' : اشاعت نسخه' .. ednumber
else
return ' : اشاعت نسخه' .. ednumber
end
end
Line ۲۶۷ ⟶ ۲۹۷:
local s = {}
if snak['P1680'] then
table.insert(s, wikidata({property = 'P1680', enbartenfirstvalue = 'true',enlabelcate ='true'}, snak))
else
for i, item in pairs( items) do
local lab = wikidata({property = 'P1680',enlabelcate ='true', entityId = item, enbartenfirstvalue = 'true', noref = 'true'})
local sitelink = mw.wikibase.sitelink( item )
if sitelink and lab then
Line ۲۹۱ ⟶ ۳۲۱:
local function gettitle(items, snak)
local link = getLink(items, snak, 'P854') or getLink(items, snak, 'P1065','') -- the title will be with the link
local title = GetItemValue(items, snak, 'P1476' , 'سرليک ' ,' ')
local subtitle = GetItemValue(items, snak, 'P1680' , 'سرليک ' ,' ')
if not title or title =='' then title = subtitle end
if link and link ~= ''
Line ۳۰۴ ⟶ ۳۳۴:
local function getwhatever(snak, property)
if snak[property] then
--mw.log("Module:Cite getwhatever property " .. property)
local a = get_property_label(property)
--local a = wikidata({property = 'P1629', entityId = property, enbartenfirstvalue = 'true', noref = 'true',enlabelcate ='true', label = get_property_label(property)})
local s = {}
--local items = {}
--mw.log("Module:Cite find snak.property " .. property)
for j, prop in pairs(snak[property]) do
if prop.snaktype == 'value' then
Line ۳۱۹ ⟶ ۳۴۹:
end
end
if property == "P143" then a = 'عواید له ' end
if property == "P248" then a = "'''پورتهیادونه برخهلخوا د'''" end
--table.insert(s, wikidata({property = property, conjunction = ', ',enlabelcate ='true'}, snak))
if #s > 0 then
Line ۳۴۳ ⟶ ۳۷۳:
--local vaa = GetValueFromEntityId(snak , entity , property , 'true' )
local vaa = GetValueFromEntityId(snak , property , 'true' )
--mw.log("Module:Cite gettherest property:" .. property )
table.insert(s, vaa)
end
Line ۳۵۴ ⟶ ۳۸۴:
 
function numbers( items, snak)
local section = GetNumberFromItem(items, snak, 'P958','بابموضوع: ')
local volume = GetNumberFromItem(items, snak, 'P478','ژرورځپاڼه: ')
local page = GetNumberFromItem(items, snak, 'P304','پاڼه: ')
local issue = GetNumberFromItem(items, snak, 'P433','شمېرهاعداد: ')
 
field = {}
Line ۳۹۴ ⟶ ۴۲۴:
function getMultiLink(items, snak , entity)
local title = GetItemValue(items, snak, 'P1476' ,'' ,'')
local link = getLink(items, snak, 'P854',title)--,'حواله یو آر ایل اخیستنه له'
local link1 = getLink1get_Link_from_item(items, snak, 'P854') --
--local therest = gettherest(snak, entity)
local therest = gettherest(snak)
local quall = Getquall(snak , entity)
local fulltext = getLink1get_Link_from_item(items, snak, 'P953') --
local accessdate =getdate(snak, 'P813','د نشر نېټه')
local archive = getLink(items, snak, 'P1065','')
Line ۴۲۸ ⟶ ۴۵۸:
local archive = getLink(items, snak, 'P1065','')
local archive1 = getLink(items, snak, 'P1065','آرکیو یو آر ایل')
local archivedate =getdate(snak, 'P2960','')-- تاريخد ارشیف نېټه آرکیو
local accessdate =getdate(snak, 'P813','د اعلاننشر نېټه')
local aa = geturl((archive or link),title)
Line ۴۳۹ ⟶ ۴۶۹:
if accessdate and accessdate ~= '' then table.insert(field, accessdate) end
end
a = ' سې آرکائیوآرشيف ' .. (org or 'اصل')
if archivedate and archivedate ~= '' then a =a .. ' په ' .. archivedate end
table.insert(field, a)
Line ۴۴۸ ⟶ ۴۷۸:
function getreftable( items, snak , hash , options )
local entity = options.entityId
local author = GetValueFromItem(items, snak, 'P50','مصنفدوتنه')
--local editor = getEditor(items, snak )
local editor = GetValueFromItem(items, snak, 'P98','مدیرسمونګر')
local title = gettitle(items, snak )
local publisher = GetValueFromItem(items, snak, 'P123','نشرونکېخپرونکی')
local creator = GetValueFromItem(items, snak, 'P170','خالقپیدا کوونکی')
local publishedin = GetValueFromItem(items, snak, 'P1433','نشريدنهنشرونه لخوا د')
 
--local publishedin = getpublishedin(items, snak )
--local publishdate = getPublishdate(items, snak )
local publishdate = getdate( snak, 'P577','نشرونهد لخواخپرولو دنیټه')
local edition = getedition(items, snak )
local number = numbers( items, snak)
Line ۴۷۰ ⟶ ۵۰۰:
local archiveLink = getarchiveLink(items, snak , entity)
local license = GetItemValue(items, snak, 'P275','اجازت نامهمنښتلیک')
local quote = GetItemValue(items, snak, 'P1683' , 'اقتباسارزښت' ,' ') --
if title and title ~= '' and subtitle and subtitle ~= '' then
--title = title .. ' : ' .. subtitle
Line ۵۱۶ ⟶ ۵۴۶:
for i, item in pairs(items) do
function qoo(item,property)
return wikidata({entityId = item, property = property , noref = 'true',enbartenfirstvalue='1',formatting = 'raw'})
end
local wiki = qoo(item, 'P1800') or qoo(item, 'P1566') or qoo(item,'P21') -- all wikimedia site ,GeoNames ,gender
local wik2 = qoo(item, 'P31')
local blackk = {"Q20651139"
, "Q465"
, "Q15241312"}
, 'Q52' -- Wikipedia
}
for k, b in pairs(blackk) do
if item == b then val = 'true' end
Line ۵۳۳ ⟶ ۵۶۷:
return val
end
 
local ref_cash = {}
 
function p.citeitem( items, snak , hash , options , notag)
Options = options
if hash and hash ~= "" and ref_cash[hash] then
--mw.log("Module:Cite ref_cash[hash] = " .. hash)
return ref_cash[hash]
end
if not items and not snak then return nil end
if type(items) == 'string' then
Line ۵۶۳ ⟶ ۶۰۴:
refrence = mw.getCurrentFrame():extensionTag( 'ref', refrence, {name = hash} )
end
end
if hash and hash ~= "" then
ref_cash[hash] = refrence
end
return refrence
Line ۵۶۸ ⟶ ۶۱۲:
 
function p.citeitem2( ref , options , notag)
Options = options
if not ref then return nil end
local hash = ref.hash
local snak = ref.snaks
local snnaks = ""
if hash and hash ~= "" and ref_cash[hash] then
--mw.log("Module:Cite ref_cash[hash] = " .. hash)
return ref_cash[hash]
end
for Px, prope in pairs(snak) do
snnaks = snnaks .. "," .. Px
end
--mw.log( "Module:Cite Citeitem2 hash: " .. hash )
--mw.log( "Module:Cite *snnaks : " .. snnaks )
items= {}
if snak.P248 then
Line ۶۰۲ ⟶ ۶۵۱:
end
end
if hash and hash ~= "" then
ref_cash[hash] = refrence
end
return refrence
end