jenkins-bot has submitted this change and it was merged.
Change subject: Add a tool group to VE toolbar with Citoid
......................................................................
Add a tool group to VE toolbar with Citoid
Override the toolbarGroups to add in a toolGroupTool that is cite
and a group of specific citations.
Change-Id: I5f98aa74005efd273d78e837352a72851e773217
---
M Citoid.php
M i18n/en.json
M i18n/qqq.json
M modules/ve.ui.CiteFromIdInspectorTool.js
4 files changed, 62 insertions(+), 12 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Citoid.php b/Citoid.php
index 07fccb8..39a8871 100644
--- a/Citoid.php
+++ b/Citoid.php
@@ -44,7 +44,8 @@
),
'dependencies ' => array(
'ext.visualEditor.mwreference',
- 'json'
+ 'json',
+ 'ext.visualEditor.mediawiki'
),
'messages' => array(
'citoid-520-error',
diff --git a/i18n/en.json b/i18n/en.json
index 0bddd6b..74b3b98 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,8 +8,8 @@
"citoid-citeFromIDDialog-search-label": "URL or DOI",
"citoid-citeFromIDDialog-search-placeholder": "e.g.
http://www.example.com",
"citoid-citeFromIDDialog-search-progress": "Searching, please wait...",
- "citoid-citeFromIDDialog-title": "Autofill citations by URL or DOI",
- "citoid-citeFromIDTool-title": "Autofill from URL",
+ "citoid-citeFromIDDialog-title": "Add a citation",
+ "citoid-citeFromIDTool-title": "Cite",
"citoid-desc": "Provides access points between the citoid service and
MediaWiki",
"citoid-typeMap-config-error": "Mediawiki:citoid-template-type-map.json
is improperly configured.",
"citoid-unknown-error": "An unknown error has occured that prevented us
from creating a citation. Please try again later."
diff --git a/i18n/qqq.json b/i18n/qqq.json
index f4298f5..0e444bb 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -11,7 +11,7 @@
"citoid-citeFromIDDialog-search-placeholder": "Placeholder for the
URL/DOI search field.",
"citoid-citeFromIDDialog-search-progress": "Message for when the search
is in progress",
"citoid-citeFromIDDialog-title": "The title displayed on the dialog",
- "citoid-citeFromIDTool-title": "What the dialog is called in the menu",
+ "citoid-citeFromIDTool-title": "Label for the button to add a citation
in the toolbar",
"citoid-desc":
"{{desc|name=Citoid|url=http://www.mediawiki.org/wiki/Citoid}}",
"citoid-typeMap-config-error": "Error message indicating
Mediawiki:citoid-template-type-map.json either doesn't exist or contains
errors.",
"citoid-unknown-error": "Error message indicating that the service to
create citations has returned an error or is temporarily malfunctioning, asking
the user to try again later."
diff --git a/modules/ve.ui.CiteFromIdInspectorTool.js
b/modules/ve.ui.CiteFromIdInspectorTool.js
index 2acb07f..d59466a 100644
--- a/modules/ve.ui.CiteFromIdInspectorTool.js
+++ b/modules/ve.ui.CiteFromIdInspectorTool.js
@@ -1,4 +1,60 @@
( function () {
+ // Don't create tool unless the configuration message is present
+ try {
+ JSON.parse( mw.message( 'citoid-template-type-map.json'
).plain() );
+ } catch ( e ) {
+ return;
+ }
+
+ // HACK: Find the position of the current citation toolbar definition
+ // and manipulate it.
+ var i, len, originalDefinition,
+ toolGroups = ve.init.mw.Target.static.toolbarGroups,
+ citeIndex = toolGroups.length;
+
+ // Instead of using the rigid position of the group,
+ // downgrade this hack from horrific to somewhat less horrific by
+ // looking through the object to find what we actually need
+ // to replace. This way, if toolbarGroups are changed in VE code
+ // we won't have to manually change the index here.
+ for ( i = 0, len = toolGroups.length; i < len; i++ ) {
+ if ( ve.getProp( toolGroups[i], 'include', 0, 'group' ) ===
'cite' ) {
+ citeIndex = i;
+ originalDefinition = ve.copy( toolGroups[i] );
+ // Remove the label, since we only need a
downward-arrow indicator
+ delete originalDefinition.label;
+ break;
+ }
+ }
+
+ // HACK: Replace the previous cite group to represent citoid and the
+ // dropdown menu for cite tools.
+ ve.init.mw.Target.static.toolbarGroups[ citeIndex ] = {
+ header: OO.ui.deferMsg( 'visualeditor-toolbar-cite-group' ),
+ title: OO.ui.deferMsg(
'visualeditor-toolbar-cite-group-tooltip' ),
+ include: [ 'citefromid', 'moreCiteTool' ]
+ };
+
+ /**
+ * MediaWiki UserInterface citation tool group
+ *
+ * @class
+ * @extends OO.ui.ToolGroupTool
+ * @constructor
+ * @param {OO.ui.ToolGroup} toolGroup
+ * @param {Object} [config] Configuration options
+ */
+ ve.ui.MoreCiteTool = function VeUiMoreCiteTool( toolGroup, config ) {
+ OO.ui.ToolGroupTool.call( this, toolGroup, config );
+ };
+ OO.inheritClass( ve.ui.MoreCiteTool, OO.ui.ToolGroupTool );
+ ve.ui.MoreCiteTool.static.autoAddToCatchall = false;
+ ve.ui.MoreCiteTool.static.name = 'moreCiteTool';
+ ve.ui.MoreCiteTool.static.group = 'citeTools';
+ ve.ui.MoreCiteTool.static.title =
+ OO.ui.deferMsg( 'visualeditor-toolbar-cite-tooltip' );
+ ve.ui.MoreCiteTool.static.groupConfig = originalDefinition;
+ ve.ui.toolFactory.register( ve.ui.MoreCiteTool );
/**
* MediaWiki UserInterface cite from ID inspector tool.
@@ -10,14 +66,6 @@
* @param {OO.ui.Toolbar} toolbar
* @param {Object} [config] Configuration options
*/
-
- // Don't create tool unless the configuration message is present
- try {
- JSON.parse( mw.message( 'citoid-template-type-map.json'
).plain() );
- } catch ( e ) {
- return;
- }
-
ve.ui.CiteFromIdInspectorTool = function VeUiCiteFromIdInspectorTool(
toolGroup, config ) {
ve.ui.InspectorTool.call( this, toolGroup, config );
};
@@ -27,6 +75,7 @@
ve.ui.CiteFromIdInspectorTool.static.name = 'citefromid';
ve.ui.CiteFromIdInspectorTool.static.icon = 'ref-cite-web';
ve.ui.CiteFromIdInspectorTool.static.title = OO.ui.deferMsg(
'citoid-citeFromIDTool-title' );
+ ve.ui.CiteFromIdInspectorTool.static.label = OO.ui.deferMsg(
'citoid-citeFromIDTool-title' );
ve.ui.CiteFromIdInspectorTool.static.group = 'cite';
ve.ui.CiteFromIdInspectorTool.static.commandName = 'citefromid';
--
To view, visit https://gerrit.wikimedia.org/r/196077
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5f98aa74005efd273d78e837352a72851e773217
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits