Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Modül:VikiveriBK

bullvar_katip

Administrator
Katılım
21 Mayıs 2024
Mesajlar
532,105
-- Version: 2023-07-10 -- Module to implement use of a blacklist and whitelist for infobox fields -- Can take a named parameter |qid which is the Wikidata ID for the article -- if not supplied, it will use the Wikidata ID associated with the current page. -- Fields in blacklist are never to be displayed, i.e. module must return nil in all circumstances -- Fields in whitelist return local value if it exists or the Wikidata value otherwise -- The name of the field that this function is called from is passed in named parameter |name -- The name is compulsory when blacklist or whitelist is used, -- so the module returns nil if it is not supplied. -- blacklist is passed in named parameter |suppressfields (or |spf) -- whitelist is passed in named parameter |fetchwikidata (or |fwd) local p = {} local cdate -- initialise as nil and only load _complex_date function if needed -- Module:Complex date is loaded lazily and has the following dependencies: -- Module:Calendar -- Module:ISOdate -- Module:DateI18n -- Module:I18n/complex date -- Module:Ordinal -- Module:I18n/ordinal -- Module:Yesno -- Module:Formatnum -- Module:Linguistic -- -- The following, taken from https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times, -- is needed to use Module:Complex date which seemingly requires date precision as a string. -- It would work better if only the authors of the mediawiki page could spell 'millennium'. local dp = { [6] = "millennium", [7] = "century", [8] = "decade", [9] = "year", [10] = "month", [11] = "day", } local i18n = { ["errors"] = { ["property-not-found"] = "Özellik bulunamadı.", ["No property supplied"] = "Özellik sağlanmadı", ["entity-not-found"] = "Vikiveri varlığı bulunamadı.", ["unknown-claim-type"] = "Bilinmeyen talep türü.", ["unknown-entity-type"] = "Bilinmeyen varlık türü.", ["qualifier-not-found"] = "Niteleyici bulunamadı.", ["site-not-found"] = "Wikimedia projesi bulunamadı.", ["labels-not-found"] = "Etiket bulunamadı.", ["descriptions-not-found"] = "Açıklama bulunamadı.", ["aliases-not-found"] = "Takma ad bulunamadı.", ["unknown-datetime-format"] = "Bilinmeyen zaman biçimi.", ["local-article-not-found"] = "Madde Vikiveri'de mevcut, ancak Vikipedi'de mevcut değil", ["dab-page"] = " (dab)", }, ["months"] = { "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık" }, ["century"] = "yüzyıl", ["BC"] = "MÖ", ["BCE"] = "MÖ", ["ordinal"] = { [1] = ".", [2] = ".", [3] = ".", ["default"] = "." }, ["filespace"] = "Dosya", ["Unknown"] = "Bilinmeyen", ["NaN"] = "Sayı değil", -- set the following to the name of a tracking category, -- e.g. "Kategori:Eksik Vikiveri bilgisine sahip maddeler", or "" to disable: ["missinginfocat"] = "Kategori:Eksik Vikiveri bilgisine sahip maddeler", ["editonwikidata"] = "Bunu Vikiveri'de düzenleyin", ["latestdatequalifier"] = function (date) return "before " .. date end, -- some languages, e.g. Bosnian use a period as a suffix after each number in a date ["datenumbersuffix"] = "", ["list separator"] = ", ", ["multipliers"] = { [0] = "", [3] = " bin", [6] = " milyon", [9] = " milyar", [12] = " trilyon", } } -- This allows an internationisation module to override the above table if 'en' ~= mw.getContentLanguage:getCode then require("Module:i18n").loadI18n("Modül:VikiveriBK/i18n", i18n) end -- This piece of html implements a collapsible container. Check the classes exist on your wiki. local collapsediv = '" end else strout = nil -- no items had valid reference end if replacetext ~= "" and strout then strout = replacetext end return strout end ------------------------------------------------------------------------------- -- rendersnak takes a table (propval) containing the information stored on one property value -- and returns the value as a string and its language if monolingual text. -- It handles data of type: -- wikibase-item -- time -- string, url, commonsMedia, external-id -- quantity -- globe-coordinate -- monolingualtext -- It also requires linked, the link/pre/postfixes, uabbr, and the arguments passed from frame. -- The optional filter parameter allows quantities to be be filtered by unit Qid. ------------------------------------------------------------------------------- -- Dependencies: parseParam; labelOrId; i18n[]; dateFormat; -- roundto; decimalPrecision; decimalToDMS; linkedItem; ------------------------------------------------------------------------------- local rendersnak = function(propval, args, linked, lpre, lpost, pre, post, uabbr, filter) lpre = lpre or "" lpost = lpost or "" pre = pre or "" post = post or "" args.lang = args.lang or findLang.code -- allow values to display a fixed text instead of label local dtxt = args.displaytext or args.dt if dtxt "" then dtxt nil end -- switch to use display of short name (P1813) instead of label local shortname args.shortname or args.sn shortname parseParam(shortname, false) local snak propval.mainsnak or propval local dtype snak.datatype local dv snak.datavalue dv dv and dv.value -- value and monolingual text language code returned local val, mlt if propval.rank and not args.reqranks[propval.rank:sub(1, 1)] then -- val is nil: value has a rank that isn't requested ------------------------------------ elseif snak.snaktype "somevalue" then -- value is unknown val = i18n["Unknown"] ------------------------------------ elseif snak.snaktype "novalue" then -- value is none -- val "No value" -- don't return anything ------------------------------------ elseif dtype "wikibase-item" then -- data type is a wikibase item: -- it's wiki-linked value, so output as link if enabled and possible local qnumber = dv.id if linked then val = linkedItem(qnumber, args) else -- no link wanted so check for display-text, otherwise test for lang code local label, islabel if dtxt then label = dtxt else label, islabel = labelOrId(qnumber) local langlabel = mw.wikibase.getLabelByLang(qnumber, args.lang) if langlabel then label = mw.text.nowiki( langlabel ) end end val = pre .. label .. post end -- test for link required ------------------------------------ elseif dtype "time" then -- data type is time: -- time is in timestamp format -- date precision is integer per mediawiki -- output formatting according to preferences (y/dmy/mdy) -- BC format as BC or BCE -- plaindate is passed to disable looking for "sourcing cirumstances" -- or to set the adjectival form -- qualifiers (if any) is a nested table or nil -- lang is given, or user language, or site language -- -- Here we can check whether args.df has a value -- If not, use code from Module:Sandbox/RexxS/Getdateformat to set it from templates like val dateFormat(dv.time, dv.precision, args.df, args.bc, args.pd, propval.qualifiers, args.lang, "", dv.calendarmodel) ------------------------------------ -- data types which are strings: elseif dtype "commonsMedia" or dtype "external-id" or dtype "string" or dtype "url" then -- commonsMedia or external-id or string or url -- all have mainsnak.datavalue.value as string if (lpre "" or lpre ":") and lpost "" then -- don't link if no linkpre/postfix or linkprefix is just ":" val = pre .. dv .. post elseif dtype "external-id" then val "[" .. lpre .. dv .. lpost .. " " .. pre .. dv .. post .. "]" else val "" .. pre .. dv .. post .. "" end -- check for link requested (i.e. either linkprefix or linkpostfix exists) ------------------------------------ -- data types which are quantities: elseif dtype "quantity" then -- quantities have mainsnak.datavalue.value.amount and mainsnak.datavalue.value.unit -- the unit is of the form http://www.wikidata.org/entity/Q829073 -- -- implement a switch to turn on/off numerical formatting later local fnum = true -- -- a switch to turn on/off conversions - only for en-wiki local conv = parseParam(args.conv or args.convert, false) -- if we have conversions, we won't have formatted numbers or scales if conv then uabbr = true fnum = false args.scale = "0" end -- -- a switch to turn on/off showing units, default is true local showunits = parseParam(args.su or args.showunits, true) -- -- convert amount to a number local amount = tonumber(dv.amount) or i18n["NaN"] -- -- scale factor for millions, billions, etc. local sc = tostring(args.scale or ""):sub(1,1):lower local scale if sc == "a" then -- automatic scaling if amount > 1e15 then scale = 12 elseif amount > 1e12 then scale = 9 elseif amount > 1e9 then scale = 6 elseif amount > 1e6 then scale = 3 else scale = 0 end else scale = tonumber(args.scale) or 0 if scale before . and / local disp, n = addr:gsub( "^([^/]+)/$", "%1" ):gsub("%/", "/"):gsub("%.", ".") return '" .. icon end ------------------------------------------------------------------------------- -- getWebsite fetches the Official website (P856) and formats it for use in an infobox. -- This is similar to Template:Official website but with a url displayed, -- and it adds the "edit at Wikidata" pen icon beyond the microformat if enabled. -- A local value will override the Wikidata value. "NONE" returns nothing. -- e.g. ------------------------------------------------------------------------------- -- Dependencies: findLang; parseParam; ------------------------------------------------------------------------------- p.getWebsite = function(frame) local url = frame.args.url or "" if url:upper "NONE" then return nil end local urls {} local quals {} local qid frame.args.qid or "" if url and url ~ "" then urls[1] url else if qid "" then qid = mw.wikibase.getEntityIdForCurrentPage end if not qid then return nil end local prop856 = mw.wikibase.getBestStatements(qid, "P856") for k, v in pairs(prop856) do if v.mainsnak.snaktype "value" then urls[#urls+1] v.mainsnak.datavalue.value if v.qualifiers and v.qualifiers["P1065"] then -- just take the first archive url (P1065) local au v.qualifiers["P1065"][1] if au.snaktype "value" then quals[#urls] = au.datavalue.value end -- test for archive url having a value end -- test for qualifers end -- test for website having a value end -- loop through website(s) end if #urls 0 then return nil end local out {} for i, u in ipairs(urls) do local link quals or u local prot, addr u:match("(http*://)(.+)") addr addr or u local disp, n addr:gsub("%.", "%.") out[#out+1] '" end local langcode findLang(frame.args.lang).code local noicon parseParam(frame.args.noicon, false) if url "" and not noicon then out[#out] = out[#out] .. createicon(langcode, qid, "P856") end local ret = "" if #out > 1 then ret = mw.getCurrentFrame:expandTemplate{title = "ubl", args = out} else ret = out[1] end return ret end ------------------------------------------------------------------------------- -- getAllLabels fetches the set of labels and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllLabels = function(frame) local args = frame.args or frame:getParent.args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local labels = mw.wikibase.getEntity(qid).labels if not labels then return i18n["labels-not-found"] end local out = {} for k, v in pairs(labels) do out[#out+1] = v.value .. " (" .. v.language .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- getAllDescriptions fetches the set of descriptions and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllDescriptions = function(frame) local args = frame.args or frame:getParent.args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local descriptions = mw.wikibase.getEntity(qid).descriptions if not descriptions then return i18n["descriptions-not-found"] end local out = {} for k, v in pairs(descriptions) do out[#out+1] = v.value .. " (" .. v.language .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- getAllAliases fetches the set of aliases and formats it for display as wikitext. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllAliases = function(frame) local args = frame.args or frame:getParent.args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local aliases = mw.wikibase.getEntity(qid).aliases if not aliases then return i18n["aliases-not-found"] end local out = {} for k1, v1 in pairs(aliases) do local lang = v1[1].language local val = {} for k1, v2 in ipairs(v1) do val[#val+1] = v2.value end out[#out+1] = table.concat(val, ", ") .. " (" .. lang .. ")" end return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- showNoLinks displays the article titles that should not be linked. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.showNoLinks = function(frame) local out = {} for k, v in pairs(donotlink) do out[#out+1] = k end table.sort( out ) return table.concat(out, "; ") end ------------------------------------------------------------------------------- -- checkValidity checks whether the first unnamed parameter represents a valid entity-id, -- that is, something like Q1235 or P123. -- It returns the strings "true" or "false". -- Change false to nil to return "true" or "" (easier to test with #if:). ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- function p.checkValidity(frame) local id = mw.text.trim(frame.args[1] or "") if mw.wikibase.isValidEntityId(id) then return true else return false end end ------------------------------------------------------------------------------- -- getEntityFromTitle returns the Entity-ID (Q-number) for a given title. -- Modification of Module:ResolveEntityId -- The title is the first unnamed parameter. -- The site parameter determines the site/language for the title. Defaults to current wiki. -- The showdab parameter determines whether dab pages should return the Q-number or nil. Defaults to true. -- Returns the Q-number or nil if it does not exist. ------------------------------------------------------------------------------- -- Dependencies: parseParam ------------------------------------------------------------------------------- function p.getEntityFromTitle(frame) local args=frame.args if not args[1] then args=frame:getParent.args end if not args[1] then return nil end local title = mw.text.trim(args[1]) local site = args.site or "" local showdab = parseParam(args.showdab, true) local qid = mw.wikibase.getEntityIdForTitle(title, site) if qid then local prop31 = mw.wikibase.getBestStatements(qid, "P31")[1] if not showdab and prop31 and prop31.mainsnak.datavalue.value.id == "Q4167410" then return nil else return qid end end end --general function to get value given an entity and property function p.getVal(entity, propertyID, linked, separator, return_val) local claims if separator nil then separator ", " end if return_val nil then return_val = "" end if entity and entity.claims then claims = entity.claims[propertyID] end if claims then -- if wiki-linked value output as link if possible if (claims[1] and claims[1].mainsnak.snaktype "value" and claims[1].mainsnak.datavalue.type "wikibase-entityid") then local out = {} for k, v in pairs(claims) do local item_id = "Q" .. v.mainsnak.datavalue.value["numeric-id"] local label = mw.wikibase.label(item_id) local datav = mw.wikibase.getSitelink(item_id, 'trwiki') if datav nil then datav label if datav nil then datav = "" end end -- bağlantı ekle if linked ~= nil then if datav ~= "" then if label == datav then datav = .. datav .. else datav = .. label .. end end end out[#out + 1] = datav end return table.concat(out, separator) else -- just return best values return entity:formatPropertyValues(propertyID).value end else return return_val end end p.getDeathAge = function(frame) local entity = mw.wikibase.getEntityObject local birth = entity.claims['P569'][1]['mainsnak']['datavalue']['value']['time'] local death = entity.claims['P570'][1]['mainsnak']['datavalue']['value']['time'] return frame:expandTemplate{ title = 'Ölüm tarihi ve yaşı', args = { ["1"] = string.sub(death, 2, 5), ["2"] = string.sub(death, 7, 8), ["3"] = string.sub(death, 10, 11), ["4"] = string.sub(birth, 2, 5), ["5"] = string.sub(birth, 7, 8), ["6"] = string.sub(birth, 10, 11) } } end p.getHeight = function(frame) local entity = mw.wikibase.getEntityObject if entity ~= nil then if entity.claims ~= nil then local bb = entity.claims['P2048'] if bb ~= nil then local b = bb[1]['mainsnak']['datavalue']['value']['amount'] local unit = bb[1]['mainsnak']['datavalue']['value']['unit'] local unit_item = string.match(unit, "%d+") b = string.sub(b, 2) -- santimetre: Q174728 -- metre: Q11573 -- inç: Q218593 -- ayak: Q3710 if unit_item "174728" then b b / 100 elseif unit_item "218593" then b = string.format("%.0f", (b * 2.54)) b = b / 100 elseif unit_item == "3710" then b = string.format("%.0f", (b * 12 * 2.54)) b = b / 100 end b = string.gsub(b, '%.', ',') return frame:expandTemplate{ title = 'Dönüştürme', args = { ["1"] = b, ["2"] = "m", ["3"] = "ftin", ["abbr"] = "on" } } .. "Kategori:Boyu Vikiveri'den çekilen kişiler" end end end end ------------------------------------------------------------------------------- -- getDatePrecision returns the number representing the precision of the first best date value -- for the given property. -- It takes the qid and property ID -- The meanings are given at https://www.mediawiki.org/wiki/Wikibase/DataModel#Dates_and_times -- 0 = 1 billion years .. 6 = millennium, 7 = century, 8 = decade, 9 = year, 10 = month, 11 = day -- Returns 0 (or the second unnamed parameter) if the Wikidata does not exist. ------------------------------------------------------------------------------- -- Dependencies: parseParam; sourced; ------------------------------------------------------------------------------- function p.getDatePrecision(frame) local args=frame.args if not args[1] then args=frame:getParent.args end local default = tonumber(args[2] or args.default) or 0 local prop = mw.text.trim(args[1] or "") if prop "" then return default end local qid args.qid or "" if qid "" then qid = mw.wikibase.getEntityIdForCurrentPage end if not qid then return default end local onlysrc = parseParam(args.onlysourced or args.osd, true) local stat = mw.wikibase.getBestStatements(qid, prop) for i, v in ipairs(stat) do local prec = (onlysrc == false or sourced(v)) and v.mainsnak.datavalue and v.mainsnak.datavalue.value and v.mainsnak.datavalue.value.precision if prec then return prec end end return default end return p ------------------------------------------------------------------------------- -- List of exported functions ------------------------------------------------------------------------------- --getValue getValue getPreferredValue getCoords getQualifierValue getSumOfParts getValueByQual getValueByLang getValueByRefSource getPropertyIDs getQualifierIDs getPropOfProp getAwardCat getIntersectCat getGlobe getCommonsLink getSiteLink getLink getLabel label getAT getDescription getAliases pageId formatDate location checkBlacklist emptyor labelorid getLang getItemLangCode findLanguage getQID followQid globalSiteID siteID projID formatNumber examine checkvalue url2 getWebsite getAllLabels getAllDescriptions getAllAliases showNoLinks checkValidity getEntityFromTitle getDatePrecision -- -------------------------------------------------------------------------------
 

Tema özelleştirme sistemi

Bu menüden forum temasının bazı alanlarını kendinize özel olarak düzenleye bilirsiniz.

Zevkine göre renk kombinasyonunu belirle

Tam ekran yada dar ekran

Temanızın gövde büyüklüğünü sevkiniz, ihtiyacınıza göre dar yada geniş olarak kulana bilirsiniz.

Izgara yada normal mod

Temanızda forum listeleme yapısını ızgara yapısında yada normal yapıda listemek için kullanabilirsiniz.

Forum arkaplan resimleri

Forum arkaplanlarına eklenmiş olan resimlerinin kontrolü senin elinde, resimleri aç/kapat

Sidebar blogunu kapat/aç

Forumun kalabalığında kurtulmak için sidebar (kenar çubuğunu) açıp/kapatarak gereksiz kalabalıklardan kurtula bilirsiniz.

Yapışkan sidebar kapat/aç

Yapışkan sidebar ile sidebar alanını daha hızlı ve verimli kullanabilirsiniz.

Radius aç/kapat

Blok köşelerinde bulunan kıvrımları kapat/aç bu şekilde tarzını yansıt.

Foruma hoş geldin 👋, Ziyaretçi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.

Geri