Skip to content

Commit

Permalink
v1.19.5: fix #69
Browse files Browse the repository at this point in the history
  • Loading branch information
kanasimi committed Dec 21, 2023
1 parent 4fc6931 commit 02ec0a3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 33 deletions.
8 changes: 5 additions & 3 deletions Wikiapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ function setup_wiki_session(wiki_session) {
*
* @returns {Promise} Promise object represents {String} login_name
*
* @example <caption><span id="example__Login to wiki site 1">Login to wiki site method 1.</span></caption>
* @example <caption><span id="example__Login to wiki site 1">Login to wiki site method 1 (recommend).</span></caption>
// <code>
const wiki = new Wikiapi;
const login_options = {
user_name: '', password: '', API_URL: 'en',
// Ror lingualibre only. @see https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js
// e.g., lingualibre. @see https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js
//data_API_URL: 'https://lingualibre.org/api.php',
//SPARQL_API_URL: 'https://lingualibre.org/bigdata/namespace/wdq/sparql',
// Calling in another domain
Expand Down Expand Up @@ -401,7 +401,7 @@ function reject_edit_error(reject, error, result) {
// console.log(error);
}

if (result && typeof error === 'object')
if (result && error && typeof error === 'object')
error.result = result;
reject(error);
return true;
Expand Down Expand Up @@ -1564,6 +1564,8 @@ await wiki.for_each_page(link_from, page_data => {
summary: 'test edit',
// Allow content to be emptied. 允許內容被清空。白紙化。
allow_empty: true,
// If the content is not changed, using `skip_nochange` will skip the actual edit. Otherwise, a null edit will be made.
skip_nochange: true,
tags: 'bot trial',
// prevent creating new pages
// Throw an error if the page doesn't exist.
Expand Down
38 changes: 20 additions & 18 deletions docs/Wikiapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ <h4 class="name" id=".KEY_subcategories"><span class="type-signature">(static) <

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1159">line 1159</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1160">line 1160</a>
</li></ul></dd>


Expand Down Expand Up @@ -380,7 +380,7 @@ <h4 class="name" id="category_tree"><span class="type-signature"></span>category

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1135">line 1135</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1136">line 1136</a>
</li></ul></dd>


Expand Down Expand Up @@ -600,7 +600,7 @@ <h4 class="name" id="convert_Chinese"><span class="type-signature"></span>conver

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1666">line 1666</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1669">line 1669</a>
</li></ul></dd>


Expand Down Expand Up @@ -1084,7 +1084,7 @@ <h4 class="name" id="delete"><span class="type-signature"></span>delete<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1840">line 1840</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1843">line 1843</a>
</li></ul></dd>


Expand Down Expand Up @@ -1296,7 +1296,7 @@ <h4 class="name" id="download"><span class="type-signature"></span>download<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1520">line 1520</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1521">line 1521</a>
</li></ul></dd>


Expand Down Expand Up @@ -1551,7 +1551,7 @@ <h4 class="name" id="edit"><span class="type-signature"></span>edit<span class="

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1888">line 1888</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1891">line 1891</a>
</li></ul></dd>


Expand Down Expand Up @@ -2039,7 +2039,7 @@ <h4 class="name" id="for_each_page"><span class="type-signature"></span>for_each

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1591">line 1591</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1594">line 1594</a>
</li></ul></dd>


Expand Down Expand Up @@ -2111,6 +2111,8 @@ <h5>Example</h5>
summary: 'test edit',
// Allow content to be emptied. 允許內容被清空。白紙化。
allow_empty: true,
// If the content is not changed, using `skip_nochange` will skip the actual edit. Otherwise, a null edit will be made.
skip_nochange: true,
tags: 'bot trial',
// prevent creating new pages
// Throw an error if the page doesn't exist.
Expand Down Expand Up @@ -2316,7 +2318,7 @@ <h4 class="name" id="get_featured_content"><span class="type-signature"></span>g

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1759">line 1759</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1762">line 1762</a>
</li></ul></dd>


Expand Down Expand Up @@ -2504,7 +2506,7 @@ <h4 class="name" id="listen"><span class="type-signature"></span>listen<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1921">line 1921</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1924">line 1924</a>
</li></ul></dd>


Expand Down Expand Up @@ -2758,13 +2760,13 @@ <h4 class="name" id="login"><span class="type-signature"></span>login<span class

<h5>Examples</h5>

<p class="code-caption"><span id="example__Login to wiki site 1">Login to wiki site method 1.</span></p>
<p class="code-caption"><span id="example__Login to wiki site 1">Login to wiki site method 1 (recommend).</span></p>

<pre class="prettyprint"><code>// &lt;code>
const wiki = new Wikiapi;
const login_options = {
user_name: '', password: '', API_URL: 'en',
// Ror lingualibre only. @see https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js
// e.g., lingualibre. @see https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js
//data_API_URL: 'https://lingualibre.org/api.php',
//SPARQL_API_URL: 'https://lingualibre.org/bigdata/namespace/wdq/sparql',
// Calling in another domain
Expand Down Expand Up @@ -4326,7 +4328,7 @@ <h4 class="name" id="redirects_here"><span class="type-signature"></span>redirec

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1251">line 1251</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1252">line 1252</a>
</li></ul></dd>


Expand Down Expand Up @@ -4536,7 +4538,7 @@ <h4 class="name" id="redirects_root"><span class="type-signature"></span>redirec

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1214">line 1214</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1215">line 1215</a>
</li></ul></dd>


Expand Down Expand Up @@ -4746,7 +4748,7 @@ <h4 class="name" id="register_redirects"><span class="type-signature"></span>reg

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1334">line 1334</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1335">line 1335</a>
</li></ul></dd>


Expand Down Expand Up @@ -5002,7 +5004,7 @@ <h4 class="name" id="search"><span class="type-signature"></span>search<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1180">line 1180</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1181">line 1181</a>
</li></ul></dd>


Expand Down Expand Up @@ -5213,7 +5215,7 @@ <h4 class="name" id="site_name"><span class="type-signature"></span>site_name<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1813">line 1813</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1816">line 1816</a>
</li></ul></dd>


Expand Down Expand Up @@ -5897,7 +5899,7 @@ <h4 class="name" id="upload"><span class="type-signature"></span>upload<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1441">line 1441</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1442">line 1442</a>
</li></ul></dd>


Expand Down Expand Up @@ -6141,7 +6143,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Apr 22 2023 08:50:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Fri Dec 22 2023 06:05:01 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
4 changes: 2 additions & 2 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ <h4 class="name" id="Wikiapi_for_each_page_in_list"><span class="type-signature"

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1094">line 1094</a>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1095">line 1095</a>
</li></ul></dd>


Expand Down Expand Up @@ -1770,7 +1770,7 @@ <h5>Examples</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Apr 22 2023 08:50:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Fri Dec 22 2023 06:05:01 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
9 changes: 6 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ <h3> </h3>
<a href="https://www.codacy.com/gh/kanasimi/wikiapi/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=kanasimi/wikiapi&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/bfb4fe9fe6e04346986f5cc83099369e" alt="Codacy Badge"></a>
<a href="https://deepscan.io/dashboard#view=project&amp;tid=4788&amp;pid=6757&amp;bid=58325"><img src="https://deepscan.io/api/teams/4788/projects/6757/branches/58325/badge/grade.svg" alt="DeepScan grade"></a></p>
<h1>JavaScript MediaWiki API</h1>
<p>A simple way to access MediaWiki API via JavaScript with <a href="https://kanasimi.github.io/CeJS/_test%20suite/wikitext_parser.html">wikitext parser</a>.
This is basically a modern syntax version of <a href="https://github.com/kanasimi/CeJS/blob/master/application/net/wiki">CeJS MediaWiki module</a>. For example, using <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function">async functions</a>.</p>
<p align="center">
<img alt="Wikiapi logo" width="244" src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/WikiapiJS_MW_gear_icon.svg/244px-WikiapiJS_MW_gear_icon.svg.png" />
</p>
A simple way to access MediaWiki API via JavaScript with [wikitext parser](https://kanasimi.github.io/CeJS/_test%20suite/wikitext_parser.html).
This is basically a modern syntax version of [CeJS MediaWiki module](https://github.com/kanasimi/CeJS/blob/master/application/net/wiki). For example, using [async functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
<h2>Features</h2>
<ul>
<li>Read / edit pages.</li>
Expand Down Expand Up @@ -463,7 +466,7 @@ <h2>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Apr 22 2023 08:50:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Fri Dec 22 2023 06:05:01 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
16 changes: 10 additions & 6 deletions docs/wikiapi.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ <h1 class="page-title">wikiapi.js</h1>
*
* @returns {Promise} Promise object represents {String} login_name
*
* @example &lt;caption>&lt;span id="example__Login to wiki site 1">Login to wiki site method 1.&lt;/span>&lt;/caption>
* @example &lt;caption>&lt;span id="example__Login to wiki site 1">Login to wiki site method 1 (recommend).&lt;/span>&lt;/caption>
// &lt;code>
const wiki = new Wikiapi;
const login_options = {
user_name: '', password: '', API_URL: 'en',
// Ror lingualibre only. @see https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js
// e.g., lingualibre. @see https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js
//data_API_URL: 'https://lingualibre.org/api.php',
//SPARQL_API_URL: 'https://lingualibre.org/bigdata/namespace/wdq/sparql',
// Calling in another domain
Expand Down Expand Up @@ -445,7 +445,7 @@ <h1 class="page-title">wikiapi.js</h1>
// console.log(error);
}

if (result &amp;&amp; typeof error === 'object')
if (result &amp;&amp; error &amp;&amp; typeof error === 'object')
error.result = result;
reject(error);
return true;
Expand Down Expand Up @@ -1070,6 +1070,7 @@ <h1 class="page-title">wikiapi.js</h1>
options = CeL.setup_options(options);
// console.trace(options.for_each_page);
// const wiki = this[KEY_wiki_session];
//console.trace([ list_type, title ]);
wiki_API.list(title, (list/* , target, options */) => {
// console.trace(list);
if (list.error) {
Expand Down Expand Up @@ -1607,6 +1608,8 @@ <h1 class="page-title">wikiapi.js</h1>
summary: 'test edit',
// Allow content to be emptied. 允許內容被清空。白紙化。
allow_empty: true,
// If the content is not changed, using `skip_nochange` will skip the actual edit. Otherwise, a null edit will be made.
skip_nochange: true,
tags: 'bot trial',
// prevent creating new pages
// Throw an error if the page doesn't exist.
Expand Down Expand Up @@ -1677,7 +1680,7 @@ <h1 class="page-title">wikiapi.js</h1>
resolve(this);
}
};
//console.trace(work_config);
//console.trace([ options, work_config, ]);

wiki.work(work_config, page_list);
}
Expand Down Expand Up @@ -2026,12 +2029,13 @@ <h1 class="page-title">wikiapi.js</h1>
// arrow function expression DO NOT has this, arguments, super, or
// new.target keywords.
Wikiapi.prototype[type] = function (title, options) {
if (options === undefined &amp;&amp; CeL.is_Object(title)) {
if (options === undefined &amp;&amp; CeL.is_Object(title) &amp;&amp; !wiki_API.is_page_data(title)) {
// shift arguments
options = title;
title = undefined;
}
const _this = this;
//console.trace(arguments);
/**
* @example &lt;code>

Expand Down Expand Up @@ -2075,7 +2079,7 @@ <h1 class="page-title">wikiapi.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Apr 22 2023 08:50:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Fri Dec 22 2023 06:05:01 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wikiapi",
"title": "JavaScript MediaWiki API for node.js",
"version": "1.19.4",
"version": "1.19.5",
"description": "A simple way to access MediaWiki API via JavaScript with simple wikitext parser.",
"keywords": [
"MediaWiki",
Expand Down Expand Up @@ -29,6 +29,8 @@
"type": "git",
"url": "git+https://github.com/kanasimi/wikiapi.git"
},

"type": "commonjs",
"main": "Wikiapi.js",
"scripts": {
"test": "nyc node \"_test suite/test.js\"",
Expand Down

0 comments on commit 02ec0a3

Please sign in to comment.