Jump to content

Extension:TemplateData/ko

From mediawiki.org
This page is a translated version of the page Extension:TemplateData and the translation is 28% complete.
이 확장 기능은 미디어위키 1.35 이상에서 포함됩니다. 따라서 다시 다운로드하지 않아도 됩니다. 하지만 여전히 제공되는 별개의 지침을 따라야 합니다.
미디어위키 확장 기능 설명서
TemplateData
출시 상태: 안정
구현 태그 , API
설명 Allows to store, retrieve and visualise information about templates
만든 이 Timo Tijhof, Moriel Schottlender, James Forrester, Trevor Parscal, Bartosz Dziewoński, Marielle Volz, ...
최신 버전 0.1.2 (지속적인 업데이트)
호환성 정책 스냅샷은 미디어위키와 함께 릴리스됩니다. Master is not backward compatible.
MediaWiki >= 1.43
PHP 5.4+
데이터베이스 변경 아니오
라이선스 GNU General Public License 2.0 or later
다운로드
  • $wgTemplateDataUseGUI
‎<templatedata>
Quarterly downloads 306 (Ranked 14th)
Public wikis using 6,971 (Ranked 24th)
TemplateData 확장 기능 번역 (translatewiki.net에서 가능한 경우)
이슈 미해결 작업 · 버그 보고

The TemplateData extension introduces a ‎<templatedata> tag and an API which together allow editors to specify how templates and their parameters should be used. This information is available as a nicely-formatted table for end-users, and as a JSON API, which enables other systems (e.g. VisualEditor ) to build interfaces for working with templates. See Help:TemplateData for in-depth help.

설치

  • 파일을 다운로드하고 TemplateData 폴더를 extensions/ 디렉토리에 넣어 주세요.
    개발자와 코딩 기여자는 Git을 이용해 확장기능을 다운받는 것이 좋습니다.cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
  • 아래의 코드를 LocalSettings.php 코드의 마지막에 추가합니다.
    wfLoadExtension( 'TemplateData' );
    
  • Yes 완료 – 위키의 ‘Special:Version’에 이동해서, 확장기능이 올바르게 설치된 것을 확인합니다.

데이터 편집하기

틀데이터 확장 프로그램은 틀 문서의 내용에서 정의된 ‎<templatedata> 태그를 통해 작동합니다. (선택적으로 다른 페이지에서도 변환 할 수 있습니다). This is designed to be compatible with the common layout many wikis have of transcluding template documentation from a separate page (but is not required). This content of the ‎<templatedata> tag must be valid JSON using the format described below; note that all descriptions must be in plain text (no wikitext is accepted inside the template data).

틀 데이터 확장기능은 ‎<templatedata> 블록이 틀 문서에 포함되어 저장될 때 다음과 같은 검사를 수행합니다:

  1. 내용은 유효한 JSON이어야 합니다.
  2. JSON 구조의 각 항목은 아래와 같이 정해진 자료의 유형 (예: 객체, 배열 또는 원시) 이어야 합니다.
  1. For those items which have a specified list of possible values (e.g. the type of a parameter), the value in the JSON object must match one of those values.

이 중 어떤 검사 중 하나라도 실패하면 서버는 저장할 수 없으며 편집 창 위에 에러 메시지가 표시됩니다.

For autovalue items, T4700 prevents subst: from working in any template that is added inside a tag, including ‎<ref> and ‎<gallery> tags. 틀 데이터 블록은 올바르게 저장되지만, 생성된 위키텍스트는 틀이 사용되면 올바르게 파서되지 않습니다.

