Skip to content

Commit

Permalink
fix wiki_API.wmflabs
Browse files Browse the repository at this point in the history
  • Loading branch information
kanasimi committed Dec 23, 2023
1 parent 9a1c6bb commit 6524d35
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
11 changes: 11 additions & 0 deletions _test suite/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4693,6 +4693,17 @@ function test_wiki() {
token = CeL.wiki.parse('{{WPBS|1=\n{{TT}}\n}}');
assert(['{{WPBS|class=A|vital=yes|1=\n{{TT}}\n}}', CeL.wiki.parse.replace_parameter(token, { 'class': 'A', vital: 'yes' }, { value_only: true, force_add: true, before_parameter: 1, no_value_space: true }) === 2 && token.toString()], 'wiki.parse.replace_parameter remove parameter: #4');

wikitext = '{{t1|p1=1|p2=2|p4=}}'; parsed = CeL.wiki.parse(wikitext);
var parsed_2 = CeL.wiki.parse('{{ T1|p3=3|p4=4}}');
assert([false, !!CeL.wiki.parse.merge_template_parameters(parsed, parsed_2)], 'merge_template_parameters #1');
assert(['{{t1|p1=1|p2=2|p4=4|p3=3}}', parsed.toString()], 'merge_template_parameters #2');
parsed_2 = CeL.wiki.parse('{{ T1 |p4=3|p3=4}}');
assert(['p4,p3', CeL.wiki.parse.merge_template_parameters(parsed, parsed_2).join()], 'merge_template_parameters conflict #1');
assert(['{{t1|p1=1|p2=2|p4=4|p3=3}}', parsed.toString()], 'merge_template_parameters conflict #2');
parsed_2 = CeL.wiki.parse('{{ T1|p4=3|p5=5}}');
assert(['p4', CeL.wiki.parse.merge_template_parameters(parsed, parsed_2).join()], 'merge_template_parameters conflict #3');
assert(['{{t1|p1=1|p2=2|p4=4|p3=3}}', parsed.toString()], 'merge_template_parameters conflict #4');

wikitext = '{{Wikipedia:削除依頼/ログ/{{#time:Y年Fj日|-7 days +9 hours}}}}'; parsed = CeL.wiki.parser(wikitext).parse();
assert([wikitext, parsed.toString()], 'wiki.parse: {{#parserfunctions:}} #1');
token = [];
Expand Down
11 changes: 9 additions & 2 deletions application/net/wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,17 @@ function module_code(library_namespace) {
// function setup_wmflabs()

// only for node.js.
// https://wikitech.wikimedia.org/wiki/Help:Toolforge/FAQ#How_can_I_detect_if_I.27m_running_in_Cloud_VPS.3F_And_which_project_.28tools_or_toolsbeta.29.3F
if (library_namespace.platform.nodejs) {
/** {String}Wikimedia Toolforge name. CeL.wiki.wmflabs */
wiki_API.wmflabs = require('fs').existsSync('/etc/wmflabs-project')
wiki_API.wmflabs =
// inside
// https://wikitech.wikimedia.org/wiki/Help:Toolforge/Kubernetes
library_namespace.env.TOOL_DATA_DIR
//
&& library_namespace.env.KUBERNETES_PORT

// https://wikitech.wikimedia.org/wiki/Help:Toolforge/FAQ#How_can_I_detect_if_I.27m_running_in_Cloud_VPS.3F_And_which_project_.28tools_or_toolsbeta.29.3F
|| require('fs').existsSync('/etc/wmflabs-project')
// e.g., 'tools-bastion-05'.
// if use `process.env.INSTANCEPROJECT`,
// you may get 'tools' or 'tools-login'.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cejs",
"title": "CeJS",
"version": "4.5.5",
"version": "4.5.6",
"description": "A JavaScript module framework that is simple to use.",
"keywords": [
"arbitrary-precision",
Expand Down

0 comments on commit 6524d35

Please sign in to comment.