Jump to content

User:Chlod/Tools/Stroke Order Resolver

From Wikipedia, the free encyclopedia
Stroke Order Resolver
Original author(s)Chlod Alejandro
Developer(s)Contributors to the Stroke Order Resolver project
Initial releaseAugust 31, 2020; 4 years ago (2020-08-31)
Stable release
1.0.0 / August 31, 2020; 4 years ago (2020-08-31)
Repositoryhttps://github.com/ChlodAlejandro/wiki-kanji-stroke-order
Written inJavaScript
EngineNode.js
TypeWeb scraper
LicenseApache 2.0 License

The Stroke Order Resolver (SOR) is a Modular Express Server module that takes a Kanji, Hiragana, or Katakana character, and returns the stroke order for that character. It automatically falls back to the Kangxi radical stroke orders if it does not find a stroke order meant for Japanese characters.

The images are taken from the Wikimedia Commons Stroke Order Project.

Endpoints

[edit]
Format Endpoint Description
PNG (link for 「一」)

(link for 「前」)

URL 「一」: https://wiki.chlod.net/kanji/%E4%B8%80

URL 「前」: https://wiki.chlod.net/kanji/%E5%89%8D

Returns the stroke order for the given character.

For 「一」, which has both a Japanese version (File:一-jbw.png) and the other version (File:一-bw.png), the Japanese version will be shown.

Since 「前」 does not have a Japanese version (the file File:前-jbw.png does not exist), it will fallback to the other version (File:前-bw.png).

PNG (as parameter) (link for 「前」) URL: https://wiki.chlod.net/kanji/?character=%E5%89%8D

Returns the stroke order for the 前 character. This version takes the character from a URL parameter instead of the path.

GIF (link for 「前」) URL: https://wiki.chlod.net/kanji/%E5%89%8D?animated=1

Returns the stroke order for the 前 character (as a GIF).

To get the animated version, the parameter animated must be passed with the value of 1.

Error cases

[edit]

If the SOR experiences an issue, it will return the appropriate response code and an image describing the issue. For example, if a character was not provided, a 400 response code will be returned, along with a picture describing the issue. If a character did not have an available image, the 404 code is returned.

If a 500 error was returned, there was an internal error in attempting to retrieve the appropriate image. The error is logged on the server side, so if you ping me on my talk page, I'll be able to check out what went wrong.