Mooeypoo has uploaded a new change for review.
https://gerrit.wikimedia.org/r/196077
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, 68 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Citoid
refs/changes/77/196077/1
diff --git a/Citoid.php b/Citoid.php
index 07fccb8..c0a070a 100644
--- a/Citoid.php
+++ b/Citoid.php
@@ -44,7 +44,8 @@
),
'dependencies ' => array(
'ext.visualEditor.mwreference',
- 'json'
+ 'json',
+ 'ext.visualEditor.viewPageTarget'
),
'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..d87fcc8 100644
--- a/modules/ve.ui.CiteFromIdInspectorTool.js
+++ b/modules/ve.ui.CiteFromIdInspectorTool.js
@@ -1,5 +1,67 @@
( 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: Rebuild the toolbarGroups to represent citoid and the
+ * dropdown menu for cite tools.
+ */
+ ve.init.mw.Target.static.toolbarGroups = ( function () {
+ var tool,
+ index = 4,
+ toolGroups = ve.copy(
ve.init.mw.Target.static.toolbarGroups );
+
+ // 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 ( tool in toolGroups ) {
+ if ( ve.getProp( toolGroups[tool], 'include', 0,
'group', 'cite' ) ) {
+ index = tool;
+ break;
+ }
+ }
+
+ toolGroups[ index ] = {
+ header: OO.ui.deferMsg(
'visualeditor-toolbar-cite-group' ),
+ title: OO.ui.deferMsg(
'visualeditor-toolbar-cite-group-tooltip' ),
+ include: [ 'citefromid', 'moreCiteTool' ]
+ };
+ return toolGroups;
+ }() );
+
+ /**
+ * 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 = {
+ indicator: 'down',
+ title: OO.ui.deferMsg(
'visualeditor-toolbar-cite-group-tooltip' ),
+ include: [ { group: 'cite' }, 'reference', 'reference/existing'
],
+ demote: [ 'reference', 'reference/existing' ]
+ };
+ ve.ui.toolFactory.register( ve.ui.MoreCiteTool );
+
/**
* MediaWiki UserInterface cite from ID inspector tool.
*
@@ -11,13 +73,6 @@
* @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 +82,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: newchange
Gerrit-Change-Id: I5f98aa74005efd273d78e837352a72851e773217
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits