Mvolz has uploaded a new change for review. https://gerrit.wikimedia.org/r/314712
Change subject: Add credit line for Zotero citations ...................................................................... Add credit line for Zotero citations Bug: T145464 Change-Id: If181b9bfc8384fa31b2d6e3b082cc0470bf96546 --- M extension.json M i18n/en.json M i18n/qqq.json M modules/ve.ui.CiteFromIdInspector.css M modules/ve.ui.CiteFromIdInspector.js 5 files changed, 29 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Citoid refs/changes/12/314712/1 diff --git a/extension.json b/extension.json index 6d771d4..1a01d7b 100644 --- a/extension.json +++ b/extension.json @@ -47,6 +47,7 @@ "citoid-520-error", "citoid-citation-widget-insert-button", "citoid-citefromiddialog-back", + "citoid-citefromiddialog-credit", "citoid-citefromiddialog-lookup-button", "citoid-citefromiddialog-mode-auto", "citoid-citefromiddialog-mode-manual", diff --git a/i18n/en.json b/i18n/en.json index f36eee3..84d8c86 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -5,6 +5,7 @@ "citoid-520-error": "Unable to retrieve information from the provided identifier.", "citoid-citation-widget-insert-button": "Insert", "citoid-citefromiddialog-back": "Back", + "citoid-citefromiddialog-credit": "Powered by $1", "citoid-citefromiddialog-lookup-button": "Generate", "citoid-citefromiddialog-mode-auto": "Automatic", "citoid-citefromiddialog-mode-manual": "Manual", diff --git a/i18n/qqq.json b/i18n/qqq.json index 9498378..b2ffbd2 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -14,6 +14,7 @@ "citoid-520-error": "Error message for when citoid service returns a 520 error", "citoid-citation-widget-insert-button": "Label for the button to insert a chosen reference.\n{{Identical|Insert}}", "citoid-citefromiddialog-back": "Label for the button to go back to the generate panel in the inspector.\n{{Identical|Back}}", + "citoid-citefromiddialog-credit": "Text giving credit for the source of the retrieved citation; variable is name of source, i.e. 'Zotero'.", "citoid-citefromiddialog-lookup-button": "Label for the generate button for citation inputs. Unlike \"search\", \"generate\" is a process in which there is certainty that a particular result will be found, for example, matching a valid ISBN to a book title.\n{{Identical|Generate}}", "citoid-citefromiddialog-mode-auto": "Label of tab in citation dialog ({{msg-mw|Citoid-citefromiddialog-title}}), used to select mode. The other tabs are {{msg-mw|Citoid-citefromiddialog-mode-manual}} and {{msg-mw|Citoid-citefromiddialog-mode-reuse}}.\n{{Identical|Automatic}}", "citoid-citefromiddialog-mode-manual": "Label of tab in citation dialog, used to select mode.\n{{Identical|Manual}}", diff --git a/modules/ve.ui.CiteFromIdInspector.css b/modules/ve.ui.CiteFromIdInspector.css index 9b998ed..e2ab05d 100644 --- a/modules/ve.ui.CiteFromIdInspector.css +++ b/modules/ve.ui.CiteFromIdInspector.css @@ -55,6 +55,11 @@ z-index: 1; } +.ve-ui-citeFromIdInspector-credit { + font-size:x-small; + text-align:right; +} + .ve-ui-citeFromIdInspector-dialog-error { margin-top: 1em; color: #c00; @@ -75,4 +80,4 @@ .ve-ui-citeFromIdInspector-sourceSelect .ve-ui-citeSourceSelectWidget-basic { width: 100%; -} +} \ No newline at end of file diff --git a/modules/ve.ui.CiteFromIdInspector.js b/modules/ve.ui.CiteFromIdInspector.js index 9689e3d..03dc675 100644 --- a/modules/ve.ui.CiteFromIdInspector.js +++ b/modules/ve.ui.CiteFromIdInspector.js @@ -199,6 +199,7 @@ // Preview fieldset this.previewSelectWidget = new ve.ui.CiteFromIdGroupWidget(); + this.credit = null; this.autoProcessPanels.result.$element.append( this.previewSelectWidget.$element ); // Manual mode @@ -480,6 +481,9 @@ // Clear selection this.sourceSelect.selectItem(); + // Clear credit line + this.credit.$element.remove(); + // Reset if ( this.lookupPromise ) { this.lookupPromise.abort(); @@ -516,6 +520,8 @@ return new OO.ui.Process( function () { // Clear the results this.setModePanel( 'auto', 'lookup' ); + // Clear credit line + this.credit.$element.remove(); }, this ); } // Fallback to parent handler @@ -631,6 +637,7 @@ this.results.push( { templateName: templateName, template: null, + source: citation.source, // May be undefined or Array transclusionModel: new ve.dm.MWTransclusionModel() } ); result = this.results[ this.results.length - 1 ]; @@ -646,7 +653,8 @@ return $.when.apply( $, partPromises ) .then( function () { - var optionWidgets = []; + var sources = [], + optionWidgets = []; // Create option widgets for ( i = 0; i < inspector.results.length; i++ ) { refWidget = new ve.ui.CiteFromIdReferenceWidget( @@ -657,12 +665,22 @@ templateName: inspector.results[ i ].templateName, citeTools: inspector.citeTools } ); + sources.push( inspector.results[i].source ); // source may be undefined or Array of strings optionWidgets.push( refWidget ); renderPromises.push( refWidget.getRenderPromise() ); } if ( optionWidgets.length > 0 ) { - // Add to the select widget + // Add citations to the select widget inspector.previewSelectWidget.addItems( optionWidgets ); + // Add credit item only for result to the widget, currently for Zotero only + if ( sources[ 0 ] && ( sources[ 0 ].indexOf( 'Zotero' ) > -1 ) ) { + inspector.credit = new OO.ui.Element( { + tag: 'div', + text: OO.ui.deferMsg( 'citoid-citefromiddialog-credit', [ 'Zotero' ] ), + classes: [ 've-ui-citeFromIdInspector-credit' ] + } ); + inspector.previewSelectWidget.$element.append( inspector.credit.$element ); + } return $.when.apply( $, renderPromises ); } // failed, so go back -- To view, visit https://gerrit.wikimedia.org/r/314712 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If181b9bfc8384fa31b2d6e3b082cc0470bf96546 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Citoid Gerrit-Branch: master Gerrit-Owner: Mvolz <mv...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits