[MediaWiki-commits] [Gerrit] Make visualeditor-cite-tool-definition.json always exist, re... - change (mediawiki...Cite)

2016-06-25 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Make visualeditor-cite-tool-definition.json always exist, 
rename to cite-tool-definition.json
..


Make visualeditor-cite-tool-definition.json always exist, rename to 
cite-tool-definition.json

Bug: T138573
Change-Id: I454380c392feea55483d00d4b7eec45bce04ff53
---
M CiteDataModule.php
M modules/ve-cite/i18n/en.json
M modules/ve-cite/i18n/qqq.json
M modules/ve-cite/ve.ui.MWReference.init.js
4 files changed, 19 insertions(+), 1 deletion(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CiteDataModule.php b/CiteDataModule.php
index e2468a0..0e2d9a3 100644
--- a/CiteDataModule.php
+++ b/CiteDataModule.php
@@ -21,11 +21,19 @@
 
public function getScript( ResourceLoaderContext $context ) {
$citationDefinition = json_decode(
-   $context->msg( 'visualeditor-cite-tool-definition.json' 
)
+   $context->msg( 'cite-tool-definition.json' )
->inContentLanguage()
->plain()
);
 
+   if ( $citationDefinition === null ) {
+   $citationDefinition = json_decode(
+   $context->msg( 
'visualeditor-cite-tool-definition.json' )
+   ->inContentLanguage()
+   ->plain()
+   );
+   }
+
$citationTools = [];
if ( is_array( $citationDefinition ) ) {
foreach ( $citationDefinition as $tool ) {
diff --git a/modules/ve-cite/i18n/en.json b/modules/ve-cite/i18n/en.json
index 263c2f0..a965889 100644
--- a/modules/ve-cite/i18n/en.json
+++ b/modules/ve-cite/i18n/en.json
@@ -16,10 +16,12 @@
"Amir E. Aharoni"
]
},
+   "visualeditor-cite-tool-definition.json": "null",
"visualeditor-cite-tool-name-book": "Book",
"visualeditor-cite-tool-name-journal": "Journal",
"visualeditor-cite-tool-name-news": "News",
"visualeditor-cite-tool-name-web": "Website",
+   "cite-tool-definition.json": "null",
"cite-ve-dialog-reference-editing-reused": "This reference is used $1 
{{PLURAL:$1|times}} on this page.",
"cite-ve-dialog-reference-options-group-label": "Use this group",
"cite-ve-dialog-reference-options-group-placeholder": "General 
references",
diff --git a/modules/ve-cite/i18n/qqq.json b/modules/ve-cite/i18n/qqq.json
index 2abccd3..003eece 100644
--- a/modules/ve-cite/i18n/qqq.json
+++ b/modules/ve-cite/i18n/qqq.json
@@ -26,10 +26,12 @@
"Umherirrender"
]
},
+   "visualeditor-cite-tool-definition.json": "Legacy name for 
cite-tool-definition.json message.",
"visualeditor-cite-tool-name-book": "Title of tool that inserts a 
citation for a book.\n{{Identical|Book}}",
"visualeditor-cite-tool-name-journal": "Title of tool that inserts a 
citation for a journal\n{{Identical|Journal}}",
"visualeditor-cite-tool-name-news": "Title of tool that inserts a 
citation for a news.\n{{Identical|News}}",
"visualeditor-cite-tool-name-web": "Title of tool that inserts a 
citation for a website.\n{{Identical|Website}}",
+   "cite-tool-definition.json": "JSON list of objects detailing each 
citation with name (key referring to a visualeditor-cite-tool-name-x message), 
icon ('ref-cite-book', 'ref-cite-journal', 'ref-cite-news', 'ref-cite-web'), 
and template name",
"cite-ve-dialog-reference-editing-reused": "Text shown at the top of 
the reference dialog when editing a reference that is used multiple 
times.\n\nParameters:\n* $1 - Number of times used. This is always greater than 
1.",
"cite-ve-dialog-reference-options-group-label": "Label for the 
reference group input",
"cite-ve-dialog-reference-options-group-placeholder": "Placeholder for 
the reference group input",
diff --git a/modules/ve-cite/ve.ui.MWReference.init.js 
b/modules/ve-cite/ve.ui.MWReference.init.js
index 46c0cd5..85b113e 100644
--- a/modules/ve-cite/ve.ui.MWReference.init.js
+++ b/modules/ve-cite/ve.ui.MWReference.init.js
@@ -77,6 +77,12 @@
// Must use mw.message to avoid JSON being parsed as 
Wikitext
tools = JSON.parse( mw.message( 
'visualeditor-cite-tool-definition.json' ).plain() );
} catch ( e ) {}
+   if ( !tools ) {
+   try {
+   // Must use mw.message to avoid JSON being 
parsed as Wikitext
+   tools = JSON.parse( mw.message( 
'cite-tool-definition.json' ).plain() );
+   } catch ( e ) {}
+   }
 
if ( Array.isArray( tools ) ) {
  

[MediaWiki-commits] [Gerrit] Make visualeditor-cite-tool-definition.json always exist, re... - change (mediawiki...Cite)

2016-06-24 Thread Alex Monk (Code Review)
Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/295972

Change subject: Make visualeditor-cite-tool-definition.json always exist, 
rename to cite-tool-definition.json
..

Make visualeditor-cite-tool-definition.json always exist, rename to 
cite-tool-definition.json

Bug: T138573
Change-Id: I454380c392feea55483d00d4b7eec45bce04ff53
---
M CiteDataModule.php
M modules/ve-cite/i18n/en.json
M modules/ve-cite/i18n/qqq.json
M modules/ve-cite/ve.ui.MWReference.init.js
4 files changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cite 
refs/changes/72/295972/1

diff --git a/CiteDataModule.php b/CiteDataModule.php
index e2468a0..0e2d9a3 100644
--- a/CiteDataModule.php
+++ b/CiteDataModule.php
@@ -21,11 +21,19 @@
 
public function getScript( ResourceLoaderContext $context ) {
$citationDefinition = json_decode(
-   $context->msg( 'visualeditor-cite-tool-definition.json' 
)
+   $context->msg( 'cite-tool-definition.json' )
->inContentLanguage()
->plain()
);
 
+   if ( $citationDefinition === null ) {
+   $citationDefinition = json_decode(
+   $context->msg( 
'visualeditor-cite-tool-definition.json' )
+   ->inContentLanguage()
+   ->plain()
+   );
+   }
+
$citationTools = [];
if ( is_array( $citationDefinition ) ) {
foreach ( $citationDefinition as $tool ) {
diff --git a/modules/ve-cite/i18n/en.json b/modules/ve-cite/i18n/en.json
index 263c2f0..a965889 100644
--- a/modules/ve-cite/i18n/en.json
+++ b/modules/ve-cite/i18n/en.json
@@ -16,10 +16,12 @@
"Amir E. Aharoni"
]
},
+   "visualeditor-cite-tool-definition.json": "null",
"visualeditor-cite-tool-name-book": "Book",
"visualeditor-cite-tool-name-journal": "Journal",
"visualeditor-cite-tool-name-news": "News",
"visualeditor-cite-tool-name-web": "Website",
+   "cite-tool-definition.json": "null",
"cite-ve-dialog-reference-editing-reused": "This reference is used $1 
{{PLURAL:$1|times}} on this page.",
"cite-ve-dialog-reference-options-group-label": "Use this group",
"cite-ve-dialog-reference-options-group-placeholder": "General 
references",
diff --git a/modules/ve-cite/i18n/qqq.json b/modules/ve-cite/i18n/qqq.json
index 2abccd3..003eece 100644
--- a/modules/ve-cite/i18n/qqq.json
+++ b/modules/ve-cite/i18n/qqq.json
@@ -26,10 +26,12 @@
"Umherirrender"
]
},
+   "visualeditor-cite-tool-definition.json": "Legacy name for 
cite-tool-definition.json message.",
"visualeditor-cite-tool-name-book": "Title of tool that inserts a 
citation for a book.\n{{Identical|Book}}",
"visualeditor-cite-tool-name-journal": "Title of tool that inserts a 
citation for a journal\n{{Identical|Journal}}",
"visualeditor-cite-tool-name-news": "Title of tool that inserts a 
citation for a news.\n{{Identical|News}}",
"visualeditor-cite-tool-name-web": "Title of tool that inserts a 
citation for a website.\n{{Identical|Website}}",
+   "cite-tool-definition.json": "JSON list of objects detailing each 
citation with name (key referring to a visualeditor-cite-tool-name-x message), 
icon ('ref-cite-book', 'ref-cite-journal', 'ref-cite-news', 'ref-cite-web'), 
and template name",
"cite-ve-dialog-reference-editing-reused": "Text shown at the top of 
the reference dialog when editing a reference that is used multiple 
times.\n\nParameters:\n* $1 - Number of times used. This is always greater than 
1.",
"cite-ve-dialog-reference-options-group-label": "Label for the 
reference group input",
"cite-ve-dialog-reference-options-group-placeholder": "Placeholder for 
the reference group input",
diff --git a/modules/ve-cite/ve.ui.MWReference.init.js 
b/modules/ve-cite/ve.ui.MWReference.init.js
index 46c0cd5..85b113e 100644
--- a/modules/ve-cite/ve.ui.MWReference.init.js
+++ b/modules/ve-cite/ve.ui.MWReference.init.js
@@ -77,6 +77,12 @@
// Must use mw.message to avoid JSON being parsed as 
Wikitext
tools = JSON.parse( mw.message( 
'visualeditor-cite-tool-definition.json' ).plain() );
} catch ( e ) {}
+   if ( !tools ) {
+   try {
+   // Must use mw.message to avoid JSON being 
parsed as Wikitext
+   tools = JSON.parse( mw.message( 
'cite-tool-definition.json' ).plain() );
+   } catch ( e ) {}
+   }