Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:SDcat

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
WarningThis Lua module is used onapproximately 6,520,000 pages, or roughly 10% of all pages.
To avoid major disruption and server load, any changes should be tested in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on thetalk page before implementing them.
This module can only be edited byadministrators because it istranscluded onto one or morecascade-protected pages.

Module to check whether local short description matches that on Wikidata

setCat has the qid of a Wikidata entity passed as |qid=(it defaults to the associated qid of the current article if omitted)and the local short description passed as |sd=It returns a category if there is an associated Wikidata entity.

It returns one of the following tracking categories, as appropriate:

  • Category:Short description matches Wikidata (case-insensitive)
  • Category:Short description is different from Wikidata
  • Category:Short description with empty Wikidata description

For testing purposes, a link prefix |lp= may be set to ":" to make the categories visible.

Usage

From within a template
{{SDcat |sd={{{shortdescription|}}} }}
or
{{#invoke:SDcat |setCat |sd={{{shortdescription|}}} }}

Template:SDcat is a wrapper for this module.

From another module
sdcat = require("Module:SDcat")._setCat
local tracking_cat = sdcat(shortdesc, itemID)

For testing

{{#invoke:SDcat |setCat |qid={{get QID|Douglas Adams}}|sd=English author and humorist (1952–2001) |lp=":"}}

A few examples of tests are atModule talk:SDcat

The abovedocumentation istranscluded fromModule:SDcat/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

--[[SDcatModule to check whether local short description matches that on Wikidata--]]localp={}---------------------------------------------------------------------------------[[setCat has the qid of a Wikidata entity passed as |qid=(it defaults to the associated qid of the current article if omitted)and the local short description passed as |sd=It returns a category if there is an associated Wikidata entity.It returns one of the following tracking categories, as appropriate:* Category:Short description matches Wikidata (case-insensitive)* Category:Short description is different from Wikidata* Category:Short description with empty Wikidata descriptionFor testing purposes, a link prefix |lp= may be set to ":" to make the categories visible.--]]-- function exported for use in other modules-- (local short description, Wikidata entity-ID, link prefix)p._setCat=function(sdesc,itemID,lp)ifnotmw.wikibasethenreturnnilendifitemID==""thenitemID=nilend-- Wikidata description fieldlocalwdesc=(mw.wikibase.getDescription(itemID)or""):lower()ifwdesc==""thenreturn"[["..lp.."Category:Short description with empty Wikidata description]]"elseifwdesc==sdescthenreturn"[["..lp.."Category:Short description matches Wikidata]]"elsereturn"[["..lp.."Category:Short description is different from Wikidata]]"endend-- function exported for call from #invokep.setCat=function(frame)localargsifframe.args.sdthenargs=frame.argselseargs=frame:getParent().argsend-- local short descriptionlocalsdesc=mw.text.trim(args.sdor""):lower()-- Wikidata entity-IDlocalitemID=mw.text.trim(args.qidor"")-- link prefix, strip quoteslocallp=mw.text.trim(args.lpor""):gsub('"','')returnp._setCat(sdesc,itemID,lp)endreturnp
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:SDcat&oldid=1208339511"
Category:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp