From 7378ac37e98b5bfcf4594104104e4b39269a5327 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Thu, 12 May 2022 23:07:05 +0900 Subject: [PATCH 01/14] Remove {{CSSTutorialTOC}} --- files/ko/learn/css/howto/generated_content/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/files/ko/learn/css/howto/generated_content/index.html b/files/ko/learn/css/howto/generated_content/index.html index 216305f889527a..c9771c3fd58438 100644 --- a/files/ko/learn/css/howto/generated_content/index.html +++ b/files/ko/learn/css/howto/generated_content/index.html @@ -3,7 +3,6 @@ slug: Learn/CSS/Howto/Generated_content translation_of: Learn/CSS/Howto/Generated_content --- -

{{ CSSTutorialTOC() }}

중요: 번역은 제가 필요한 부분 및 확인 가능한 부분만 진행 하였으며 변역된 날자는(2013/03/18)이며 문서 변경이 잦아 오늘 이후는 원문과 번역이 다를 수 있습니다. 참고하세요. 미 번역/변경된 부분은 추가로 다른 분이 해 주실 것으로 믿습니다.

{{ previousPage("/en-US/docs/CSS/Getting_Started/Color", "색상") }}CSS 시작하기 안내서 9번째 장; 이번에는 CSS에서Document에 표시될 내용물을 추가 하는 방법을 알아보자. stylesheet를 수정해서 텍스트 내용과 이미지를 수정해 보자.

From 009f8bc970f3ba82c5313a5b5ab5ee8121f91047 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Thu, 12 May 2022 23:08:09 +0900 Subject: [PATCH 02/14] Remove {{DOM0}} --- files/ko/web/api/document/alinkcolor/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/files/ko/web/api/document/alinkcolor/index.html b/files/ko/web/api/document/alinkcolor/index.html index 9cbfe4a0e152fe..4f65626177a19d 100644 --- a/files/ko/web/api/document/alinkcolor/index.html +++ b/files/ko/web/api/document/alinkcolor/index.html @@ -21,6 +21,5 @@

Notes

Another alternative is document.body.aLink, although this is deprecated in HTML 4.01 in favor of the CSS alternative.

Gecko supports both alinkColor/:active and {{ Cssxref(":focus") }}. Internet Explorer 6 and 7 support alinkColor/:active only for HTML anchor (<a>) links and the behavior is the same as :focus under Gecko. There is no support for :focus in IE.

Specification

-

{{ DOM0() }}

MSDN: alinkColor property

{{ languages( { "es": "es/DOM/document.alinkColor", "pl": "pl/DOM/document.alinkColor" } ) }}

From 89a48b78056fe43f2ce1aa21dddd595ec1cab6c0 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Thu, 12 May 2022 23:09:02 +0900 Subject: [PATCH 03/14] Remove {{DiscussionList}} --- files/ko/glossary/dhtml/index.html | 5 ----- files/ko/web/mathml/index.html | 2 -- files/ko/web/xslt/index.html | 5 ----- 3 files changed, 12 deletions(-) diff --git a/files/ko/glossary/dhtml/index.html b/files/ko/glossary/dhtml/index.html index f729271ac6ce73..58afb1c615b767 100644 --- a/files/ko/glossary/dhtml/index.html +++ b/files/ko/glossary/dhtml/index.html @@ -21,11 +21,6 @@

Documentation

-

커뮤니티

-
  • Mozilla 포럼 보기... -
-

{{ DiscussionList("dev-ajax", "mozilla.dev.ajax") }} -

도구

diff --git a/files/ko/web/mathml/index.html b/files/ko/web/mathml/index.html index ffdb5bb22474b5..c0c351f6c71c21 100644 --- a/files/ko/web/mathml/index.html +++ b/files/ko/web/mathml/index.html @@ -30,8 +30,6 @@

MathML 레퍼

