Comparing version 1.14.0 to 1.14.1
@@ -261,3 +261,3 @@ 'use strict'; | ||
// cache alias of {{Article history}} | ||
const Article_history_alias = (await wiki.redirects_here('Template:Article history')) | ||
const Article_history_alias = (await enwiki.redirects_here('Template:Article history')) | ||
.map(page_data => page_data.title | ||
@@ -264,0 +264,0 @@ // remove "Template:" prefix |
{ | ||
"name": "wikiapi", | ||
"title": "JavaScript MediaWiki API for node.js", | ||
"version": "1.14.0", | ||
"version": "1.14.1", | ||
"description": "A simple way to access MediaWiki API via JavaScript with simple wikitext parser.", | ||
@@ -6,0 +6,0 @@ "keywords": [ "MediaWiki", "MediaWiki API", "wikitext", "ECMAScript 2017", "wikidata", "wdq", "sparql" ], |
@@ -83,3 +83,3 @@ [![npm version](https://badge.fury.io/js/wikiapi.svg)](https://www.npmjs.com/package/wikiapi) | ||
// exmaple 3 | ||
await enwiki.edit('Just replace by this wikitext', {bot: 1, minor: 1, nocreate: 1}); | ||
await enwiki.edit('Just replace by this wikitext', {bot: 1, minor: 1, nocreate: 1, summary: 'test edit'}); | ||
@@ -96,3 +96,3 @@ console.log('Done.'); | ||
+ '\nTest edit using {{GitHub|kanasimi/wikiapi}}.'; | ||
}, {bot: 1, nocreate: 1, minor: 1}); | ||
}, {bot: 1, nocreate: 1, minor: 1, summary: 'test edit'}); | ||
console.log('Done.'); | ||
@@ -111,3 +111,3 @@ })(); | ||
// Only needed if ypu want to modify page. | ||
summary: 'summary', | ||
summary: 'test edit', | ||
bot: 1, nocreate: 1, minor: 1 | ||
@@ -114,0 +114,0 @@ }); |
@@ -110,2 +110,4 @@ 'use strict'; | ||
get() { | ||
//console.trace(this); | ||
//console.log(wiki_API.content_of(this, 0)); | ||
return wiki_API.content_of(this, 0); | ||
@@ -122,5 +124,9 @@ } | ||
// this === page_data | ||
options = { ...options, [KEY_SESSION]: this[KEY_wiki_session] }; | ||
// function parse_page(options) @ CeL.wiki | ||
return wiki_API.parser(this, options).parse(options); | ||
//options = { ...options, [KEY_SESSION]: this[KEY_wiki_session] }; | ||
options = wikiapi.prototype.append_session_to_options.call(this, options); | ||
// using function parse_page(options) @ CeL.wiki | ||
return wiki_API.parser(this, options).parse(); | ||
// return {Array}parsed | ||
} | ||
@@ -130,2 +136,11 @@ }, | ||
function set_page_data_attributes(page_data, wiki) { | ||
// `page_data` maybe non-object when error occurres. | ||
if (page_data) { | ||
page_data[KEY_wiki_session] = wiki; | ||
Object.defineProperties(page_data, page_data_attributes); | ||
} | ||
return page_data; | ||
} | ||
function wikiapi_page(title, options) { | ||
@@ -138,7 +153,3 @@ function wikiapi_page_executor(resolve, reject) { | ||
} else { | ||
if (page_data) { | ||
page_data[KEY_wiki_session] = wiki; | ||
Object.defineProperties(page_data, page_data_attributes); | ||
} | ||
resolve(page_data); | ||
resolve(set_page_data_attributes(page_data, wiki)); | ||
} | ||
@@ -225,7 +236,4 @@ }, { | ||
// TODO: for (typeof content === 'function'), | ||
// set page_data_attributes | ||
// wiki.edit(page contents, options, callback) | ||
wiki.edit(content, options, (title, error, result) => { | ||
wiki.edit(typeof content === 'function' ? page_data => content(set_page_data_attributes(page_data, wiki)) : content, options, (title, error, result) => { | ||
// console.trace('wikiapi_edit_page: callbacked'); | ||
@@ -586,3 +594,3 @@ // console.log(title); | ||
} | ||
resolve(redirect_list); | ||
resolve(redirect_list || root_page_data); | ||
} | ||
@@ -622,3 +630,3 @@ }, this.append_session_to_options({ | ||
// or: | ||
// alternative method: | ||
switch (wiki_session.redirect_target_of(token)) { | ||
@@ -713,7 +721,3 @@ case wiki_session.redirect_target_of(template_name_1): | ||
try { | ||
// `page_data` maybe non-object when error occurres. | ||
if (page_data) { | ||
page_data[KEY_wiki_session] = wiki; | ||
Object.defineProperties(page_data, page_data_attributes); | ||
} | ||
set_page_data_attributes(page_data, wiki); | ||
@@ -943,3 +947,4 @@ if (work_options.will_call_methods) { | ||
//Object.assign({ [KEY_SESSION]: wiki }, options) | ||
return { ...options, [KEY_SESSION]: this[KEY_wiki_session] }; | ||
//return { ...options, [KEY_SESSION]: this[KEY_wiki_session] }; | ||
return wiki_API.add_session_to_options(this[KEY_wiki_session], options); | ||
}, | ||
@@ -1003,3 +1008,3 @@ | ||
// wrapper for sync functions | ||
for (const function_name of ('namespace|remove_namespace|is_namespace|to_namespace|is_talk_namespace|to_talk_page|talk_page_to_main|normalize_title|redirect_target_of|is_template' | ||
for (const function_name of ('namespace|remove_namespace|is_namespace|to_namespace|is_talk_namespace|to_talk_page|talk_page_to_main|normalize_title|redirect_target_of|aliases_of_page|is_template' | ||
// CeL.run('application.net.wiki.featured_content'); | ||
@@ -1006,0 +1011,0 @@ // [].map(wiki.to_talk_page.bind(wiki)) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59948
1267