Please avoid using {{#tag:templatedata}} as it makes it impossible to use the template data editor.

형식

The below is a visualised version of the JSON data as defined on the template page enclosed by ‎<templatedata>‎</templatedata> tags. The formal specification is available in the TemplateData repository. Refer to Specification.md for the latest version.

TemplateData object

The TemplateData object is a JSON root element enclosed in a ‎<templatedata> element on the template page.

타입 설명
description InterfaceText이나 null 틀의 간단한 설명 일반 텍스트여야 합니다. 일단 작성되면 하나의 틀을 편집할 때 캡션으로 표시될 수 있고 사용자가 많은 틀 중 하나를 선택할 때 검색 결과에서 표시될 수도 있습니다. 기본값은 null.

→ For more details see: description

params 변수 객체를 포함하는 객체 An object that maps each parameter name of the template to a corresponding Param object describing the properties of that parameter.

→ For more details see: params

paramOrder 변수 이름을 나타내는 문자열을 포함하는 배열 변수를 표시되는 논리적 순서. The array contains each parameter key exactly once. Each string must be a valid key in the params object.

→ For more details see: paramOrder

sets Array containing
Set objects
An array containing set specifications. A set is a group of parameters that should be used together. 기본값은 [] Note that the sets functionality is still in development.
format 문자열, inline 또는 block How the template's wikitext representation SHOULD be laid out. 기본값은 inline. See #Custom_formats for other custom formats.
maps Object containing Map objects An object that links a simplified name of a third party consumer of the template data (i.e. Citoid, Special:MyLanguage/Wikidata, etc.) to a map object that in turn links a name of a consumer parameter to one or more corresponding names of template parameters.

변수 객체

타입 기본값 Description
label InterfaceText null 변수에 대한 간단한 이름 적당한 숫자의 문자를 넣어주셔야 합니다.

→ For more details see: label

description InterfaceText null 옵션 목록에서 어느 것을 선택해야 하는지, 변수에 대한 간단한 설명.

→ For more details see: description

required boolean false Whether the parameter is required for the template to work (true if this parameter must be specified).

→ For more details see: required

suggested 부울값 false Whether the parameter is suggested for the template to be useful (true if this parameter should be specified).

→ For more details see: suggested

deprecated 부울값이나 문자열 false 쓰이지 않는 매개 변수인지 값은 사용자에게 무엇을 할 수 있는지 안내하는 일련의 명령일 수도 있고, 단순히 true 일 수도 있습니다.

→ For more details see: deprecated

aliases 문자열을 포함하는 배열 [] 별명 목록 An alias is an alternative name for the parameter that may be used instead of (not in addition to) the primary name. Aliases are not documented in a separate Parameter object. If they need more information, they should be in their own property marked "deprecated".

→ For more details see: aliases

default InterfaceText null A fixed default value used by the template if no value is assigned to the parameter, or a description thereof.

→ For more details see: default

autovalue 문자열 null A dynamically-generated default value in wikitext, such as today's date or the editing user's name; this will often involve wikitext substitution, such as {{subst:CURRENTYEAR}}.

→ For more details see: autovalue

example InterfaceText null An example text for the parameter, to help users fill in the proper value.

→ For more details see: example

type string "unknown" The type of the parameter, for (soft) type hinting. One of:
문자열 값 Type of Parameter
"unknown" Assumed type if not set

→ For more details see: value ‘unknown’

"number" Any numerical value (without decimal points or thousand separators)

→ For more details see: value ‘number’

"string" Any textual value. May contain line breaks.

→ For more details see: value ‘string’

"line" Short text field – use for names, labels, and other short-form fields. This is supposed to be text that is not expected to contain line breaks.

→ For more details see: value ‘line’

"boolean" A boolean value ('1' for true, '0' for false, '' for unknown), see three-valued logic.

→ For more details see: value ‘boolean’

"date" A date in ISO 8601 format, e.g. "2014-05-09" or "2014-05-09T16:01:12Z"

→ For more details see: value ‘date’

"url" A URL, including protocol, e.g. "http://www.example.org", "https://example.org", or "//example.org".

→ For more details see: value ‘url’

"wiki-page-name" 현재 위키의 유효한 문서의 이름 Doesn't have to exist, but if not, should be a valid page name which could be created.

→ For more details see: value ‘wiki-page-name’

"wiki-file-name" A valid MediaWiki file name for the current wiki. Doesn't have to exist, but if not, should be a valid file name which could be uploaded. Should not include the namespace (e.g. "Foo.svg" not "File:Foo.svg" or "Bild:Foo.svg").

→ For more details see: value ‘wiki-file-name’

"wiki-template-name" A valid MediaWiki Template name for the current wiki.

→ For more details see: value ‘wiki-template-name’

"wiki-user-name" A valid MediaWiki user name for the current wiki. Doesn't have to exist, but if not, should be a valid user name which could be created. Should not include the namespace (e.g. "Foo" not "User:Foo" or "Usario:Foo").

→ For more details see: value ‘wiki-user-name’

"content" Page content in wikitext, such as text style, links, images, etc.

→ For more details see: value ‘content’

"unbalanced-wikitext" Raw wikitext that should not be treated as standalone content because it is unbalanced – for example, templates concatenating incomplete wikitext as a bigger whole, such as {{echo|before=<u>|after=</u>}}

→ For more details see: value ‘unbalanced-wikitext’

→ For more details see: type

inherits string none
substituted
The name key of another parameter (must be a valid key in the params object). The current Parameter Object will inherit properties from the specified Parameter Object, with local properties overriding the inherited ones.

→ For more details see: inherits

suggestedvalues Array containing strings [] An optional parameter property. Creates a list of parameter values to help users select the desired value. For the suggested values to be displayed as a combo box in VisualEditor, the parameter’s type must be set to one of the following: content, line, string, number, unknown or unbalanced wikitext.

→ For more details see: suggestedvalues

Set object

Object or primitive type

설명

label InterfaceText A (very) brief name for the parameter set. Try to keep under 20-ish characters.
params Array of strings One or more names of parameters to include in the set (each must be a valid key in the params object). A parameter may be in multiple sets. Not every parameter must be in a set.

Maps structure

Maps is a single data structure that goes multiple levels deep. It became common to call the second level a “map object”.

Type Default Description
name of consumer object {} An object that links a name of a consumer to a map object that in turn links a name of a consumer parameter to one or more corresponding names of template parameters.

The names of the template parameters can be specified either as a string (one name), an array of strings (several names), or an array of arrays of strings (several sets of names); each of these strings must be a valid key in the params object elsewhere in the same template's TemplateData.

A specific template parameter may be in multiple maps, and it may be used in the values of multiple keys in a given map, but not every template parameter must be in a map.

A shortened example from English Wikipedia's Template:Cite_news#TemplateData illustrates the structure of map objects.

{
	"proveit": {
		"main": "title",
		"textarea": [
			"quote"
		]
	},
	"citoid": {
		"title": "title",
		"url": "url",
		"publisher": "publisher",
		"publicationTitle": "work",
		"date": "date",
		"ISSN": [
			"issn"
		],
		"ISBN": [
			"isbn"
		],
		"contributor": "others",
		"author": [
			[
				"first",
				"last"
			],
			[
				"first2",
				"last2"
			],
			[
				"first9",
				"last9"
			]
		],
		"editor": [
			[
				"editor-first",
				"editor-last"
			]
		]
	}
}

InterfaceText (string or object)

A free-form plain-text string (i.e. no wikitext or HTML) in the content-language of the wiki, or an object containing those strings keyed by language code.

The default value for all InterfaceText fields is null.

String type

If it is a string, it must contain a non-localized string in the content language of the local wiki.

Object type

If it is an object, the object must have this mapping:

Key Type Description
위키피디아의 언어 코드 문자열 Localized string for users of that interface language.

Example of object mapping:

Value
"en" "Welcome to Wikipedia"
"de" "Willkommen bei Wikipedia"
"fr" "Bienvenue sur Wikipédia"
"nl" "Welkom op Wikipedia"
"it" "Benvenuti su Wikipedia"
"es" "Bienvenidos a Wikipedia"
"ru" "Добро пожаловать в Википедию"

Example

An example TemplateData structure as specified within wikitext on a template page.

<templatedata>
{
    "description": "Label unsigned comments in a conversation.",
    "params": {
        "user": {
            "label": "User's name",
            "type": "wiki-user-name",
            "required": true,
            "description": "User name of person who forgot to sign their comment.",
            "aliases": ["1"]
        },
        "date": {
            "label": "Date",
            "suggested": true,
            "description": {
                "en": "Timestamp of when the comment was posted, in YYYY-MM-DD format."
            },
            "aliases": ["2"],
            "autovalue": "{{subst:#time:Y-m-d}}"
        },
        "year": {
            "label": "Year",
            "type": "number"
        },
        "month": {
            "label": "Month",
            "inherits": "year"
        },
        "day": {
            "label": "Day",
            "inherits": "year"
        },
        "comment": {
            "required": false
        }
    },
    "sets": [
        {
            "label": "Date",
            "params": ["year", "month", "day"]
        }
    ],
    "maps": {
        "ExampleConsumer": {
            "foo": "user",
            "bar": ["year", "month", "day"],
            "quux": [
                "date",
                ["day", "month"],
                ["month", "year"],
                "year"
            ]
        }
    }
}
</templatedata>

Below is how the above example would be displayed on the template page:

Label unsigned comments in a conversation.

Template parameters

ParameterDescriptionTypeStatus
User's nameuser 1

User name of person who forgot to sign their comment.

Userrequired
Datedate 2

Timestamp of when the comment was posted, in YYYY-MM-DD format.

Auto value
{{subst:#time:Y-m-d}}
Unknownsuggested
Yearyear

no description

Numberoptional
Monthmonth

no description

Numberoptional
Dayday

no description

Numberoptional
commentcomment

no description

Unknownoptional

API

See the generated help at Special:ApiHelp/templatedata. A sample invocation (formatted for human readability) is:

This returns the template data for Template:Cite web. The ‎<templatedata>...‎</templatedata> block for this template is on its transcluded template documentation page, en:Template:Cite web/doc.

Additions and changes to JSON as received from the API

The JSON structure provided in response to an API HTTP get request is significantly different than that which is defined in the ‎<templatedata>...‎</templatedata> block. In response to the API request, extension TemplateData makes the following changes to the JSON object:

    1. Add the title key with the name of the page from which the data was requested (e.g. "Template:Cite web").
    2. Add the sets key
    3. Change all TemplateText occurrences that are just strings to objects with a single key for the current wiki's Wikipedia language code
    4. Remove all inherits keys.
      • Add all properties from parameter from which an inheritance is defined which are not superseded by explicitly defined keys in the inheritor's Parameter Object.
    5. Add default values for all keys in each Parameter Object which have not been explicitly defined or inherited.

Visualised differences in a TemplateData JSON object delivered by the API

Wrapper objects added to JSON delivered by API
These are not defined in the JSON object enclosed by the ‎<templatedata> tags on the template page.
JSON Root
Type 설명
pages Page Object The Page object (contains one key which is the page number). If multiple pages were requested at one time there will be multiple Page Objects.

Page Object
Type Description
{{{1}}} TemplateData Object The TemplateData Object containing the information payload. 키는 JSON 데이터를 요청한 틀 문서의 정적 페이지 고유 번호입니다.
틀 데이터 객체 (API에 의해 추가된)
The following key is added to the root of the JSON object which is enclosed in ‎<templatedata> tags on the template page.
Type Description
title string The page name of the template (e.g. "Template:Cite web").
This key is not contained in the JSON structure on the template page. It is added to the structure by the MediaWiki software in route to delivery via the API.
sets Array containing Set Objects An array containing set specifications. A set is a group of parameters that should be used together.
If this does not exist on the template page it is added as an empty array to the structure provided by the API.
Parameter Objects from API
Type Description
label InterfaceText translated to InterfaceText object, if not already in that format.
required 부울값 정의되지 않았다면 기본값 false이 추가됩니다.
description InterfaceText or null If defined as a string, converted to a InterfaceText object. 정의되지 않았다면 null이 키로 추가됩니다.
deprecated 부울값이나 문자열 정의되지 않았다면 기본값 false이 추가됩니다.
aliases 문자열의 배열 정의되지 않으면 기본 빈 배열이 지정됩니다. (즉 [])
default 문자열 If not defined, default of "" is assigned.
type 문자열 정의되지 않았다면 기본값 "unknown"이 지정됩니다.
inherits (removed) This key is removed and all inherited keys are added. Keys defined for the current parameter take precedence and any keys not defined on either the current param, or the one from which it inherits are given the default value.
InterfaceText (Object or null):
An object containing strings keyed by language code.
Object or
primitive type
Description
Object
(containing localized strings by Wikipedia language code)
If a TemplateData field on the template page contains a string, not an object with localized strings, MediaWiki translates it into an InterfaceText Object with a string assigned to the key name of the source Wikipedia Wikipedia language code. The default for all InterfaceText fields is null.
(Wiki language code) string Localized string for users of that interface language.

Example of JSON object provided by API

The response to an API request for the TemplateData structure in the Example section (above) can be seen:

Configuration

변수 기본값 설명
$wgTemplateDataUseGUI true Experimental dialog interface to edit templatedata JSON

관련 항목