커뮤니티

    -
  • Mozilla 포럼보기...
    - {{ DiscussionList("dev-tech-mathml", "mozilla.dev.tech.mathml") }}
  • IRC 채널
  • Wiki used by Mozilla 공헌자 위키
  • W3C Math Home
  • diff --git a/files/ko/web/xslt/index.html b/files/ko/web/xslt/index.html index 9046e48c94e650..5b941a2a7b5e51 100644 --- a/files/ko/web/xslt/index.html +++ b/files/ko/web/xslt/index.html @@ -28,11 +28,6 @@

    문서

    -

    커뮤니티

    -
    • Mozilla 포럼 보기... -
    -

    {{ DiscussionList("dev-tech-xslt", "mozilla.dev.tech.xslt") }} -

    관련 주제

    XML, XPath
    From d79a3f2e61b11ecee16d90c9130b469e40afbb34 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Thu, 12 May 2022 23:09:53 +0900 Subject: [PATCH 04/14] Remove {{GlossaryList}} --- files/ko/glossary/index.html | 6 ------ 1 file changed, 6 deletions(-) diff --git a/files/ko/glossary/index.html b/files/ko/glossary/index.html index 4dbd0c6429808a..b11de2f32dd1d6 100644 --- a/files/ko/glossary/index.html +++ b/files/ko/glossary/index.html @@ -14,18 +14,12 @@ ---

    웹 기술은 문서화 및 코딩에 쓰이는 전문 용어와 약어 목록을 포함합니다. 이 용어 사전은 웹을 성공적으로 이해하고 구축하기 위해 알아야 할 단어와 약자의 정의를 제공합니다.

    -

    용어 사전

    - -

    {{GlossaryList({"split":"h3", "css":"multiColumnList"})}}

    -

    용어 사전에 기여하기

    용어 사전은 끝없이 진행 중인 작업입니다. 여러분은 새 항목을 작성하거나 기존 항목의 개선을 도울 수 있습니다. 가장 쉬운 시작법은 다음 버튼을 누르거나 아래에 제안된 용어 중 하나를 고르는 겁니다.

    용어 사전에 새 항목 추가하기

    -

    {{GlossaryList({"terms":[], "filter":"notdefined", "css":"multiColumnList"})}}

    -

    혹시 용어 사전에 기여하는 법에 관해 더 알고 싶다면, 용어 사전 문서화 상태 페이지를 확인하세요.

    정답 확인.

    다음에는?

    -

    {{ nextPage("/en-US/docs/CSS/Getting_Started/Lists", "리스트") }}Stylesheet에 내용물을 추가 하는 일반 방법으로 리스트로 표기하는 방법이 있다. 다음장에는 specify style for 리스트 elements를 위한 스타일 표기법에 대해 알아보자.

    +

    Stylesheet에 내용물을 추가 하는 일반 방법으로 리스트로 표기하는 방법이 있다. 다음장에는 specify style for 리스트 elements를 위한 스타일 표기법에 대해 알아보자.

    From e41acb878948ea81d9b483c7cc7d8a59362c45a6 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Thu, 12 May 2022 23:28:36 +0900 Subject: [PATCH 12/14] Remove {{previousPage}} --- files/ko/learn/css/howto/generated_content/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/ko/learn/css/howto/generated_content/index.html b/files/ko/learn/css/howto/generated_content/index.html index 2c2764e4d81f0d..1a76d24c7b8436 100644 --- a/files/ko/learn/css/howto/generated_content/index.html +++ b/files/ko/learn/css/howto/generated_content/index.html @@ -5,7 +5,7 @@ ---
    중요: 번역은 제가 필요한 부분 및 확인 가능한 부분만 진행 하였으며 변역된 날자는(2013/03/18)이며 문서 변경이 잦아 오늘 이후는 원문과 번역이 다를 수 있습니다. 참고하세요. 미 번역/변경된 부분은 추가로 다른 분이 해 주실 것으로 믿습니다.
    -

    {{ previousPage("/en-US/docs/CSS/Getting_Started/Color", "색상") }}CSS 시작하기 안내서 9번째 장; 이번에는 CSS에서Document에 표시될 내용물을 추가 하는 방법을 알아보자. stylesheet를 수정해서 텍스트 내용과 이미지를 수정해 보자.

    +

    CSS 시작하기 안내서 9번째 장; 이번에는 CSS에서Document에 표시될 내용물을 추가 하는 방법을 알아보자. stylesheet를 수정해서 텍스트 내용과 이미지를 수정해 보자.

    정보: 내용물

    CSS사용상의 가장 큰 장점은 document의 스타일과 내용물을 분리할 수 있도록 도와준다. 하지만 아직은 Document의 일부가 아니라 Stylesheet의 일부로서 존재해야 이치가 맞아 보이는 내용들도 있다.

    stylesheet에 놓여진 내용물(content)은 텍스트나 이미지로 구성될 수 있다. Document의 구조와 밀접하게 연결된 내용물(content)은 stylesheet에 명시 할수 있다.

    From 4ae4bd25c55cb47b80e852f43df7e702a0090906 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Thu, 12 May 2022 23:30:21 +0900 Subject: [PATCH 13/14] Remove {{wiki.localize}} --- files/ko/_redirects.txt | 2 -- files/ko/_wikihistory.json | 7 ------- files/ko/glossary/plugin/index.html | 8 -------- 3 files changed, 17 deletions(-) delete mode 100644 files/ko/glossary/plugin/index.html diff --git a/files/ko/_redirects.txt b/files/ko/_redirects.txt index 49e20eecd93aa9..7ad70a7f270a97 100644 --- a/files/ko/_redirects.txt +++ b/files/ko/_redirects.txt @@ -417,14 +417,12 @@ /ko/docs/Node_server_without_framework /ko/docs/Learn/Server-side/Node_server_without_framework /ko/docs/Notable_bugs_fixed_in_Firefox_3 /ko/docs/Mozilla/Firefox/Releases/3/Notable_bugs_fixed /ko/docs/Online_and_offline_events /ko/docs/Web/API/Navigator/onLine -/ko/docs/Plugins/Guide/Scripting_plugins /ko/docs/Glossary/Plugin /ko/docs/SVG /ko/docs/Web/SVG /ko/docs/SVG/Tutorial /ko/docs/Web/SVG/Tutorial /ko/docs/SVG:Tutorial /ko/docs/Web/SVG/Tutorial /ko/docs/SVG_In_HTML_Introduction /ko/docs/Web/SVG/Tutorial/SVG_In_HTML_Introduction /ko/docs/SVG_improvements_in_Firefox_3 /ko/docs/Mozilla/Firefox/Releases/3/SVG_improvements /ko/docs/SVG_in_Firefox /ko/docs/Web/SVG/SVG_1.1_Support_in_Firefox -/ko/docs/Scripting_Plugins /ko/docs/Glossary/Plugin /ko/docs/The_Importance_of_Correct_HTML_Commenting /ko/docs/Learn/HTML/Introduction_to_HTML/Getting_started#HTML_comments /ko/docs/The_XSLT_JavaScript_Interface_in_Gecko /ko/docs/Web/XSLT/XSLT_JS_interface_in_Gecko /ko/docs/The_XSLT_JavaScript_Interface_in_Gecko/Introduction /ko/docs/Web/XSLT/XSLT_JS_interface_in_Gecko/Introduction diff --git a/files/ko/_wikihistory.json b/files/ko/_wikihistory.json index 95a0fc8182d87a..1a7d2e8baa837a 100644 --- a/files/ko/_wikihistory.json +++ b/files/ko/_wikihistory.json @@ -721,13 +721,6 @@ "enfroze" ] }, - "Glossary/Plugin": { - "modified": "2019-01-16T15:11:14.478Z", - "contributors": [ - "teoli", - "Anonymous" - ] - }, "Glossary/Polyfill": { "modified": "2019-11-18T11:28:34.172Z", "contributors": [ diff --git a/files/ko/glossary/plugin/index.html b/files/ko/glossary/plugin/index.html deleted file mode 100644 index 921aafd7c903f1..00000000000000 --- a/files/ko/glossary/plugin/index.html +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Scripting Plugins -slug: Glossary/Plugin -translation_of: Plugins/Guide/Scripting_plugins -translation_of_original: Scripting_plugins -original_slug: Plugins/Guide/Scripting_plugins ---- -

    {{wiki.localize('System.API.page-generated-for-subpage')}}

    From d5faa71bc2afd9d74d41174228092fa879ca23c1 Mon Sep 17 00:00:00 2001 From: alattalatta Date: Thu, 12 May 2022 23:31:44 +0900 Subject: [PATCH 14/14] Remove unmaintained MDN/Tools --- files/ko/_redirects.txt | 3 - files/ko/_wikihistory.json | 26 - files/ko/mdn/tools/index.html | 16 - files/ko/mdn/tools/kumascript/index.html | 472 ------------------ .../kumascript/troubleshooting/index.html | 59 --- 5 files changed, 576 deletions(-) delete mode 100644 files/ko/mdn/tools/index.html delete mode 100644 files/ko/mdn/tools/kumascript/index.html delete mode 100644 files/ko/mdn/tools/kumascript/troubleshooting/index.html diff --git a/files/ko/_redirects.txt b/files/ko/_redirects.txt index 7ad70a7f270a97..05a8d55c7ae665 100644 --- a/files/ko/_redirects.txt +++ b/files/ko/_redirects.txt @@ -354,9 +354,6 @@ /ko/docs/MDN/Contribute/Structures/Compatibility_tables /ko/docs/MDN/Structures/Compatibility_tables /ko/docs/MDN/Contribute/Structures/Macros /ko/docs/MDN/Structures/Macros /ko/docs/MDN/Contribute/Structures/Macros/Commonly-used_macros /ko/docs/MDN/Structures/Macros/Commonly-used_macros -/ko/docs/MDN/Contribute/Tools /ko/docs/MDN/Tools -/ko/docs/MDN/Contribute/Tools/KumaScript /ko/docs/MDN/Tools/KumaScript -/ko/docs/MDN/Contribute/Tools/KumaScript/Troubleshooting /ko/docs/MDN/Tools/KumaScript/Troubleshooting /ko/docs/MDN/Getting_started /ko/docs/MDN/Contribute/Getting_started /ko/docs/MDN/Guidelines/Best_practices /ko/docs/MDN/Guidelines/Conventions_definitions /ko/docs/MDN/Guidelines/Code_guidelines/Code_guidelines /ko/docs/MDN/Guidelines/Code_guidelines/General diff --git a/files/ko/_wikihistory.json b/files/ko/_wikihistory.json index 1a7d2e8baa837a..fa8e310d4fcf38 100644 --- a/files/ko/_wikihistory.json +++ b/files/ko/_wikihistory.json @@ -2649,32 +2649,6 @@ "Netaras" ] }, - "MDN/Tools": { - "modified": "2020-09-30T16:51:24.922Z", - "contributors": [ - "chrisdavidmills", - "wbamberg", - "zziuni", - "frankradio", - "galcyurio", - "Vi01et", - "jswisher" - ] - }, - "MDN/Tools/KumaScript": { - "modified": "2020-11-30T12:49:14.835Z", - "contributors": [ - "chrisdavidmills", - "mfuji09" - ] - }, - "MDN/Tools/KumaScript/Troubleshooting": { - "modified": "2020-09-30T16:51:25.656Z", - "contributors": [ - "chrisdavidmills", - "Silvermist" - ] - }, "MDN/Yari": { "modified": "2019-09-06T03:29:26.311Z", "contributors": [ diff --git a/files/ko/mdn/tools/index.html b/files/ko/mdn/tools/index.html deleted file mode 100644 index a890d6f76cff28..00000000000000 --- a/files/ko/mdn/tools/index.html +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: MDN 도구들 -slug: MDN/Tools -tags: - - MDN 메타 - - TopicStub - - 시작하기 -translation_of: MDN/Tools ---- -
    {{MDNSidebar}}
    - -
    {{IncludeSubnav("/ko/docs/MDN")}}
    - -

    MDN은 진행 상황을 추적하고 콘텐츠를 관리하며 사이트의 최신 변경 사항을 따라하기 쉽게 해주는 많은 기능을 제공합니다.

    - -

    {{LandingPageListSubpages}}

    diff --git a/files/ko/mdn/tools/kumascript/index.html b/files/ko/mdn/tools/kumascript/index.html deleted file mode 100644 index e8d84b9b52ef3c..00000000000000 --- a/files/ko/mdn/tools/kumascript/index.html +++ /dev/null @@ -1,472 +0,0 @@ ---- -title: KumaScript -slug: MDN/Tools/KumaScript -tags: - - Guide - - Kuma - - KumaScript - - MDN Meta - - NeedsContent - - NeedsTranslation - - Site-wide - - TopicStub -translation_of: MDN/Tools/KumaScript ---- -
    {{MDNSidebar}}
    - -

    On the Kuma platform that powers MDN, the template system for automating aspects of content on the wiki is called KumaScript. KumaScript is powered by server-side JavaScript, implemented using Node.js. This article provides basic information on how to use KumaScript.

    - -

    For a detailed overview and Q&A of KumaScript, watch the MDN dev team's KumaScript Fireside Chat (the meeting starts at 10 minutes into the video). KumaScript replaced DekiScript, which was the template language for MindTouch, the previous platform used by MDN.

    - -

    What is KumaScript?

    - -
      -
    • A way to reuse and localize content that appears repeatedly between documents (e.g., compatibility labels, section navigation, warning banners).
    • -
    • A way to build documents out of content pulled from other documents.
    • -
    • A way to fetch and include content from other web sites and services (e.g., Bugzilla).
    • -
    - -

    What KumaScript is not

    - -
      -
    • KumaScript does not support interactive scripting of the kind that can accept form submissions.
    • -
    • KumaScript does not have access to a database, files, or any other way to store information persistently.
    • -
    • KumaScript does not support site personalization based on the user currently logged in.
    • -
    • KumaScript does not have access to user information, only to the content and metadata of a wiki page being viewed.
    • -
    - -

    Basics

    - -

    KumaScript is used on MDN in embedded JavaScript templates. These templates can be invoked in document content by any MDN author, through the use of macros.

    - -

    A script in KumaScript is a template, and each template is a file in the macros directory of the KumaScript repository on Github. A template looks like this:

    - -
    <% for (var i = 0; i < $0; i++) { %>
    -  Hello #<%= i %>
    -<% } %>
    - -

    Invoking a template is done with a macro, which can be used anywhere in any wiki content. A macro looks like this:

    - -
    \{{hello(3)}}
    - -

    The output of the macro looks like this:

    - -
    Hello #0
    -Hello #1
    -Hello #2
    - -

    Macro syntax

    - -

    KumaScript templates are invoked in document content with macros, like this:

    - -
    \{{templateName("arg0", "arg1", ..., "argN")}}
    - -

    Macro syntax consists of these rules:

    - -
      -
    • Macros start and end with \{{ and \}} characters.
    • -
    • The first part of the macro is the name of a template. The lowercase value of this name should match the lowercase value of one of the filenames under the macros directory of KumaScript.
    • -
    • A template can accept parameters, and this parameter list starts and ends with parentheses.
    • -
    • All non-numeric parameters must be in quotes. Numbers can be left unquoted.
    • -
    - -

    Using JSON as a macro parameter

    - -

    As a semi-experimental feature (not guaranteed to work), you can supply a JSON object for the first and only parameter, like so:

    - -
    \{{templateName({ "Alpha": "one", "Beta": ["a", "b", "c"], "Foo": "https:\/\/mozilla.org\/" })}}
    - -

    The data from this macro is available in template code as an object in the $0 argument (e.g., $0.Alpha, $0.Beta, $0.Foo). This also allows you to express complex data structures in macro parameters that are hard or impossible to do with a simple list of parameters.

    - -

    Note that this parameter style is very picky — it must adhere to JSON syntax exactly, which has some requirements about escaping characters that are easy to miss (e.g., all forward slashes are escaped). When in doubt, try running your JSON through a validator.

    - -

    How to write "\{{" in text

    - -

    Since the character sequence "\{{" is used to indicate the start of a macro, this can be troublesome if you actually just want to use "\{{" and "}}" in a page. It will probably produce DocumentParsingError messages.

    - -

    In this case, you can escape the first brace with a backslash, like so: \\{{

    - -

    Template syntax

    - -

    Each KumaScript template is a file under the macros directory of KumaScript. You create and edit these files as you would the files of any open-source project on GitHub (see the KumaScript README for more information).

    - -

    KumaScript templates are processed by an embedded JavaScript template engine with a few simple rules:

    - -
      -
    • Within a template, the parameters passed in from the macro are available as the variables $0, $1, $2, and so on. The entire list of parameters is also available in a template as the variable arguments.
    • -
    • Most text is treated as output and included in the output stream.
    • -
    • JavaScript variables and expressions can be inserted into the output stream with these blocks: -
        -
      • <%= expr %> — the value of a JavaScript expression is escaped for HTML before being included in output (e.g., characters like < and > are turned into &lt; and &gt;).
      • -
      • <%- expr %> — the value of a JavaScript expression is included in output without any escaping. (Use this if you want to dynamically build markup or use the results of another template that may include markup.)
      • -
      • It is an error to include semicolons inside these blocks.
      • -
      -
    • -
    • Anything inside a <% %> block is interpreted as JavaScript. This can include loops, conditionals, etc.
    • -
    • Nothing inside a <% %> block can ever contribute to the output stream. But, you can transition from JS mode to output mode using <% %>—for example: -
      <% for (var i = 0; i < $0; i++) { %>
      -  Hello #<%= i %>
      -<% } %>
      - -

      Note how the JavaScript code is contained in <% ... %>, and output happens in the space between %> ... <%. The for loop in JS can begin with one <% %> block, transition to output mode, and finish up in a second <% %> JS block.

      -
    • -
    • For more details on EJS syntax, check out the upstream module documentation.
    • -
    - -

    Tips

    - -

    You can see a list of macros and how they are used on MDN on the macros dashboard.

    - -

    Advanced Features

    - -

    Beyond the basics, the KumaScript system offers some advanced features.

    - -

    Environment variables

    - -

    When the wiki makes a call to the KumaScript service, it passes along some context on the current document that KumaScript makes available to templates as variables:

    - -
    -
    env.path
    -
    The path to the current wiki document
    -
    env.url
    -
    The full URL to the current wiki document
    -
    env.id
    -
    A short, unique ID for the current wiki document
    -
    env.files
    -
    An array of the files attached to the current wiki document; each object in the array is as described under File objects below
    -
    env.review_tags
    -
    An array of the review tags on the article ("technical", "editorial", etc.)
    -
    env.locale
    -
    The locale of the current wiki document
    -
    env.title
    -
    The title of the current wiki document
    -
    env.slug
    -
    The URL slug of the current wiki document
    -
    env.tags
    -
    An array list of tag names for the current wiki document
    -
    env.modified
    -
    Last modified timestamp for the current wiki document
    -
    env.cache_control
    -
    Cache-Control header sent in the request for the current wiki document, useful in deciding whether to invalidate caches
    -
    - -

    File objects

    - -

    Each file object has the following fields:

    - -
    -
    title
    -
    The attachment's title
    -
    description
    -
    A textual description of the current revision of the file
    -
    filename
    -
    The file's name
    -
    size
    -
    The size of the file in bytes
    -
    author
    -
    The username of the person who uploaded the file
    -
    mime
    -
    The MIME type of the file
    -
    url
    -
    The URL at which the file can be found
    -
    - -

    Working with tag lists

    - -

    The env.tags and env.review_tags variables return arrays of tags. You can work with these in many ways, of course, but here are a couple of suggestions.

    - -
    Looking to see if a specific tag is set
    - -

    You can look to see if a specific tag exists on a page like this:

    - -
    if (env.tags.indexOf("tag") != −1) {
    -  // The page has the tag "tag"
    -}
    -
    - -
    Iterating over all the tags on a page
    - -

    You can also iterate over all the tags on a page, like this:

    - -
    env.tag.forEach(function(tag) {
    -  // do whatever you need to do, such as:
    -  if (tag.indexOf("a") == 0) {
    -    // this tag starts with "a" - woohoo!
    -  }
    -});
    - -

    APIs and Modules

    - -

    KumaScript offers some built-in methods and APIs for KumaScript macros. Macros can also use module.exports to export new API methods.

    - -

    API changes require updating the KumaScript engine or macros via a pull request to the KumaScript repository.

    - -

    Built-in methods

    - -

    This manually-maintained documentation is likely to fall out of date with the code. With that in mind, you can always check out the latest state of built-in APIs in the KumaScript source. But here is a selection of useful methods exposed to templates:

    - -
    -
    md5(string)
    -
    Returns an MD5 hex digest of the given string.
    -
    template("name", ["arg0", "arg1", ..., "argN"])
    -
    -

    Executes and returns the result of the named template with the given list of parameters.

    - -

    Example: <%- template("warning", ["foo", "bar", "baz"]) %>.

    - -

    Example using the DOMxRef macro: <%- template("DOMxRef", ["Event.bubbles", "bubbles"]) %>.

    - -

    This is a JavaScript function. So, if one of the parameters is an arg variable like $2, do not put it in quotes. Like this: <%- template("warning", [$1, $2, "baz"]) %>. If you need to call another template from within a block of code, do not use <% ... %>. Example: myvar = "<li>" + template("LXRSearch", ["ident", "i", $1]) + "</li>";

    -
    -
    require(name)
    -
    Loads another template as a module; any output is ignored. Anything assigned to module.exports in the template is returned.
    -
    Used in templates like so: <% const my_module = require('MyModule'); %>.
    -
    cacheFn(key, timeout, function_to_cache)
    -
    Using the given key and cache entry lifetime, cache the results of the given function. Honors the value of env.cache_control to invalidate cache on no-cache, which can be sent by a logged-in user hitting shift-refresh.
    -
    request
    -
    Access to mikeal/request, a library for making HTTP requests. Using this module in KumaScript templates is not yet very friendly, so you may want to wrap usage in module APIs that simplify things.
    -
    log.debug(string)
    -
    Outputs a debug message into the script log on the page (i.e. the big red box that usually displays errors).
    -
    - -

    Built-in API modules

    - -

    There are a set of built in API that are automatically loaded and made available to every template by the environment script.

    - -

    For the most part, these attempt to provide stand-ins for legacy DekiScript features to ease template migration. But, going forward, these can be used to share common variables and methods between templates:

    - - - -

    You can see the most up to date list of methods under kuma from the KumaScript source code, but here are a few:

    - -
    -
    kuma.inspect(object)
    -
    Renders any JS object as a string, handy for use with log.debug(). See also: node.js util.inspect().
    -
    kuma.htmlEscape(string)
    -
    Escapes the characters &, <, >, " to &amp, &lt;, &gt;, &quot;, respectively.
    -
    kuma.url
    -
    See also: node.js url module.
    -
    kuma.fetchFeed(url)
    -
    Fetch an RSS feed and parse it into a JS object. See also: InsertFeedLinkList
    -
    - -

    Creating modules

    - -

    Using the built-in require() method, you can load a template as a module to share common variables and methods between templates. A module can be defined in a template like this:

    - -
    <%
    -module.exports = {
    -    add: function (a, b) {
    -        return a + b;
    -    }
    -}
    -%>
    - -

    Assuming this template is saved under https://github.com/mdn/kumascript/tree/master/macros as MathLib.ejs, you can use it in another template like so:

    - -
    <%
    -var math_lib = require("MathLib");
    -%>
    -The result of 2 + 2 = <%= math_lib.add(2, 2) %>
    - -

    And, the output of this template will be:

    - -
    The result of 2 + 2 = 4
    - -

    Tips and caveats

    - -

    Debugging

    - -

    A useful tip when debugging. You can use the log.debug() method to output text to the scripting messages area at the top of the page that's running your template. Note that you need to be really sure to remove these when you're done debugging, as they're visible to all users! To use it, just do something like this:

    - -
    <%- log.debug("Some text goes here"); %>
    - -

    You can, of course, create more complex output using script code if it's helpful.

    - -

    Caching

    - -

    KumaScript templates are heavily cached to improve performance. For the most part, this works great to serve up content that doesn't change very often. But, as a logged-in user, you have two options to force a page to be regenerated, in case you notice issues with scripting:

    - -
      -
    • Hit Refresh in your browser. This causes KumaScript to invalidate its cache for the content on the current page by issuing a request with a Cache-Control: max-age=0 header.
    • -
    • Hit Shift-Refresh in your browser. This causes KumaScript to invalidate cache for the current page, as well as for any templates or content used by the current page by issuing a request with a Cache-Control: no-cache header.
    • -
    - -

    Using search keywords to open template pages

    - -

    When using templates, it's common to open the template's code in a browser window to review the comments at the top, which are used to document the template, its parameters, and how to use it properly. To quickly access templates, you can create a Firefox search keyword, which gives you a shortcut you can type in the URL box to get to a template more easily.

    - -

    To create a search keyword, open the bookmarks window by choosing "Show all bookmarks" in the Bookmarks menu, or by pressing Control+Shift+B (Command+Shift+B on Mac). Then from the utility ("Gear") menu in the Library window that appears, choose "New Bookmark...".

    - -

    This causes the bookmark editing dialog to appear. Fill that out as follows:

    - -
    -
    Name
    -
    A suitable name for your search keyword; "Open MDN Template" is a good one.
    -
    Location
    -
    https://github.com/mdn/kumascript/blob/master/macros/%s
    -
    Tags{{Optional_Inline}}
    -
    A list of tags used to organize your bookmarks; these are entirely optional and what (if any) tags you use is up to you.
    -
    Keyword
    -
    The shortcut text you wish to use to access the template. Ideally, this should be something short and quick to type, such as simply "t" or "mdnt".
    -
    Description{{Optional_Inline}}
    -
    A suitable description explaining what the search keyword does.
    -
    - -

    The resulting dialog looks something like this:

    - -

    - -

    Then click the "Add" button to save your new search keyword. From then on, typing your keyword, then a space, then the name of a macro will open that macro in your current tab. So if you used "t" as the keyword, typing t ListSubpages will show you the page at \{{ListSubpages}}.

    - -

    Cookbook

    - -

    This section will list examples of common patterns for templates used on MDN, including samples of legacy DekiScript templates and their new KumaScript equivalents.

    - -

    Force templates used on a page to be reloaded

    - -

    It bears repeating: To force templates used on a page to be reloaded after editing, hit Shift-Reload. Just using Reload by itself will cause the page contents to be regenerated, but using cached templates and included content. A Shift-Reload is necessary to invalidate caches beyond just the content of the page itself.

    - -

    Recovering from "Unknown Error"

    - -

    Sometimes, you'll see a scripting message like this when you load a page:

    - -
    Kumascript service failed unexpectedly: <class 'httplib.BadStatusLine'>
    - -

    This is probably a temporary failure of the KumaScript service. If you Refresh the page, the error may disappear. If that doesn't work, try a Shift-Refresh. If, after a few tries, the error persists - file an IT bug for Mozilla Developer Network to ask for an investigation.

    - -

    Broken wiki.languages() macros

    - -

    On some pages, you'll see a scripting error like this:

    - -
    Syntax error at line 436, column 461: Expected valid JSON object as the parameter of the preceding macro but...
    - -

    If you edit the page, you'll probably see a macro like this at the bottom of the page:

    - -
    \{{ wiki.languages({ "zh-tw": "zh_tw/Core_JavaScript_1.5_教學/JavaScript_概要", ... }) }}
    - -

    To fix the problem, just delete the macro. Or, replace the curly braces on either side with HTML comments <!-- --> to preserve the information, like so:

    - -
    <!-- wiki.languages({ "zh-tw": "zh_tw/Core_JavaScript_1.5_教學/JavaScript_概要", ... }) -->
    - -

    Because Kuma supports localization differently, these macros aren't actually needed any more. But, they've been left intact in case we need to revisit the relationships between localized pages. Unfortunately, it seems like migration has failed to convert some of them properly.

    - -

    Finding the Current Page's Language

    - -

    In KumaScript, the locale of the current document is exposed as an environment variable:

    - -
    const lang = env.locale;
    - -

    The env.locale variable should be reliable and defined for every document.

    - -

    Reading the contents of a page attachment

    - -

    You can read the contents of an attached file by using the mdn.getFileContent() function, like this:

    - -
    <%
    -  let contents = mdn.getFileContent(fileUrl);
    -  // ... do stuff with the contents ...
    -%>
    -
    - -

    or

    - -
    <%- mdn.getFileContent(fileObject); %>
    -
    - -

    In other words, you may specify either the URL of the file to read or as a file object. The file objects for a page can be accessed through the array env.files. So, for example, to embed the contents of the first file attached to the article, you can do this:

    - -
    <%- mdn.getFileContent(env.files[0]); %>
    -
    - -
    -

    Note: You probably don't want to try to embed the contents of a non-text file this way, as the raw contents would be injected as text. This is meant to let you access the contents of text attachments.

    -
    - -

    If the file isn't found, an empty string is returned. There is currently no way to tell the difference between an empty file and a nonexistent one. But if you're putting empty files on the wiki, you're doing it wrong.

    - -

    テンプレートのローカライズ

    - -

    Templates are not translated like wiki pages, rather any single template might be used for any number of locales.

    - -

    So the main way to output content tailored to the current document locale is to pivot on the value of env.locale. There are many ways to do this, but a few patterns are common in the conversion of legacy DekiScript templates:

    - -

    If/else blocks in KumaScript

    - -

    The KumaScript equivalent of this can be achieved with simple if/else blocks, like so:

    - -
    <% if ("fr" == env.locale) { %>
    -<%- template("CSSRef") %> « <a href="/fr/docs/Référence_CSS/Extensions_Mozilla">Référence CSS: Extensions Mozilla</a>
    -<% } else if ("ja" == env.locale) { %>
    -<%- template("CSSRef") %> « <a href="/ja/docs/CSS_Reference/Mozilla_Extensions">CSS リファレンス: Mozilla 拡張仕様</a>
    -<% } else if ("pl" == env.locale) { %>
    -<%- template("CSSRef") %> « <a href="/pl/docs/Dokumentacja_CSS/Rozszerzenia_Mozilli">Dokumentacja CSS: Rozszerzenia Mozilli</a>
    -<% } else if ("de" == env.locale) { %>
    -<%- template("CSSRef") %> « <a href="/de/docs/CSS_Referenz/Mozilla_CSS_Erweiterungen">CSS Referenz: Mozilla Erweiterungen</a>
    -<% } else { %>
    -<%- template("CSSRef") %> « <a href="/en-US/docs/CSS_Reference/Mozilla_Extensions">CSS Reference: Mozilla Extensions</a>
    -<% } %>
    - -

    Depending on what text editor is your favorite, you may be able to copy & paste from the browser-based editor and attack this pattern with a series of search/replace regexes to get you most of the way there.

    - -

    My favorite editor is MacVim, and a series of regexes like this does the bulk of the work with just a little manual clean up following:

    - -
    %s#<span#^M<span#g
    -%s#<span lang="\(.*\)" .*>#<% } else if ("\1" == env.locale) { %>#g
    -%s#<span class="script">template.CSSxRef(#<%- template("CSSxRef", [#
    -%s#)</span> </span>#]) %>
    -
    - -

    Your mileage may vary, and patterns change slightly from template to template. That's why the migration script was unable to just handle this automatically, after all.

    - -

    String variables and switch

    - -

    Rather than switch between full chunks of markup, you can define a set of strings, switch them based on locale, and then use them to fill in placeholders in a single chunk of markup:

    - -
    <%
    -var s_title = 'Firefox for Developers';
    -switch (env.locale) {
    -    case 'de':
    -        s_title = "Firefox für Entwickler";
    -        break;
    -    case 'fr':
    -        s_title = "Firefox pour les développeurs";
    -        break;
    -    case 'es':
    -        s_title = "Firefox para desarrolladores";
    -        break;
    -};
    -%>
    -<span class="title"><%= s_title %></span>
    - -

    Use mdn.localString()

    - -

    A recent addition to the MDN:Common module is mdn.localString(), used like this:

    - -
    <%
    -var s_title = mdn.localString({
    -  "en-US": "Firefox for Developers",
    -  "de": "Firefox für Entwickler",
    -  "es": "Firefox para desarrolladores"
    -});
    -%>
    -<span class="title"><%= s_title %></span>
    - -

    This is more concise than the switch statement, and may be a better choice where a single string is concerned. However, if many strings need to be translated (e.g., as in \{{CSSRef}}), a switch statement might help keep all the strings grouped by locale and more easily translated that way.

    - -

    When the object does not have the appropriate locale, the value of "en-US" is used as the initial value.

    - -

    See also

    - - diff --git a/files/ko/mdn/tools/kumascript/troubleshooting/index.html b/files/ko/mdn/tools/kumascript/troubleshooting/index.html deleted file mode 100644 index ab72f466f18ccb..00000000000000 --- a/files/ko/mdn/tools/kumascript/troubleshooting/index.html +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: KumaScript 에러 해결하기 -slug: MDN/Tools/KumaScript/Troubleshooting -translation_of: MDN/Tools/KumaScript/Troubleshooting ---- -
    {{MDNSidebar}}
    - -
    -

     빨갛고 무서운 상자 안에 든 KumaScript 에러는 매우 보기 불편합니다. 하지만 다행히도, MDN 계정이 있다면 누구나 문서를 편집해 이 문제를 해결할 수 있어요. When a page has an error it gets added to the list of documents with errors.  Site editors go through this list regularly to find and fix errors. This article details the four types of KumaScript error, and some steps you can take to fix them.

    -
    - -

    DocumentParsingError

    - -

    DocumentParsingError errors appear when KumaScript has trouble understanding something in the document itself. The most common cause is a syntax error in a macro.

    - -

    Check for:

    - -
    -
    Use of curly braces without intending to call a macro.
    -
    If you need to write  \{ in a document without calling a macro you can escape it with a \ like this: \\{
    -
    Use of a special character in a macro parameter.
    -
    If you need to use a " or a \  inside of a macro parameter they can be escaped with a \ like this: \\ or \"
    -
    Missing commas between macro parameters.
    -
    Macro parameters need to be delimited by a comma (,) but not at the end of the list of parameters; for example \{\{anch("top", "Back to top")}}.
    -
    HTML tags appearing inside a macro call
    -
    If you apply styling to a macro, it will often break because, for example, a </code> tag may have appeared inside the macro code in the source code. Check the source view to see what's there, and remove any unnecessary styling.
    -
    - -
      -
    - -

    TemplateLoadingError

    - -

    TemplateLoadingError errors appear when KumaScript has trouble finding which macro to include on a page.

    - -

    Check for:

    - -
    -
    Misspelling of macro names or renamed macros.
    -
    You can look at the list of known macros in the Github repo.
    -
    - -
    -

    Tip: You can make it quick and easy to jump to a specific macro by adding a search keyword to Firefox. See {{SectionOnPage("/en-US/docs/MDN/Contribute/Tools/KumaScript", "Using search keywords to open template pages")}} for a step-by-step guide to creating the search keyword for this.

    -
    - -

    TemplateExecutionError

    - -

    TemplateExecutionError errors appear when KumaScript encounters an error in the macro. These errors can only be fixed by admin users and need to be reported as bugs.

    - -

    Before reporting an error check to see that it hasn't already been fixed. You can do this by forcing KumaScript to give you a fresh copy of the page by holding down Shift while you refresh the page (Shift + Ctrl + R on Windows/Linux, Shift + Cmd + R on Mac).

    - -

    If the error persists, report a bug, including the URL of the page and the text of the error.

    - -

    Error & Unknown

    - -

    This is the category errors end up in if they are not one of the other kinds of error.

    - -

    Check for fixes and report persistent bugs like described under TemplateExecutionError.